AI
New Method Makes AI Code Generators More Transparent by Anchoring Explanations in Program Syntax
Researchers introduce ASTrust, a technique that grounds large language models' code-generation choices in recognizable programming language structures to boost both interpretability and user trust.
A team of researchers has proposed ASTrust, a fresh approach to understanding how large language models make decisions when generating code. Rather than focusing solely on overall accuracy or broad performance metrics, the method digs into the moment-by-moment reasoning behind model outputs in ways developers can readily grasp.
The Problem with Current Approaches#
Existing techniques for interpreting code-generating AI systems tend to stop at measuring how well models perform or testing how they respond when inputs change slightly. What they largely miss is the granular, real-time explanation that helps users understand why a specific piece of code was generated at all. This gap between performance metrics and genuine interpretability undermines trust in these tools, even when they work correctly.
How ASTrust Works#
The method ties model confidence—a measure of how certain the AI is about its predictions—directly to the syntactic structures that programmers already know. It does this by working with Abstract Syntax Trees (ASTs), which represent code as hierarchical structures of language elements. Instead of simply flagging confidence at the token or word level, ASTrust distributes confidence scores across recognized syntactic categories. This shift means developers encounter explanations framed in programming language concepts rather than abstract model internals.
To make the approach practical, the researchers built automated visualizations that overlay these confidence scores onto sequence diagrams, heat maps, and graph-based representations of ASTs. This lets users analyze both individual code snippets and broad patterns across larger code repositories.
Testing and Validation#
The team evaluated ASTrust on twelve widely-used language models using a curated collection of code from popular GitHub repositories. They also conducted a human study to verify that developers actually find the explanations useful in practice. The work was submitted to arXiv in July 2024 and revised in September 2024.
This approach bridges a critical gap: making AI-assisted code generation not just accurate, but transparent and grounded in familiar programming concepts.

