Targeted Retrieval, Compact Representations: How CoT Reasoning Improves Long-Context Counting
Liang Twist Shan, Tianyu Hu, Hao Yan, Yiqiao Zhong
Key points
From the paper's conclusion- Together, our results connect long-context retrieval with representation geometry of counting, supporting a state-tracking account of CoT reasoning.
Abstract
Large language models (LLMs) have been rapidly improving in long-context tasks, powered by Chain-of-Thought (CoT) reasoning. However, the internal mechanisms underlying this improvement remain unclear. We investigate these mechanisms through a needle-in-a-haystack (NIAH) counting task, where an LLM is asked to count the number of records dispersed in a long text. Across twelve model comparison groups, Thinking (or reasoning) improves counting accuracy over Non-thinking, with pronounced gains at larger counts. This motivates our mechanistic analysis, which identifies two contrasting mechanisms: (i) broad retrieval, where Non-thinking models broadly attend to multiple needles; (ii) targeted retrieval, where Thinking models use enumeration in CoT traces to successively retrieve needles. Targeted retrieval concentrates attention on individual needles and is accompanied by more compact internal representations. Moreover, causal intervention analysis suggests that Thinking models use the CoT trace to maintain and update an internal counter as needles are successively retrieved, even without explicit numbering. In small controlled experiments, both retrieval mechanisms and counter states emerge under standard autoregressive training. Together, our results connect long-context retrieval with representation geometry of counting, supporting a state-tracking account of CoT reasoning.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Towards reasoning era: a survey of long chain-of-thought for reasoning large language modelsScience China Information Sciences · 2026
- How Does Chain-of-Thought Supervision Teach Models to Reason? A Theoretical AnalysisarXiv · 2026
- Does Latent Chain-of-Thought Actually Reason? A Single, Unifying Taxonomy for Latent ReasoningarXiv · 2026
- Not All Thinking is Created Equal: Latent Reasoning Discovers a Recurrent Search Algorithm for Depth GeneralizationarXiv · 2026
- Mitigating Query Shortcuts in Chain-of-Thought with Context-Aware DecodingarXiv · 2026
- MCTS Is Counting the Wrong Thing: Learning Exploration Counts for LLM ReasoningarXiv · 2026