TL;DR
Detecting when an LLM violates complex organizational policies usually requires expensive fine-tuning or slow "LLM-as-a-judge" prompting. This paper introduces a training-free alternative that treats policy violations as an out-of-distribution (OOD) problem in the model's internal activation space. By applying a lightweight whitening transform to hidden states, the method achieves state-of-the-art detection accuracy with negligible latency and compute overhead.
What Problem Does This Paper Address?
As LLMs are increasingly integrated into enterprise workflows (such as legal, financial, and medical applications), they must adhere to strict, nuanced organizational policies. Traditional safety guardrails focus on coarse categories like toxicity or bias, failing to capture complex corporate rules (e.g., "Do not give personalized investment advice").
Current solutions rely on fine-tuning dedicated detector models or using an LLM-as-a-judge to evaluate generated text. However, fine-tuning requires massive, curated datasets and lacks adaptability, while LLM judges introduce significant latency and high API costs, making real-time monitoring impractical for large-scale deployments.
Methods
The authors propose framing policy violation detection as an Out-of-Distribution (OOD) problem within the LLM's activation space. This operates under the hypothesis that compliant responses cluster together in a consistent activation region, while violations deviate into distinct, predictable OOD zones.
The pipeline consists of two phases:
- Offline Reference Statistics Pre-processing: The method extracts layer-wise hidden states (specifically last-token activations) from a small set of in-policy interactions. It computes a PCA-based whitening transformation to center and decorrelate these activations, mapping them to a space with zero mean and unit covariance. A small mixed set of in- and out-of-policy samples is then used to select the optimal transformer layer and calibrate a decision threshold using Youden's statistic.
- Online Detection: At runtime, the model's activations at the selected layer are whitened using the precomputed matrix. Compliance is scored simply by computing the Euclidean norm of the vector; if it exceeds the calibrated threshold, it is flagged as a violation.
Crucially, if the main generator model is a black-box API where internal states are inaccessible, the framework can use an open-weight surrogate model to process the interaction and extract activations instead.
Datasets
- DynaBench: A benchmark evaluating multi-turn user-agent dialogues across 12 complex business policy categories (e.g., regulatory compliance, information leakage, user experience, and tool use).
- $\tau$-bench (Tau-bench): A tool-use agent benchmark where the authors isolated airline domain constraints (booking, refunds) to test real-world agent trajectories containing execution noise.
- Contrastive Datasets: Small, rule-specific datasets (100 examples per policy) generated via GPT-4o (or Llama-3.1-8B) consisting of simple single-turn prompts paired with compliant and violating responses. These are used solely for offline whitening and calibration.
Key Insights and Ideas
- Internal Alignment Exists: The internal states of LLMs encode high-level behavioral properties like policy adherence long before the final tokens are generated.
- Fine-Tuning Might Be Overkill: Applying this whitening method to the internal states of base models yields performance competitive with or superior to heavily fine-tuned compliance models. This suggests base models already "know" the rules; fine-tuning merely teaches them how to express that knowledge in specific output tokens.
- Adversarial Hardening: Because this method monitors internal representations rather than surface-level text, it is incredibly resilient against prompt injection attacks designed to trick text-based LLM judges.
Key Results
- State-of-the-Art Accuracy: The method achieved up to 86.0% F1 on DynaBench using Qwen2.5-7B-Instruct, outperforming fine-tuned baselines like DynaGuard (73.1%) and LLM-as-a-judge approaches (70.1%).
- Blazing Fast & Cheap: It reduces latency by 30–50× compared to LLM-as-a-judge, adding a mere 0.03–0.05 seconds of overhead. Inference cost is also slashed by roughly 7×.
- Robustness: Under adversarial prompt injection attacks, the whitening detector suffered only a 4.23% degradation in F1, compared to a massive >21% drop for both GPT-4o-mini and DynaGuard.
Limitations and Future Work
- Model Dependency: Performance relies heavily on the quality of the underlying model's activation space structure. For instance, Mistral-7B-Instruct yielded weaker separation and lower F1 scores (66.8%) than Qwen or Llama variants.
- Distribution Shifts: While lightweight calibration requires very few samples, extreme distribution shifts between the calibration data and the deployment environment could degrade threshold accuracy, requiring lightweight recalibration.
- Passive Detection Only: The current framework flags violations after or during generation but does not actively prevent them. The authors note that a promising future direction is using these activation-space signals to steer generation proactively toward compliant regions.
Summary updated