Farther the Shift, Sparser the Representation: Analyzing OOD Mechanisms in LLMs
cs.CL, cs.AI
Submitted: 2026-03-03
Updated: 2026-09-26
Code: https://github.com/MingyuJ666/sparsityLLM
License: http://creativecommons.org/licenses/by/4.0/
The gist: In this work, we investigate how Large Language Models (LLMs) adapt their internal representations when encountering inputs of increasing difficulty, quantified as the degree of out-of-distribution
Terminology
Abstract
In this work, we investigate how Large Language Models (LLMs) adapt their internal representations when encountering inputs of increasing difficulty, quantified as the degree of out-of-distribution (OOD) shift. We reveal a consistent and quantifiable phenomenon: as task difficulty increases, whether through harder reasoning questions, longer contexts, or adding answer choices, the last hidden states of LLMs become substantially sparser. In short, the farther the shift, the sparser the representations. This sparsity--difficulty relation is observable across diverse models and domains, suggesting that language models respond to unfamiliar or complex inputs by concentrating computation into specialized subspaces in the last hidden state. Through a series of controlled analyses with a learning dynamic explanation, we demonstrate that this sparsity is not incidental but an adaptive mechanism for stabilizing reasoning under OOD. Leveraging this insight, we design Sparsity-Guided Curriculum In-Context Learning (SG-ICL), a strategy that explicitly uses representation sparsity to schedule few-shot demonstrations, leading to considerable performance enhancements. Our study provides new mechanistic insights into how LLMs internalize OOD challenges. The source code is available at the URL: https://github.com/MingyuJ666/sparsityLLM.
Sources
- Eliciting Latent Predictions from Transformers with the Tuned Lens
- SAGE: An Agentic Explainer Framework for Interpreting SAE Features in Language Models
- SAE-SSV: Supervised Steering in Sparse Representation Spaces for Reliable Control of Language Models
- Measuring Faithfulness in Chain-of-Thought Reasoning
- Orca: Progressive Learning from Complex Explanation Traces of GPT-4
- LLaMA: Open and Efficient Foundation Language Models
- DUMP: Automated Distribution-Level Curriculum Learning for RL-based LLM Post-training
- Qwen2.5 Technical Report
- Towards Uncovering How Large Language Model Works: An Explainability Perspective
Related papers
- Exploring Solution Divergence and Its Effect on Large Language Model Problem Solving
- Ishigaki-IDS-Bench: A Benchmark for Generating Information Delivery Specification from BIM Information Requirements
- Subliminal Steering: Stronger Encoding of Hidden Signals
- MedStruct-S: A Benchmark for Key Discovery, Key-Conditioned QA and Semi-Structured Extraction from OCR Clinical Reports
- The End of Transformers? On Challenging Attention and the Rise of Sub-Quadratic Architectures
- Untangling the Mechanisms of Misleading Context in Medical Question Answering