arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2602.07080cs.SEcs.AI
收藏

CodeCircuit: 通过归因图推断LLM生成代码的正确性

CodeCircuit: Toward Inferring LLM-Generated Code Correctness via Attribution Graphs

University of Illinois Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校);University of Edinburgh(爱丁堡大学);Nanyang Technological University(南洋理工大学);National University of Singapore(新加坡国立大学);IQuest Research(IQuest研究)

Yicheng He, Zheng Zhao, Zhou Kaiyu, Bryan Dai, Jie Fu, Yonghui Yang

AI总结:

CodeCircuit通过归因图分析LLM内部结构,推断生成代码的正确性,验证内部动态信号的预测能力。

摘要:

当前的代码验证范式严重依赖外部机制,如基于执行的单元测试或辅助LLM裁判,这些机制往往劳动强度大或受限于裁判模型自身能力。这提出了一个根本但尚未探索的问题:能否仅凭LLM的内部计算结构来评估其功能正确性?我们的主要目标是探讨模型的神经动态是否编码了内部可解码的信号,这些信号在代码生成过程中预测逻辑有效性。受机制可解释性启发,我们提出将代码验证视为一种机制诊断任务,将模型的显式算法轨迹映射到行级归因图中。通过分解复杂的残差流,我们旨在识别区分模型内部电路中正确推理与逻辑失败的结构特征。在Python、C++和Java上的分析证实,内在正确性信号在多样化的语法中具有鲁棒性。这些内部图的拓扑特征比表面启发式方法更可靠地预测正确性,并能够实现针对错误逻辑的定向因果干预。这些发现确立了内部反思作为验证生成代码的可解码属性。我们的代码见https://github.com/bruno686/CodeCircuit。

英文摘要:

Current paradigms for code verification rely heavily on external mechanisms-such as execution-based unit tests or auxiliary LLM judges-which are often labor-intensive or limited by the judging model's own capabilities. This raises a fundamental, yet unexplored question: Can an LLM's functional correctness be assessed purely from its internal computational structure? Our primary objective is to investigate whether the model's neural dynamics encode internally decodable signals that are predictive of logical validity during code generation. Inspired by mechanistic interpretability, we propose to treat code verification as a mechanistic diagnostic task, mapping the model's explicit algorithmic trajectory into line-level attribution graphs. By decomposing complex residual flows, we aim to identify the structural signatures that distinguish sound reasoning from logical failure within the model's internal circuits. Analysis across Python, C++, and Java confirms that intrinsic correctness signals are robust across diverse syntaxes. Topological features from these internal graphs predict correctness more reliably than surface heuristics and enable targeted causal interventions to fix erroneous logic. These findings establish internal introspection as a decodable property for verifying generated code. Our code is at https:// github.com/bruno686/CodeCircuit.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑