From Observation to Explanation: Mechanistic Interpretability of LLM-Generated Code for Principled Repair
Musfiqur Rahman
Key points
From the paper's conclusion- Together, these findings raise a question that empirical studies cannot answer: why do LLMs generate code with these properties?
Abstract
Large language models (LLMs) have transformed software development, yet our understanding of how they generate code remains critically underdeveloped. We address this gap by triangulating evidence across three layers. Longitudinally, autonomous agent-attributed code is statistically indistinguishable from human code under a semantic modification definition (HR = 1.019, p = 0.490), yet attracts disproportionately corrective modifications in production (49.1% vs 37.9% human baseline). This finding demands a causal explanation. Empirically, existing benchmarks overestimate LLM capabilities: models that achieve 84 to 89% correctness on synthetic tasks attain only 24 to 35% on real-world class-level code. Behaviourally, detection systems reveal puzzling asymmetries: GPT-3.5 is far more detectable than modern models (AUC-ROC = 0.96, a 27-point gap), even though modern models produce mutually similar code structures; yet no single feature reliably distinguishes AI-generated from human code at the class level, and the leading commercial detector achieves only 15 to 64% recall. Together, these findings raise a question that empirical studies cannot answer: why do LLMs generate code with these properties? This thesis proposes mechanistic interpretability, a causal token-level circuit tracing, as the bridge between empirical observation and principled correction. By identifying the transformer circuits responsible for detectable stylistic signatures, hallucination patterns, and systematic defects, we aim to drive an agentic repair framework that intervenes at the causal source of defects rather than patching surface symptoms.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- A Survey of LLM-based Software Repair: Taxonomies, Design Paradigms, and ApplicationsACM Transactions on Software Engineering and Methodology · 2026
- Better Understanding, Better Fixes? A Study of Hallucination in LLM-based Automated Program RepairarXiv · 2026
- Reducing Hallucinations in LLM-Generated Code via Semantic TriangulationProceedings of the ACM on Programming Languages · 2026
- Reasoning-Trace Overflow in Code Generation: An Empirical Study of Explicit Reasoning ModelsarXiv · 2026
- Code generation with large language models: a survey from neural program synthesis to autonomous software developmentApplied Intelligence · 2026
- To Run or Not to Run: Analyzing the Cost-Effectiveness of Code Execution in LLM-Based Program RepairProceedings of the ACM on software engineering. · 2026