NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Analyzing Chain-of-Thought Prompting in Large Language Models via Gradient-based Feature Attributions

Skyler Wu, Eric Meng Shen, Charumathi Badrinath, Jiaqi Ma, Himabindu Lakkaraju

TL;DR

Chain-of-Thought (CoT) prompting is widely known to improve LLM reasoning, but we still lack a mechanistic understanding of why it helps. By analyzing gradient-based feature attributions in open-source language models (1.5B–6B parameters), this paper demonstrates that CoT does not amplify attention on key input tokens; instead, it stabilizes the model’s internal representations, making token attributions remarkably robust to prompt rewordings and generation randomness.

What Problem Does This Paper Address?

While few-shot Chain-of-Thought (CoT) prompting consistently improves reasoning accuracy in models with over 100 billion parameters, the internal mechanisms driving this behavior remain poorly understood. Recent empirical work has shown that models prompted with CoT can achieve performance gains even when intermediate reasoning steps contain factual errors, suggesting that generated explanations do not faithfully reflect internal computation.

Rather than taking generated text at face value, this paper examines what happens "under the hood." The authors use gradient-based feature attributions (saliency scores) to determine whether CoT prompting fundamentally alters how language models attend to semantically critical input tokens.

Methods

The authors evaluate token-level importance by computing gradients of the final answer token's logit with respect to each input token. They evaluate four saliency formulations adapted from Yin & Neubig (2022):

  1. Regular Gradient × Input ($S_{GI}$)
  2. Regular $L_1$ Norm ($S_{GN}$)
  3. Contrastive Gradient × Input ($S^*_{GI}$)
  4. Contrastive $L_1$ Norm ($S^*_{GN}$), which computes gradients against an alternative "foil" token (e.g., the opposite binary label or ground-truth answer when incorrect).

Using these attribution scores, they probe three open-source autoregressive models—GPT-J (6B), GPT-Neo (2.7B), and GPT-2 XL (1.5B)—across three experimental settings:

  • Token Saliency Magnitudes: Comparing the absolute saliency assigned to manually annotated "relevant" tokens under standard vs. CoT few-shot prompting.
  • Perturbation Robustness: Measuring shifts in saliency distributions when questions are syntactically reworded without changing semantic meaning.
  • Stochastic Stability: Measuring the variance of token saliency across 20 randomized decoding runs (sampling with $\text{top-}k=10$, $\text{temperature}=1.0$).

Datasets

The authors sample 50 questions each from four reasoning benchmarks:

  • SST-2: Binary sentiment classification on movie reviews (filtered to excerpts $\ge 10$ tokens).
  • CoinFlip: Symbolic state-tracking tasks determining if a coin is heads- or tails-up after flips.
  • GSM8K: Multi-step grade school math word problems (filtered to $\le 200$ characters).
  • CSQA (CommonsenseQA): 5-choice commonsense multiple-choice questions.

To test prompt robustness, the authors also author syntactically reworded versions of the 50 GSM8K and CoinFlip questions, preserving vocabulary and underlying logic while altering sentence structure.

Key Insights and Ideas

  • CoT dilutes, rather than concentrates, raw token attribution: Counter to the intuition that CoT causes a model to "focus harder" on core problem variables, CoT prompting uniformly decreases the average saliency magnitude of relevant prompt tokens. Because the gradient is distributed over a longer sequence (the exemplar explanations and generated chain), token scores become less right-skewed.
  • CoT acts as a stabilizer against syntactic phrasing: Under standard prompting, minor rephrasing drastically reshuffles the saliency assigned to core entities. Under CoT prompting, mean saliencies for relevant tokens remain virtually flat between original and reworded questions.
  • Attribution remains steady despite decoding stochasticity: During temperature sampling, CoT generates a wide diversity of intermediate reasoning chains and outputs (e.g., 18 unique answers out of 20 runs on GSM8K). Yet, the underlying input token saliency scores cluster tightly, exhibiting lower variance than standard prompting.

Key Results

  • Downstream Accuracy: Corroborating earlier literature, models at this scale ($\le 6\text{B}$) do not see reasoning gains from CoT. On GPT-J, accuracy remained essentially flat on GSM8K (0.02 standard vs. 0.04 CoT) and CSQA (0.32 vs. 0.38). However, sentiment classification showed marked improvements across all sizes (e.g., GPT-J jumped from 50% to 64%; GPT-2 XL jumped from 52% to 76%).
  • Attribution Robustness (GSM8K): While standard few-shot prompting causes substantial swings in token importance between original and reworded questions (spanning mean saliency ranges up to $\sim 0.08$), CoT confines mean saliency shifts to a narrow band ($\le 0.015$).
  • Variance Reduction: Across all four datasets and attribution metrics, CoT consistently yields tighter attribution clusters across repeated stochastic runs, demonstrating that the generation of reasoning steps primes the network into a more invariant feature-processing regime.

Limitations and Future Work

  • Model Scale: The study evaluates models up to 6B parameters due to the computational cost of computing gradients across long sequences. Because emergent CoT accuracy leaps primarily appear around 100B+ parameters, confirming whether these stability gains translate directly to 100B+ models remains an open question.
  • Scale of Evaluation: Experiments were restricted to 50 questions per dataset and 5 questions for repeated stochastic trials.
  • Human Annotation Subjectivity: Relevant tokens were manually labeled by the authors. Future work could leverage automated parsing pipelines (e.g., spaCy) or crowdsourced annotations to scale evaluations.
  • Metric Disagreement: As observed in broader feature-attribution literature, different saliency formulations can yield divergent scores, motivating evaluation under complementary mechanistic interpretability lenses (e.g., circuit analysis or attention rollouts).

Summary updated

BibTeX
@inproceedings{wu2023analyzing,
  author = {Skyler Wu and Eric Meng Shen and Charumathi Badrinath and Jiaqi Ma and Himabindu Lakkaraju},
  title = {{Analyzing Chain-of-Thought Prompting in Large Language Models via Gradient-based Feature Attributions}},
  booktitle = {DeployableGenerativeAI @ ICML},
  year = {2023},
  url = {https://openreview.net/forum?id=xnXln7c0no},
}
Figure