TL;DR
While few-shot Chain-of-Thought (CoT) prompting dramatically improves LLM reasoning, models frequently get distracted by isolated, local tokens within the exemplars instead of just mimicking the overarching logic. To combat this, the authors introduce Few-shot Attention Intervention (FAI), a lightweight, inference-time method that dynamically identifies these "isolated" tokens and zeroes out their attention weights to the output token, yielding consistent performance gains across multiple reasoning benchmarks.
What Problem Does This Paper Address?
Few-shot Chain-of-Thought (CoT) prompting is the gold standard for guiding Large Language Models (LLMs) through complex multi-step reasoning tasks. Ideally, the model should treat the few-shot exemplars as holistic templates, learning the abstract style and logical structure of the solution.
However, LLMs are notoriously sensitive to prompt selection. The authors discover a major culprit behind this fragility: contextual distraction. Instead of absorbing the global logic, the model often fixates on specific, isolated numbers or words in the prompt examples and incorrectly injects them into the current problem.
As shown above, an exemplar discussing "quarters in a jar" causes the model to hallucinate the number "160" into a completely unrelated problem about baking cupcakes. Simply deleting these tokens isn't a viable solution, as it breaks the semantic integrity of the prompt.
Methods
To understand how this distraction happens, the authors first trace the internal information flow using attention saliency scores (the Hadamard product of attention weights and gradients). They observe that distracting tokens share a unique signature: they do not aggregate information from surrounding tokens in early layers (remaining semantically isolated), yet they directly channel their raw information to the prediction token in later layers.
To fix this without the massive computational overhead of calculating gradients at inference time, the authors propose Few-shot Attention Intervention (FAI):
- Identify Isolated Tokens: For every token $t_i$ in the demonstration, the model computes an aggregation coefficient $\alpha$ based on its average self-attention score. If a token has a high self-attention score, it means it hasn't integrated much context from other tokens.
- Apply a Dynamic Threshold: A token is flagged as "isolated" if its aggregation coefficient exceeds a position-dependent threshold: $$\tau = \frac{\lambda}{\text{index}_{t_i}}$$
- Intervene in Information Flow: In each layer, for any token flagged as isolated, FAI dynamically zeroes out its attention weight toward the current output token across all attention heads. This effectively blocks the isolated token from hijacking the prediction.
Datasets
The method was evaluated across several diverse reasoning benchmarks:
- Mathematical Reasoning: GSM8K and AQuA.
- Commonsense Reasoning: CSQA.
- Algorithmic/Symbolic Reasoning: Big-Bench-Hard (Date Understanding, Sport Understanding) and Last Letter Concatenation.
Additionally, the authors constructed two targeted subsets from GSM8K to validate their findings: $\text{GSM}_{\text{good}}$ (questions answered consistently correctly regardless of the prompt) and $\text{GSM}_{\text{bad}}$ (questions highly prone to being derailed by prompt distractions).
Key Insights and Ideas
- The "Isolated Token" Signature: Distracting tokens are characterized by high semantic isolation. Because they don't blend into the prompt's global context, their raw, un-aggregated values remain highly salient and easily corrupt the generation process.
- The Retrieval Paradox: Common practice dictates using semantic similarity to retrieve the "best" few-shot examples. However, the authors find that retrieved exemplars often exert a stronger distracting effect than randomly selected ones, likely because their overlapping terminology makes it easier for the model to take things out of context.
- Surgical vs. Blunt Intervention: Completely blocking all information flow from the prompt to the generation step (a contrastive baseline) stops the distractions but destroys the model's ability to follow the CoT format. FAI succeeds because it is surgical—intervening only on the ~15% of tokens identified as isolated.
Key Results
FAI consistently boosted performance across multiple model families (GPT-2, GPT-Neo, Llama-3, Mistral) and benchmarks:
- AQuA: Achieved a remarkable 5.91% absolute accuracy improvement when applied to Llama-3-8B.
- GSM8K: In a 6-shot setting with Llama-3-8B, FAI pushed accuracy from 71.65% to 75.21%.
- Preserving CoT Behavior: FAI successfully suppressed distractions without degrading the Rate of Answer Following Rationale (RAFR). The model still generated clean, step-by-step reasoning chains rather than jumping straight to a broken answer.
Limitations and Future Work
The primary limitation acknowledged by the authors is model scale. Due to hardware constraints, experiments were restricted to models within the 7-billion to 13-billion parameter range. Whether massive frontier models (e.g., 70B+ parameters or proprietary models) naturally suffer less from this local token distraction—or if they would benefit even more from FAI—remains an open question for future research.
Summary updated