Addition in Four Movements: Mapping Layer-wise Information Trajectories in LLM s (2025)

Abstract: Arithmetic offers a compact test of whether large language models compute or memorize. We study multi-digit addition in LLaMA-3-8B-Instruct using linear probes and the Logit Lens, and find a consistent four-stage, layer-wise ordering of probe-decodable signal types across depth: (1) early layers encode formula structure (operand/operator layout) while the gold next token is still far from top-1; (2) mid layers expose digit-wise sums and carry indicators; (3) deeper layers express result-level numerical abstractions that support near-perfect digit decoding from hidden states; and (4) near the output, representations align with final sequence generation, with the correct next token reliably ranked first. Across experiments, each signal family becomes linearly decodable with high accuracy (stage-wise peaks typically \geq 95% on in-domain multi-digit addition, and up to 99%). Taken together, these observations— in our setting —are consistent with a hierarchical, computation-first account rather than rote pattern matching, and help explain why Logit Lens inspection is most informative mainly in later layers. Code and data are available at https://github.com/YaoToolChest/addition-in-four-movements.git.

## introduction generalizable reasoning remains a core challenge for large language models (llms). arithmeticand multi-digit addition in particular-offers a controlled probe of whether models execute algorithmic procedures or merely match surface patterns @xcite . humans solve addition via a well-defined carry algorithm; an llm could either approximate this stepwise computation (e.g., column-wise summation with carry propagation) or rely on shortcuts. consistent, systematic performance across inputs is suggestive of internal computation, whereas systematic or context-specific failures point to superficial heuristics. prior work advances two contrasting views. one line of evidence reports structured, algorithm-like behavior: analyses of gpt-style models reveal components that specialize in partial summation and carry handling @xcite , and even minimal two-layer encoder-only transformers can learn the carry-addition procedure @xcite . another line argues that correct answers often arise from simple heuristics @xcite , citing a "bag of heuristics" in neuron activations @xcite and out-of-distribution errors such as commutativity violations or symbol perturbations @xcite . related analyses report fourier-like representational structure that mixes low-and high-frequency features @xcite . these disagreements leave open how mainstream llms implement addition. we focus on llama-3-8b-instruct @xcite and ask: does it perform multi-digit addition through structured, algorithmic computation (e.g., digit-wise summation with carry propagation), or through non-algorithmic pattern extraction? our starting point is a logit lens analysis @xcite . consistent with observations that the lens is most informative in later layers (cf. @xcite )), we find that next-token probabilities largely reflect compressed late-stage representations and reveal little about intermediate processing. because the logit lens is informative mainly in late layers-i.e., the gold next token tends to become rank-1 only late in the forward pass-we hypothesize a hierarchical, multi-stage computation rather than a simple accumulation of confidence on the correct token. in other words, intermediate layers appear to reorganize information before output selection, rather than merely amplifying the correct-token probability. guided by this observation, we articulatewithout presupposing discrete stage boundaries or causal transitions-a layer-wise organization of addition-related signals that become decodable in a consistent order as depth increases. we make each signal family explicit and testable: using linear probes on llama-3-8b-instruct, we observe that these four signal families emerge in the above order across layers. the ordering supports a computation-first interpretation in our setting, reconciles component specialization with reusable numerical structure, and explains why logit lens inspection is most revealing in later layers. we emphasize that our analysis is diagnostic rather than interventional: decodability does not imply necessity, and we do not claim causal stage transitions; instead, we provide operational evidence for a structured information-processing pipeline during addition. ## related work we organize prior work on llm arithmetic competence into three lenses: (i) algorithmic computation, (ii) heuristic pattern matching, and (iii) abstract numerical representation. algorithmic evidence toy models and midsized llms exhibit algorithm-like solutions: attention can implement dft-style modular addition @xcite , and helical/"clock" number encodings have been proposed for general addition @xcite . in larger models, component specialization persists -carryrouting heads and layer-wise decompositions into column summation and carry propagation are reported in 7b-scale gpt/llama variants @xcite ; causal analyses further identify operand routers and parallel digit streams @xcite . heuristic evidence an opposing view attributes success to a "bag of heuristics": neuron-level studies find sparse, template-like strategies @xcite , and controlled out-of-distribution tests reveal failures under digit permutations, novel symbols, or simple reorderings @xcite . ## methodology overview. we study how internal representations evolve when llama-3-8b-instruct performs multi-digit addition. as illustrated in fig. 2 , for each input we extract the hidden state of the last input token (the position that predicts the first answer token) at every layer and apply two complementary diagnostics: (i) logit lens to observe the model's layer-wise next-token distribution, and (ii) linear probes to test whether specific arithmetic attributes are linearly decodable. this setup allows us to map where and when structure, intermediate computations, and result digits emerge across depth. indexing convention. we adopt a 0-indexed convention with layer states @xmath0, . . . , 32} for llama-3-8b-instruct. here, @xmath1, and @xmath2, . . . , 32 denote the outputs after transformer blocks 1-32. unless otherwise noted, all results are reported using layer states l0-l32. ## experiments and results we conduct a series of experiments to diagnose how arithmetic features are represented within the llama-3-8b-instruct model. across all experiments, diagnostic probes are trained on the hidden states of all layer states l0-l32 (embedding + 32 transformer blocks), while the pretrained model parameters remain frozen. we use a common default setup for datasets, prompts, preprocessing, and splits; experiment-specific settings are described in each subsection. ## analysis the experimental results of this study systematically reveal that when the llama-3-8b-instruct large language model processes addition operations, the evolution of its internal information representation presents a clear, sequential trajectory. firstly, in the shallower layers of the network (e.g., in the formula structure recognition experiment, probes trained on two-digit numbers, when processing four-digit comparisons, show peak accuracy around layer 14), the model can efficiently identify the structural type of addition expressions (such as a+b, b+a, a+a). at this point, the probe accuracy for decoding these structural features is high, especially its good generalization to different operand lengths, indicating that the model can capture the syntactic and basic semantic composition of the input arithmetic task at early computational depths. secondly, in the middle layers of the network (roughly from layer 14 to layer 18), the decodability of core arithmetic operation features begins to become prominent. the decoding accuracy for the representation of carry signals (whether for units, tens, or hundreds digits) significantly improves in this interval, reaching a near-perfect level around layer 19, forming a clear and easily decodable representation of the key steps of the operation. almost simultaneously (starting with a sharp rise from layer 16 and stabilizing around layers 17-19), the prediction accuracy for the overall addition result (i.e., the "sum") also reaches saturation, suggesting that a stable internal representation of the result is largely formed by these layers. subsequently, in the deeper layers of the network (especially after layer 25), probe results indicate that the model appears to focus more on a detailed numerical abstraction of the operation result. experiments show that in these deeper layers, the model can accurately distinguish and represent the individual digits composing the "sum" (such as the hundreds digit, tens digit, units digit), linking the operation result with its specific numerical attributes. logit lens analysis further indicates that the generation of the final answer token primarily occurs in the final stages of the network (layers 23 to 32, peaking at layer 30). this is sequentially consistent with the maturation point of internal numerical representations (after layer 25), suggesting a potential transformation process within the model from internal numerical concepts to the final text output. furthermore, in the "arithmetic result experiment," the probe accuracy for sums across different numerical ranges (500-509 to 900-909) shows a highly consistent trend with increasing layer depth, all reaching high accuracy at similar levels (around layers @xcite @xcite . this indicates that, from the perspective of the evolution pattern of probe accuracy, these specific numerical range problems do not exhibit a significant difficulty gradient in terms of "when they become solvable" within the model's internal processing. ## discussion the sequential evolution pattern of information representation observed in this experiment provides important clues for understanding how llms perform arithmetic operations. several phenomena are worth further discussion: firstly, representations are dynamic, with their prominence peaking at specific positions in the processing trajectory, sometimes followed by a slight decrease in decodability. this 'low-highslight decrease' pattern was observed in several probe experiments. for instance, in the formula structure representation task (fig. 3 , focusing on probes trained on 2-digit addition), the accuracy for identifying '2-digit (in-domain train)' patterns peaks around layer 10 and then shows a gradual decline. similarly, the '4-digit (ood test)' curve in the same figure peaks around layer 14 before decreasing. a similar trend is observable in the carry signal experiment (fig. 5 ). for example, the 'hundreds place' carry detection accuracy sharply peaks around layer 19-20, then exhibits a noticeable decrease in subsequent layers before a slight rebound. the 'tens place' and 'ones place' also show peaks (around layer 19 and 18 respectively) followed by a dip. this pattern suggests that initially, accuracy is low as the specific arithmetic representation has not yet clearly formed. in intermediate layers, this information becomes most linearly decodable, and its representation strength and accessibility reach their peak. subsequently, as the model processes this information or integrates it for subsequent computational stages, it may shift focus. newly accumulated representational information from later layers (via residual connections) or the transformation of these features for downstream tasks might slightly interfere with or partially obscure the previously formed representations that are no longer central to the immediate next step of computation. this reflects the dynamic evolutionary nature of the model's internal representations, where specific information (as detected by our probes) is most clearly and accessibly represented at particular depths, rather than being monotonically refined. secondly,generalizability of representation. generalization experiments on the three-digit number recognition task show that a probe trained on addition generalizes very well to subtraction (peaking near 90% accuracy) and strongly to multiplication (peaking near 80%), and that its generalization to subtraction is even stronger than to multiplication. the relatively superior generalization to subtraction (i.e., marginally better performance at similarly high levels) may indicate that in this model's representation learning, subtraction and addition share more direct or more readily transferable numerical representation elements. although multiplication (conceptually a form of repeated addition, and likewise exhibiting good generalization here) also achieves a high degree of transfer, it falls slightly short of subtraction. this suggests that, despite substantial commonality, the computational mechanism the model learns for multiplication-or the representations it forms-retain some distinctive aspects that render its transfer a bit less effective than subtraction. overall, this shows that the model's learned numerical representations combine a certain level of abstraction and cross-operation universality with features that are specific to each arithmetic operation. thirdly, the analogical nature of the model's "computation" process. the sequential emergence and progressive refinement of features revealed in this study bear resemblance to the cognitive processes humans use to solve arithmetic problems, which involve breaking down steps and calculating progressively. from identifying the structure of the expression, to processing carries, calculating the sum, and finally confirming and expressing each digit, the model internally appears to be executing a structured, computation-like process, rather than simple pattern matching or memory retrieval. ## conclusion through a series of carefully designed probe experiments on the llama-3-8b-instruct model, and with comparative analyses on other representative models (detailed in appendix d), this study systematically investigated their internal information processing mechanisms when performing addition operations. the main conclusions regarding llama-3-8b-instruct are as follows: