English

Interpreting the Latent Structure of Operator Precedence in Language Models

Computation and Language 2025-11-04 v2

Abstract

Large Language Models (LLMs) have demonstrated impressive reasoning capabilities but continue to struggle with arithmetic tasks. Prior works largely focus on outputs or prompting strategies, leaving the open question of the internal structure through which models do arithmetic computation. In this work, we investigate whether LLMs encode operator precedence in their internal representations via the open-source instruction-tuned LLaMA 3.2-3B model. We constructed a dataset of arithmetic expressions with three operands and two operators, varying the order and placement of parentheses. Using this dataset, we trace whether intermediate results appear in the residual stream of the instruction-tuned LLaMA 3.2-3B model. We apply interpretability techniques such as logit lens, linear classification probes, and UMAP geometric visualization. Our results show that intermediate computations are present in the residual stream, particularly after MLP blocks. We also find that the model linearly encodes precedence in each operator's embeddings post attention layer. We introduce partial embedding swap, a technique that modifies operator precedence by exchanging high-impact embedding dimensions between operators.

Keywords

Cite

@article{arxiv.2510.13908,
  title  = {Interpreting the Latent Structure of Operator Precedence in Language Models},
  author = {Dharunish Yugeswardeenoo and Harshil Nukala and Ved Shah and Cole Blondin and Sean O Brien and Vasu Sharma and Kevin Zhu},
  journal= {arXiv preprint arXiv:2510.13908},
  year   = {2025}
}

Comments

11 pages, 6 figures. An earlier version of this work was accepted to CoLM 2024. This is an extended version of our CoLM 2024 paper. Includes additional ablations; added Ved Shah as author for those contributions

R2 v1 2026-07-01T06:39:40.311Z