TL;DR
Large Language Models (LLMs) often rely on memorized pretraining patterns rather than genuine reasoning, leading to catastrophic cascading errors in Chain-of-Thought (CoT) generation. This paper introduces STIM, a novel diagnostic framework that identifies memorization at the individual token level across local, mid-range, and long-range sources. The authors reveal that surface-level local memorization is the dominant driver of reasoning failures, accounting for up to 67% of incorrect tokens, especially when models are pushed out of their comfort zone into "long-tail" distributions.
What Problem Does This Paper Address?
While LLMs perform remarkably well on standard reasoning benchmarks, they are notoriously fragile under slight input modifications. This raises a fundamental question: are these models truly reasoning, or are they just cleverly reciting their training data?
This issue is particularly acute in Chain-of-Thought (CoT) prompting. Because CoT relies on sequential step-by-step generation, a single mispredicted token early in the chain can cause errors to cascade downstream, completely derailing the final answer.
Existing memorization metrics fall short because they operate at the sequence or final-answer level, failing to pinpoint the exact token that caused the breakdown. Furthermore, prior metrics look at memorization in isolation, ignoring that a token's generation is simultaneously influenced by multiple sources: the immediate local context, the model's own prior outputs, and the original input prompt.
Methods
The authors introduce STIM (Source-aware Token-level Identification of Memorization), a framework designed to disentangle and quantify token-level memorization from three distinct contextual sources:
- Local Context ($STIM_{loc}$): Measures the influence of immediately preceding tokens (short-range n-grams).
- Mid-Range ($STIM_{mid}$): Measures the influence of salient tokens within the model's partially generated prefix.
- Long-Range ($STIM_{long}$): Measures the influence of salient tokens from the input prompt.
STIM works by extracting the top-20 candidate tokens at a given decoding step and computing the Spearman correlation between the model's predicted probabilities and the actual token co-occurrence frequencies in the pretraining corpus. To query these massive pretraining frequencies efficiently, the authors leverage Infinigram over the model's open pretraining dataset. The maximum score among the three sources ($STIM_{max}$) determines the dominant driver of memorization for that token.
To evaluate reasoning failures specifically, the authors use a Process Reward Model (PRM) to locate the first erroneous step in a failed CoT chain, focusing their token-level analysis precisely where the reasoning first breaks down.
Datasets
The framework was evaluated using the open-source OLMo 2 models (7B and 13B variants) pretrained on the Dolma 1.7 corpus. The authors tested four core reasoning tasks:
- Applied Math (GSM8K)
- Formula Calculation
- Counting
- Capitalization
To rigorously test the boundaries of memorization versus reasoning, they created "Long-tail" variants of these datasets by applying transformations that reduce input entity frequency or alter standard formats. For example, they expanded digits, converted integers to floats, shifted math problems into base-2 (binary), substituted common fruits with rare ones (e.g., keule, ugli), and introduced atypical capitalization rules.
Key Insights and Ideas
- Complexity Breeds Memorization: Models rely much more heavily on memorization in complex multi-step tasks (like Applied Math) than in simpler, locally structured tasks (like Counting).
- The Long-Tail Fallback: Counterintuitively, memorization scores increase when models encounter unfamiliar, long-tail inputs. When faced with out-of-distribution prompts, the model panics and inappropriately falls back on superficial patterns memorized during pretraining.
- The Reversal of Memory's Role: In standard base distributions, high memorization scores correlate with correct answers, meaning the model successfully leverages familiar templates to solve problems. However, under distribution shift, this relationship flips: high memorization scores correlate with incorrect steps, as the model forces ill-fitting pretraining templates onto novel scenarios.
- The Tyranny of Local Context: Local context memorization—essentially falling for high-frequency short n-grams—is the single largest driver of errors, demonstrating that models easily lose sight of global logic in favor of cheap local text continuations.
Key Results
- Dominant Error Sources: Local memorization was the primary culprit behind incorrect tokens, accounting for 67.3% of errors in base Applied Math and 64.7% in base Capitalization.
- Heuristic Abandonment: Under distribution shift in complex tasks, local memorization errors dropped significantly (from 67.3% to 47.4% in Applied Math), showing that the model is forced to abandon brittle local heuristics when confronted with highly unfamiliar inputs.
- Error Pinpointing: STIM proved highly effective at predicting exactly which tokens caused a step to fail. Across all tasks, STIM significantly outperformed random baselines. In Applied Math, $STIM_{max}$ achieved a Precision@1 of 45.5% and a Recall@3 of 67.0% (compared to random baselines of 15.8% and 35.2%).
Limitations and Future Work
- Saliency Method Dependencies: STIM relies on LERG, a perturbation-based token saliency method chosen for its computational efficiency. However, LERG can miss finer-grained influence patterns that more intensive gradient-based or causal tracing methods might capture.
- PRM Imperfections: The accuracy of the pipeline depends on the PRM's ability to correctly identify the first failing step. If the PRM mislabels a step, the downstream token analysis becomes noisy.
- The Open-Data Bottleneck: STIM requires fully open, indexed pretraining data to calculate token frequencies via Infinigram. This restricts its current applicability to open models like OLMo and Pythia, leaving closed commercial models (where memorization behavior is arguably most critical to audit) out of reach for now.
Summary updated