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

Unravelling the Mechanisms of Manipulating Numbers in Language Models

Michal Štefánik, Timothee Mickus, Marek Kadlčík, Bertram Højer, Michal Spiegel, Raúl Vázquez, Aman Sinha, Josef Kuchař, Philipp Mondorf · Submission to ICLR 2026 · Withdrawn

TL;DR

Despite frequently stumbling on simple arithmetic at generation time, large language models (LLMs) internally construct strikingly precise, universal, sinusoidal representations of numbers. By training specialized sinusoidal probes, the authors show that LLMs often compute the correct mathematical answer internally—only for specific downstream layers to corrupt it before it surfaces as text.

What Problem Does This Paper Address?

LLMs are notoriously unreliable at arithmetic, frequently hallucinating wrong answers. Paradoxically, recent mechanistic interpretability work found that models learn highly organized, accurate input embeddings for numerical tokens.

Why does a model with high-fidelity internal number representations still produce erroneous math outputs? Does the representation degrade during computation, or does the reasoning mechanism itself break down? This paper investigates how numerical features evolve across transformer layers, how multi-token numbers are stored, and precisely where arithmetic errors originate.

Methods

  • Sinusoidal Probing: Building on Kadlčík et al. (2025), the authors use probes explicitly biased with sinusoidal basis functions: $$f_{\text{sin}}(\mathbf{x}) = (\mathbf{W}_{\text{out}} \mathbf{S})^T (\mathbf{W}_{\text{in}} \mathbf{x})$$ where $\mathbf{S}$ contains fixed sine and cosine frequencies across hidden dimensions. This probe decodes numerical values far more accurately than linear, logarithmic, or binary baselines.

  • Fourier Decomposition & RSA: The authors perform Representational Similarity Analysis (RSA) and Fourier analysis on PCA-reduced token embeddings across multiple model families to compare numerical frequency profiles against non-numeric control tokens.

  • Cross-Layer & Component Attribution: Probes are evaluated across held-out layers and decomposed transformer subcomponents (Q, K, V, attention projections, MLPs, residual stream) to track where numerical representations survive or break.
  • Activation Steering & Layer Ablation: Suspect layers responsible for corrupting calculations are ablated. In addition, the authors steer hidden states $\mathbf{h}_i$ toward probe-optimized sinusoidal target embeddings $\mathbf{e}_y$ via linear interpolation: $\alpha \mathbf{h}_i + (1 - \alpha)\mathbf{e}_y$.

Datasets

  • Synthetic Arithmetic: Simple operator prompts (e.g., $x_1 + x_2$, subtraction, multiplication, division).
  • Multi-Domain Natural Language Corpus: Curated to test number representation in realistic text across four domains:
  • Culinary: Recipe NLG Lite, FoodRecipe-ImageCaptioning
  • Temporal: TimeLineExtraction (legal document dates)
  • Arithmetic Word Problems: MetaMathQA, DROP, AQuA-RAT
  • Medical: ICD-10 diagnostic codes and classifications (Original numbers were replaced with uniformly sampled integers from vocabulary to eliminate natural frequency bias).
  • Recent News: A subset of post-cutoff BBC news articles (RealTimeData/bbc_news_alltime) to evaluate multi-token number superposition ($10^3 - 10^{18}$).

Key Insights and Ideas

  • Universal Frequential Fingerprint: Across disparate architectures (Llama 3, OLMo 2, Phi 4), models independently converge on the exact same top $k=63$ Fourier frequencies for numbers (100% Intersection-over-Union agreement). This does not occur for general language tokens.
  • The Residual Stream is the Number Highway: Inside a transformer block, attention projection temporarily degrades the sinusoidal structure, which is partially reconstructed by the MLP. Crucially, the residual stream bypasses this disruption, keeping number representations stable across depth.
  • Models "Know" the Answer Before Breaking It: Errors in arithmetic are not simply failures to compute; they are often failures to preserve. For erroneous outputs in division, 94.4% of instances contained the correct answer in intermediate activations before a later layer disrupted it.
  • Localized Superposition: Multi-token numbers are superposed directly into the representation of the final numeric token, with high accuracy for immediate predecessors (offset $-1$), but this mechanism degrades significantly beyond 3 tokens ($\ge 10^9$).

Key Results

  • Cross-Layer Interchangeability: Probes trained on all-but-one layer achieve 95% to 100% accuracy on held-out intermediate layers, confirming that intermediate layers share a nearly identical coordinate system for numbers.
  • Error Latency: Probes reveal that models internally held the correct answer in 56.8% of failed subtraction cases, 26.3% of failed multiplication cases, and 94.4% of failed division cases.
  • Error Mitigation via Targeted Intervention:
  • Layer Ablation: Removing individual layers that consistently corrupted values (e.g., layer 4 in Llama-3.2 3B) yielded up to a 26% error reduction in multiplication and 27%–64% in division.
  • Sinusoidal Steering: Interpolating activations toward probe-optimized embeddings on incorrect instances reduced errors by up to 19.23% in division and 17.03% in multiplication.

Limitations and Future Work

  • Low Absolute Baseline on Hard Operations: While removing corruption layers improved division accuracy relatively, the absolute accuracy of smaller models on division was very low to begin with (5.9%), limiting practical standalone deployment of naive layer pruning.
  • Superposition Horizon: The models fail to superpose numbers spanning more than three tokens reliably, explaining why LLMs struggle with large integer arithmetic without chain-of-thought prompting.
  • Scope of Tasks: The study predominantly explores direct token generation on single operations; extending these geometric probes to multi-step reasoning traces and scratchpads remains an open avenue.

Summary updated

BibTeX
@inproceedings{stefanik2026unravelling,
  author = {Michal Štefánik and Timothee Mickus and Marek Kadlčík and Bertram Højer and Michal Spiegel and Raúl Vázquez and Aman Sinha and Josef Kuchař and Philipp Mondorf},
  title = {{Unravelling the Mechanisms of Manipulating Numbers in Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.acl-long.1415},
}
Figure