Do LMs Know What Variables Do? Interpreting Code Representations via Variable Roles

Célian Vasson, Daniil Ognev, Kentaro Inui, Benjamin Heinzerling
10/16/2026
cs.CLcs.LG

No confident code implementation found for this paper.

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{vasson2026know,
  title  = {Do LMs Know What Variables Do? Interpreting Code Representations via Variable Roles},
  author = {Célian Vasson and Daniil Ognev and Kentaro Inui and Benjamin Heinzerling},
  year   = {2026},
  eprint = {2610.24118},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2610.24118v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2610.24118.svg)](https://codeofpaper.com/paper/2610.24118)

Discussion