Function Induction and Task Generalization: An Interpretability Study with Off-by-One Addition

Qinyuan Ye, Robin Jia, Xiang Ren

TL;DR

Researchers have identified a specific internal mechanism in Large Language Models (LLMs) called "Function Induction." While traditional "induction heads" help models copy-paste text from context, this newly discovered circuit allows models to induce abstract mathematical rules—like "add one to the result"—and apply them to novel tasks. This mechanism is modular and reusable, appearing across diverse tasks from counterfactual arithmetic to Caesar ciphers.

What Problem Does This Paper Address?

We know LLMs are incredible at In-Context Learning (ICL)—give them a few examples of a new task, and they "get it." However, the internal "circuitry" that enables this task-level generalization remains a black box.

Most prior interpretability work focused on simple pattern matching (e.g., if the model sees [A][B]...[A], it predicts [B]). This paper tackles a more complex challenge: counterfactual reasoning. Specifically, how does a model handle a task like "off-by-one addition" (e.g., 1+1=3, 2+2=5, 3+3=?)?

Example of standard vs. off-by-one addition tasks

To solve this, the model can't just rely on its pre-trained arithmetic; it must recognize a two-step process: perform standard addition, then apply an unexpected "+1" transformation. The authors aim to map the specific neurons and attention heads responsible for this "rule-bending" behavior.

Methods

The authors employ several "mechanistic interpretability" techniques to reverse-engineer the models (primarily focusing on Gemma-2 9B, but validating across others):

  • Path Patching: A surgical technique where activations from a "base" run (standard addition) are swapped into a "contrast" run (off-by-one addition) to see which specific computational paths are responsible for the +1 behavior.
  • Head Ablation: "Turning off" specific attention heads to observe the impact on accuracy.
  • Logit Lens: Inspecting the model’s internal representations at intermediate layers to see when the "correct" answer (e.g., 6) is discarded in favor of the "counterfactual" answer (e.g., 7).
  • Causal Effect Heatmaps: Visualizing how specific heads promote or suppress certain numerical outputs across a 10x10 grid of inputs.

Datasets

The study uses several synthetic and existing benchmarks:

  • Off-by-one Addition: A custom dataset of addition problems where the answer is consistently incremented by 1.
  • Shifted MMLU: A modified version of the Massive Multitask Language Understanding benchmark where the correct multiple-choice letter is shifted (e.g., if the answer is A, the prompt shows B).
  • Caesar Cipher: A classic ROT-k letter substitution task.
  • Base-8 Addition: An algorithmic task used to test if the model uses the same "shifting" logic to handle non-decimal arithmetic.

Key Insights and Ideas

  • From Token Induction to Function Induction: The authors found a circuit that mirrors the structure of "induction heads" but operates at a higher level of abstraction. Instead of copying a specific token, these Function Induction (FI) heads "copy" a transformation rule from the examples provided in the prompt.
  • A Collaborative "Team" of Heads: The +1 function isn't handled by a single "smart" head. Instead, multiple heads work in parallel. One head might suppress the standard sum, while another promotes the incremented value. They collaborate to shift the probability mass toward the counterfactual answer.
  • Late-Stage Reasoning: Logit lens analysis showed that models typically compute the "correct" standard addition result in early layers and only apply the "off-by-one" twist in the final third of the network.
  • Modular Reusability: The most striking finding is that the exact same heads used for off-by-one addition are also used to solve Caesar ciphers and shifted multiple-choice questions. This suggests LLMs develop "general-purpose shifting" modules.

Key Results

  • High Performance: Modern models like Llama-3 (8B) and Phi-4 (14B) achieve near 100% accuracy on off-by-one addition with just 8 in-context examples.
Contrast accuracy vs. number of ICL examples across models
  • Causal Necessity: When the authors ablated (disabled) just six identified FI heads in Gemma-2, the model’s accuracy on the off-by-one task plummeted from 86% to 0%, while its ability to do standard addition remained at 100%.
  • Shortcut Discovery: In the base-8 addition task, the researchers found that models don't necessarily "learn" base-8 logic. Instead, they often use a shortcut—performing base-10 addition and then using the FI heads to "adjust" the result based on the patterns in the prompt.

Limitations and Future Work

  • Incomplete Circuit: The identified circuit explains about 78% of the behavior. The remaining 22% likely involves MLP (Multi-Layer Perceptron) layers, which this study did not analyze in depth.
  • Scope of Functions: The study focused heavily on "shifting" functions (x + k). It remains unclear if the model uses similar induction circuits for more complex non-linear functions (e.g., x^2 or logical XOR).
  • Training Origins: The authors briefly experimented with toy models but found it difficult to replicate the emergence of these circuits from scratch, suggesting that the scale of pre-training data is a critical factor in developing these sophisticated induction mechanisms.

Overall, this work provides a rare "look under the hood" at how LLMs don't just memorize, but actively compose and reuse abstract algorithmic structures to solve novel problems.

Summary updated

BibTeX
@inproceedings{ye2026function,
  author = {Qinyuan Ye and Robin Jia and Xiang Ren},
  title = {{Function Induction and Task Generalization: An Interpretability Study with Off-by-One Addition}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=TISRmGHpjQ},
}
Figure