mlsanityData to 24 Nov 2026

Auditing and Adapting kNNGuard for Long-Context Prompts

arXiv 2611.27084 ↗Submitted 20 Nov 2026Announced 23 Nov 2026cs.LGcited by 0

New in LLM safety and security; no direction yet. LLM safety and security

Abstract (arXiv)

Training-free activation guardrails such as kNNGuard score prompts by comparing last-token LLM hidden states (the Layer Ensemble branch, kNNGuard LE) and sentence embeddings (all-MiniLM-L6-v2, Embedding-kNN) against a small reference bank (50 examples per class), combining the two branches into a Fused Ensemble (kNNGuard FE). While effective on short inputs (up to 256 tokens), standard kNNGuard degrades substantially on long inputs (over 1000 tokens): averaged across Qwen3.5-4B and Gemma-4-E4B-it, kNNGuard LE AUROC drops from 0.742 (0.777 and 0.706) to 0.554 (0.587 and 0.521) on Content Harm Moderation (Aegis-2.0), and from 0.994 (0.995 and 0.992) to 0.556 (0.598 and 0.513) on RAG Hallucination Detection (HaluBench). We trace this degradation to three causes: (1) hidden-state drift as sequence length increases, (2) hard 256-token truncation in MiniLM, and (3) signal dilution when a long document is compressed into a single final-token vector. We then evaluate three training-free adaptations: a Length-Routed Dual Bank, a long-context embedding model (Qwen3-Embedding-0.6B), and Strided Window Pooling across intermediate token positions. On Content Harm Moderation, dual-bank routing and strided window pooling raise long-context kNNGuard LE AUROC from 0.554 to 0.828 (+0.274 AUROC) and fused kNNGuard FE AUROC from 0.721 to 0.886 (+0.164 AUROC) with no latency overhead from bank routing. On RAG Hallucination Detection, where the guardrail must verify logical consistency between a generated answer and a retrieved passage, sentence-embedding kNN remains near random chance across all lengths, while length-matched LLM hidden states (kNNGuard LE) recover medium-length detection (AUROC = 0.853) but remain limited on over-1000-token passages (AUROC = 0.607) due to final-token dilution over long contexts.

Key facts. No citing papers in the map yet (data through 24 Nov 2026). Builds on 16 of its 27 references that are in the map. Submitted 20 Nov 2026, announced 23 Nov 2026.

Builds on

16 of 27 references.

References · 16

  1. 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,845
  2. 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,559
  3. 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 5,132
  4. 2020MiniLM: Deep Self-Attention Distillation for Task-Agnostic Compression of Pre-Trained Transformerscited by 1,560
  5. 2019PubMedQA: A Dataset for Biomedical Research Question Answeringcited by 1,358
  6. 2019DROP: A Reading Comprehension Benchmark Requiring Discrete Reasoning Over Paragraphscited by 949
  7. 2019Generalization through Memorization: Nearest Neighbor Language Modelscited by 835
  8. 2023The Geometry of Truth: Emergent Linear Structure in Large Language Model Representations of True/False Datasetscited by 810
  9. 2023The Internal State of an LLM Knows When It's Lyingcited by 725
  10. 2023HaluEval: A Large-Scale Hallucination Evaluation Benchmark for Large Language Modelscited by 371
  11. 2025Aegis2.0: A Diverse AI Safety Dataset and Risks Taxonomy for Alignment of LLM Guardrailscited by 154
  12. 2025SafeSwitch: Steering Unsafe LLM Behavior via Internal Activation Signalscited by 32
4 more
  1. 2026Your Agentic LLMs Secretly Encode Indirect Prompt-Injection Exposure in Hidden Statescited by 11
  2. 2026FACTUM: Mechanistic Detection of Citation Hallucination in Long-Form RAGcited by 7
  3. 2025Representation-based Broad Hallucination Detectors Fail to Generalize Out of Distributioncited by 6
  4. 2026kNNGuard: Turning LLM Hidden Activations into a Training-Free Configurable Guardrailcited by 3

Built on by

Not cited yet.

Similar, not cited

Close in wording, no citation either way

  1. 2024The HalluRAG Dataset: Detecting Closed-Domain Hallucinations in RAG Applications Using an LLM's Internal States
  2. 2025TPA: Next Token Probability Attribution for Detecting Hallucinations in RAG
  3. 2025Probabilistic distances-based hallucination detection in LLMs with RAG
  4. 2025Turk-LettuceDetect: A Hallucination Detection Models for Turkish RAG Applications
  5. 2026Prompt Embedding Probes (PEP): Hallucination Detection in LLMs from Hidden States
  6. 2025HALT-RAG: A Task-Adaptable Framework for Hallucination Detection with Calibrated NLI Ensembles and Abstention
  7. 2025SGuard-v1: Safety Guardrail for Large Language Models
  8. 2026RAGognizer: Hallucination-Aware Fine-Tuning via Detection Head Integration