TL;DR
When external context contradicts a language model’s parametric memory, the model doesn't just passively guess—it internally registers the disagreement. By linearly probing the residual stream of models like Llama 3 (8B), this paper shows that conflict signals peak around layer 14, followed by knowledge selection decisions around layer 17. Moreover, relying on contextual versus parametric knowledge produces distinctly skewed activation distributions in deeper layers, enabling accurate prediction of model behavior before output generation begins.
What Problem Does This Paper Address?
Large language models (LLMs) rely heavily on retrieval-augmented generation (RAG) to access up-to-date or domain-specific facts. However, retrieved context often conflicts with the model’s internal parametric knowledge—whether due to outdated information, retrieval errors, or counterfactual noise.
Standard approaches to catch these conflicts rely on multi-step prompting (e.g., asking the model to verify statements sentence-by-sentence) or fine-tuning. These methods introduce high inference latency and treat the model as a black box. The authors ask two fundamental mechanistic questions:
- Can LLMs internally recognize knowledge conflicts within their activations?
- Can we predict whether an LLM will favor context or memory before it generates its answer?
Methods
The authors analyze the Transformer residual stream—the accumulated representation passed across layers via skip connections—at the final prompt token right before decoding the first answer token.
- Linear Probing: A simple logistic regression classifier with $L_1$ regularization is trained on intermediate activations (the residual hidden state $h^l$, self-attention outputs $a^l$, and MLP outputs $m^l$ across layer $l$).
- Conflict Detection Probe: Distinguishes activations given conflicting context ($e_C$) versus memory-consistent context ($e_M$).
- Knowledge Selection Probe: For conflicting inputs, predicts whether the generated answer aligns with the context ($a_C$) or internal memory ($a_M$).
- Distributional Geometry: The authors quantify the residual stream's distribution shape using three sparsity/skewness metrics: Kurtosis, Hoyer index, and the Gini coefficient, alongside standard $L_1$ and $L_2$ vector norms.
Datasets
Experiments were conducted using open-domain question answering (ODQA) benchmarks featuring paired memorized and conflicting contexts:
- NQSwap (Longpre et al., 2021)
- Macnoise (Hong et al., 2024)
- ConflictQA (Xie et al., 2024)
Evaluations were performed primarily on Llama-3-8B and Llama-2-7B under greedy decoding with 3-shot in-context demonstrations.
Key Insights and Ideas
- Internal Conflict Emergence is Layer-Specific: Knowledge conflict is virtually invisible in early layers (1–7), rises rapidly around layer 8, and peaks near the mid-point (layers 13–14). Beyond this point, attention and MLP sub-layers contribute less new conflict information.
- A Two-Stage Internal Mechanism: Conflict detection and knowledge resolution operate in sequence. The model first registers the conflict (peaking at layers 13–14), but probing accuracy for which knowledge source wins peaks slightly later (layer 16–17). The model notices the discrepancy before it resolves it.
- Context Reliance Induces Activation Skewness: When the model chooses contextual knowledge over parametric memory, residual stream activations in late layers (layers 20–30) become significantly more skewed (demonstrating higher Kurtosis, Hoyer, and Gini values). Interestingly, the raw $L_1$ and $L_2$ vector magnitudes remain virtually unchanged, showing that context overrides alter activation sparsity rather than overall scale.
Key Results
- High-Accuracy Conflict Detection: A lightweight linear probe on layer 13/14 hidden states detects contextual-parametric conflicts with approximately 90% accuracy and high AUROC/AUPRC (~0.95), introducing negligible compute overhead compared to prompting-based detection pipelines.
- Early Behavior Forecasting: Probing activations at layer 16–17 reliably predicts whether the model will output the contextual ($a_C$) or parametric ($a_M$) answer, providing an early-warning signal for hallucinated or manipulated outputs prior to token generation.
Limitations and Future Work
- Model Scale and Architecture: Experiments focus on 7B/8B parameter dense models (Llama 2 and Llama 3). Behaviors on larger models (e.g., 70B+) or Mixture-of-Experts architectures remain unverified.
- Passive Detection vs. Active Steering: The paper demonstrates that internal signals exist and are linearly separable, but does not implement intervention techniques. The authors note this study provides the foundation for future work steering knowledge selection (e.g., via Sparse Autoencoder-based representation engineering).
- Generation Settings: Probing occurs strictly at the first generated token under greedy decoding; multi-token reasoning dynamics and alternative decoding strategies were not analyzed.
Summary updated