mlsanityData to 26 Nov 2026

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

arXiv 2610.24118 ↗Submitted 16 Oct 2026cs.CL cs.LGcited by 0

On the map: Mechanistic interpretability → Knowledge and representations inside LLMs also fits: SAE features and their applications

Abstract (arXiv)

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.

Key facts. No citing papers in the map yet (data through 26 Nov 2026). Placed in Knowledge and representations inside LLMs, one of 13 directions in Mechanistic interpretability. Builds on 48 of its 63 references that are in the map. Submitted 16 Oct 2026.

Builds on

48 of 63 references.

Closest ancestors · 1

Same direction, newest first

  1. 2025Mechanistic Interpretability of Code Correctness in LLMs via Sparse Autoencoders3 Oct

Other references · 47

  1. 2021Program Synthesis with Large Language Modelscited by 3,972
  2. 2023Sparse Autoencoders Find Highly Interpretable Features in Language Modelscited by 1,607
  3. 2024Refusal in Language Models Is Mediated by a Single Directioncited by 1,174
  4. 2023Towards Automated Circuit Discovery for Mechanistic Interpretabilitycited by 787
  5. 2024A Survey on Large Language Models for Code Generationcited by 695
  6. 2024Scaling and evaluating sparse autoencoderscited by 661
  7. 2024Gemma Scope: Open Sparse Autoencoders Everywhere All At Once on Gemma 2cited by 450
  8. 2026Scaling Monosemanticity: Extracting Interpretable Features from Claude 3 Sonnetcited by 248
  9. 2024Llama Scope: Extracting Millions of Features from Llama-3.1-8B with Sparse Autoencoderscited by 160
  10. 2024Do I Know This Entity? Knowledge Awareness and Hallucinations in Language Modelscited by 129
  11. 2025A Survey on Code Generation with LLM-based Agentscited by 115
  12. 2022ReCode: Robustness Evaluation of Code Generation Modelscited by 114
35 more
  1. 2022Natural Attack for Pre-trained Models of Codecited by 78
  2. 2022What Do They Capture? -- A Structural Analysis of Pre-Trained Language Models for Source Codecited by 53
  3. 2021What do pre-trained code models know about code?cited by 37
  4. 2023Emergent Representations of Program Semantics in Language Models Trained on Programscited by 34
  5. 2026Qwen-Scope: Turning Sparse Features into Development Tools for Large Language Modelscited by 30
  6. 2022Probing Pretrained Models of Source Codecited by 27
  7. 2022AST-Probe: Recovering abstract syntax trees from hidden representations of pre-trained language modelscited by 18
  8. 2024Do Large Code Models Understand Programming Concepts? Counterfactual Analysis for Code Predicatescited by 17
  9. 2022An Exploratory Study on Code Attention in BERTcited by 14
  10. 2022Two Sides of the Same Coin: Exploiting the Impact of Identifiers in Neural Code Comprehensioncited by 11
  11. 2022Unveiling Code Pre-Trained Models: Investigating Syntax and Semantics Capacitiescited by 10
  12. 2025Are Large Language Models Robust in Understanding Code Against Semantics-Preserving Mutations?cited by 10
  13. 2022Explainable AI for Pre-Trained Code Models: What Do They Learn? When They Do Not Work?cited by 9
  14. 2024Understanding How CodeLLMs (Mis)Predict Types with Activation Steeringcited by 7
  15. 2025How Programming Concepts and Neurons Are Shared in Code Language Modelscited by 7
  16. 2025Neuron-Guided Interpretation of Code LLMs: Where, Why, and How?cited by 7
  17. 2022Follow-up Attention: An Empirical Study of Developer and Neural Model Code Explorationcited by 6
  18. 2023How Does Naming Affect LLMs on Code Analysis Tasks?cited by 6
  19. 2024A Critical Study of What Code-LLMs (Do Not) Learncited by 6
  20. 2024Looking into Black Box Code Language Modelscited by 6
  21. 2023Towards Understanding What Code Language Models Learnedcited by 5
  22. 2025Generating Planning Feedback for Open-Ended Programming Exercises with LLMscited by 5
  23. 2025Failure by Interference: Language Models Make Balanced Parentheses Errors When Faulty Mechanisms Overshadow Sound Onescited by 5
  24. 2026CodeCircuit: Toward Inferring LLM-Generated Code Correctness via Attribution Graphscited by 5
  25. 2026DeepGuard: Secure Code Generation via Multi-Layer Semantic Aggregationcited by 4
  26. 2023Redundancy and Concept Analysis for Code-trained Language Modelscited by 3
  27. 2023INSPECT: Intrinsic and Systematic Probing Evaluation for Code Transformerscited by 3
  28. 2025Analyzing Latent Concepts in Code Language Modelscited by 3
  29. 2026Do Code Language Models Follow Tests? Paired Interventions on Program Behaviorcited by 3
  30. 2022Unveiling Project-Specific Bias in Neural Code Modelscited by 2
  31. 2026A Mechanistic Lens on Semantic Conflicts: Using Activation Patching to Understand LLM Behaviorcited by 2
  32. 2026Are Arithmetic Heuristic Neurons Form-Invariant? A Mechanistic Analysis of Symbols, Text, and Code in LLMscited by 2
  33. 2013On the Concept of Variable Roles and its Use in Software Analysiscited by 1
  34. 2023A Study of Variable-Role-based Feature Enrichment in Neural Models of Codecited by 1
  35. 2026From Brewing to Resolution: Tracing the Internal Lifecycle of Code Reasoning in LLMscited by 1

Built on by

Not cited yet.

Similar, not cited

Close in wording, no citation either way

  1. 2025The Illusion of Role Separation: Hidden Shortcuts in LLM Role Learning (and How to Fix Them)
  2. 2026Emergent Semantic Role Understanding in Language Models
  3. 2026The Granularity Axis: A Micro-to-Macro Latent Direction for Social Roles in Language Models
  4. 2026Finding the Translation Switch: Discovering and Exploiting the Task-Initiation Features in LLMs
  5. 2026One Language, Two Scripts: Probing Script-Invariance in LLM Concept Representations
  6. 2026SAE Interprets MoE: Sparse AutoEncoders Reveal That MoE Experts Exhibit Human-Interpretable Fine-Grained Specialization
  7. 2025Improving LLM Reasoning through Interpretable Role-Playing Steering
  8. 2026On the Limits of LLM Adaptability: Impact of Model-Internalized Priors on Annotation Task Performance