A Mechanistic Analysis of In-Context Learning and Out-of-Context Hallucination
Not on the map. Why?
Abstract (arXiv)
Large language models can infer and follow specific rules through in-context learning (ICL), yet may fail to remain faithful to provided evidence, giving rise to out-of-context (OOC) hallucination. Existing work has largely investigated the underlying mechanisms of ICL and OOC hallucination along separate lines. However, this separation obscures the mechanistic basis for these seemingly opposing outcomes. In this work, we study this contrast through the unified view of functional roles in dynamic context. The key observation is that role information can be internally represented without reliably constraining output. We derive a first-order decomposition to characterize the role effect, showing that its substantial influence depends on two necessary conditions, namely sufficient contribution magnitude and coherent signed aggregation. Causal analysis further shows that role span contributions affect key token choices involving response structure, content selection, and factual values. We further show that role-consistent choices depend on sufficient role span support at these key decisions, while failing choices can be reversed when this support overcomes the deficit. These findings support a common mechanistic view of ICL and OOC hallucination: each functional role defines the pattern of output decisions over which role span contributions must remain effective, and differences in this organization account for the seemingly opposing outcomes.
Key facts. No citing papers in the map yet (data through 24 Nov 2026). Builds on 28 of its 31 references that are in the map. Submitted 18 Nov 2026, announced 19 Nov 2026.
Builds on
28 of 31 references.
References · 28
- 2020Language Models are Few-Shot Learnerscited by 33,113
- 2017Axiomatic Attribution for Deep Networkscited by 3,508
- 2023Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflectioncited by 1,978
- 2023A Survey on Hallucination in Large Language Models: Principles, Taxonomy, Challenges, and Open Questionscited by 1,676
- 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,181
- 2021MuSiQue: Multihop Questions via Single-hop Question Compositioncited by 1,011
- 2021Probing Classifiers: Promises, Shortcomings, and Advancescited by 971
- 2023Large Language Models Can Be Easily Distracted by Irrelevant Contextcited by 909
- 2023Adaptive Chameleon or Stubborn Sloth: Revealing the Behavior of Large Language Models in Knowledge Conflictscited by 410
- 2023Making Retrieval-Augmented Language Models Robust to Irrelevant Contextcited by 393
- 2023Function Vectors in Large Language Modelscited by 353
- 2023In-Context Learning Creates Task Vectorscited by 337
16 more
- 2023RAGTruth: A Hallucination Corpus for Developing Trustworthy Retrieval-Augmented Language Modelscited by 323
- 2024Retrieval Head Mechanistically Explains Long-Context Factualitycited by 272
- 2024Transcoders Find Interpretable LLM Feature Circuitscited by 233
- 2023Compositional Exemplars for In-context Learningcited by 152
- 2024ClashEval: Quantifying the tug-of-war between an LLM's internal prior and external evidencecited by 133
- 2024Make Your LLM Fully Utilize the Contextcited by 125
- 2026CL-bench: A Benchmark for Context Learningcited by 61
- 2024Revisiting Demonstration Selection Strategies in In-Context Learningcited by 60
- 2024Identifying Semantic Induction Heads to Understand In-Context Learningcited by 50
- 2023Pre-Training to Learn in Contextcited by 47
- 2024Mechanistic Understanding and Mitigation of Language Model Non-Factual Hallucinationscited by 41
- 2024Context versus Prior Knowledge in Language Modelscited by 34
- 2024Revisiting In-context Learning Inference Circuit in Large Language Modelscited by 21
- 2025Improving Contextual Faithfulness of Large Language Models via Retrieval Heads-Induced Optimizationcited by 19
- 2024Interpreting Context Look-ups in Transformers: Investigating Attention-MLP Interactionscited by 13
- 2024Demonstration Selection for In-Context Learning via Reinforcement Learningcited by 9
Built on by
Not cited yet.