Do LMs Know What Variables Do? Interpreting Code Representations via Variable Roles
C\'elian Vasson, Daniil Ognev, Kentaro Inui, Benjamin Heinzerling
Key points
From the paper's conclusion- We introduce static annotation rules for all eleven roles and a corpus of 126,926 natural-code files across five languages.
Abstract
Variable roles describe recurring behaviors such as accumulation, traversal, and retaining the best candidate encountered. We use Sajaniemi's independently defined taxonomy to study which role distinctions can be recovered from large language models, how sparse autoencoders (SAEs) retain those distinctions, and whether associated directions support control of generation. We introduce static annotation rules for all eleven roles and a corpus of 126,926 natural-code files across five languages. Across five model-SAE systems, residual probes outperform individual SAE features and tested lexical baselines, with modest losses after neutral target renaming. Combining SAE features closes much of the single-feature gap, but probes on SAE reconstructions are less sensitive to role-changing edits reviewed by LLMs. High paired ranking accuracy coexists with frequent false positives at fixed thresholds. During generation, interventions often change role annotations at the cost of correctness; changes accompanied by passing tests show no clear aggregate advantage over random controls. The benchmark separates role-related recoverability, SAE fidelity, and correctness-preserving control through matched prediction, source edits, and generation interventions.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Encoded but Not Decoded: Layer-Localized Evidence for a Three-Level Gap in LLM SyntaxarXiv · 2026
- Encoding and Propagation of Grammatical Number in Large Language ModelsarXiv · 2026
- Causal Syntax Circuits in CodeLMs: Budget and Probe Decide What Looks LocalisedarXiv · 2026
- Interpreting Coding Agents Through Their Behavioral TrajectoriesarXiv · 2026
- Sparse Autoencoders for Mechanistic Interpretability in NLP: A Critical Survey of Recoverability, Interpretability, and UtilityarXiv · 2026
- Reasoning Patterns for Efficient AI Coding: An Empirical StudyarXiv · 2026