Large language models encode rich information in their hidden states. This work asks whether code correctness is legible in the hidden states of Qwen3-4B-Instruct-2507, before it generates and as it repairs a failed attempt, studied on 444 LiveCodeBench tasks. It reports two findings connected by a single confound-control tool: residualization. First, the correctness of the model's first-attempt code is linearly decodable from the prompt-final hidden state, with a leakage-free held-out AUC of 0.931 +/- 0.008 across 50 outer splits. After the linear effect of prompt length is removed from each hidden state dimension, the probe still reaches 0.911 +/- 0.010, well above a prompt-length baseline of 0.754 +/- 0.014. Second, on 236 cleaned cases where the model attempts to repair a failed first attempt, the hidden state shift from the failing attempt to its repair carries a statistically detectable contrastive direction, significant on both a magnitude and a split-half test against label-shuffled nulls. This direction does not survive a conditional residualization against repair-context covariates that differ between successful and failed repairs, marking it as a correlate of repair success driven by the repair context rather than an isolated repair-comprehension feature. The probe layer is selected by nested cross-validation, and the same residualization approach that upholds the pre-generation correctness result overturns the repair-direction interpretation. The contribution is as much methodological as empirical: a diagnostic honest enough to report a negative result alongside a positive one.


翻译:大语言模型在其隐状态中编码了丰富的信息。本文探究在Qwen3-4B-Instruct-2507模型生成代码前以及修复失败尝试时,代码正确性是否可从其隐状态中解读,研究基于444个LiveCodeBench任务展开。本文报告两项发现,并通过同一混淆控制工具——残差化(residualization)加以关联。首先,模型首次尝试生成代码的正确性可从提示词末尾的隐状态中线性解码,在50次外部分割中达到无泄漏的留存样本AUC为0.931±0.008。在从每个隐状态维度中剔除提示词长度的线性效应后,探测器的AUC仍达到0.911±0.010,远高于基于提示词长度的基线值0.754±0.014。其次,在236个经过清洗的案例中(模型尝试修复失败的首次尝试),从失败尝试到修复尝试的隐状态偏移携带了统计上可检测的对比方向,该方向在幅度检验和分割半样本检验中均显著优于标签随机打乱的零假设。然而,该方向在经过针对修复上下文协变量的条件残差化处理后便不再成立——这些协变量在成功修复与失败修复间存在差异,表明该方向是修复成功与修复上下文的关联特征,而非独立的修复理解特征。探测器的隐藏层通过嵌套交叉验证选定,而相同的残差化方法既支撑了生成前正确性结果的有效性,也推翻了修复方向解释的可靠性。本文的贡献既在于方法论层面,也在于实证层面:提供了一种诚实可靠的诊断方法,在报告正向结果的同时也能揭示负向结果。

0
下载
关闭预览

相关内容

ICML2026 | 重新思考顺序知识编辑中的正则化
专知会员服务
9+阅读 · 5月27日
AI生成代码缺陷综述
专知会员服务
17+阅读 · 2025年12月8日
【ICLR2024】能检测到LLM产生的错误信息吗?
专知会员服务
25+阅读 · 2024年1月23日
基于 SonarQube 的增量代码扫描
DevOps时代
12+阅读 · 2019年7月18日
最新论文解读 | 基于预训练自然语言生成的文本摘要方法
微软研究院AI头条
57+阅读 · 2019年3月19日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
4+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
6+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
3+阅读 · 6月17日
相关基金
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员