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.


翻译:当前的代码验证范式严重依赖外部机制——例如基于执行的单元测试或辅助LLM评判器——这些方法通常劳动密集或受限于评判模型自身能力。这引发了一个基础性但尚未探索的问题:能否纯粹从大语言模型(LLM)的内部计算结构评估其生成代码的功能正确性?我们的核心目标是探究模型在代码生成过程中,其神经动力学是否编码了可内部解码且能预测逻辑有效性的信号。受机制可解释性研究启发,我们提出将代码验证视为机制诊断任务,将模型的显式算法轨迹映射为行级归因图。通过分解复杂的残差流,我们旨在识别模型内部电路中区分正确推理与逻辑错误的结构特征。在Python、C++和Java上的实验分析证实,内在正确性信号在不同语法体系中具有鲁棒性。从这些内部图中提取的拓扑特征比表面启发式方法能更可靠地预测正确性,并支持通过定向因果干预修复错误逻辑。这些发现确立了内部自省作为验证生成代码的可解码属性。项目代码位于 https://github.com/bruno686/CodeCircuit。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
如何检测LLM内容?UCSB等最新首篇《LLM生成内容检测》综述
你的算法可靠吗? 神经网络不确定性度量
专知
40+阅读 · 2019年4月27日
【干货】深入理解自编码器(附代码实现)
国家自然科学基金
2+阅读 · 2016年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
VIP会员
相关VIP内容
相关基金
国家自然科学基金
2+阅读 · 2016年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员