论文精选

Code Is More Than Text:面向代码生成的不确定性估计新方法

Code Is More Than Text: Uncertainty Estimation for Code Generation

精选理由

代码生成的不确定性评估长期被自然语言方法误导,这篇论文给出了三个正交维度,做代码LLM安全评估或部署的团队值得仔细看,能直接改进选择性预测和人工审查流程。

AI 摘要

大型语言模型越来越多地用于代码生成,但静默错误程序带来安全风险。现有不确定性估计方法多继承自自然语言,忽略了代码的三个独特特性:单个错误标记可破坏整个程序(标记脆弱性)、算法意图与具体实现可能不一致(意图-代码差距)、以及程序可执行。研究者提出三个正交不确定性轴:词汇(Top-K token熵)、算法(伪代码一致性)和功能(行为一致性)。在五个代码LLM上,三轴集成将平均AUROC从0.696提升至0.776(+8.1点),且单次Top-K token熵在Qwen3-14B上匹配最强多基线,成本降低3倍以上。这表明代码不确定性估计需要代码特定的设计。

原文 · arXiv cs.LG

Code Is More Than Text: Uncertainty Estimation for Code Generation

Large language models (LLMs) are increasingly deployed as code generators, where silently wrong programs pose real safety and reliability risks. Reliable uncertainty estimation (UE) is essential for selective prediction, human-in-the-loop review, and downstream agentic decisions. Yet most existing code UE methods are inherited from natural language (NL) generation and ignore properties that make code distinct. We argue that code differs from NL in three ways: a single wrong token can break an entire program (token fragility); algorithmic intent and concrete implementation can disagree independently (intent-code gap); and programs can be executed (executability). We instantiate these properties as three orthogonal uncertainty axes: lexical (Top-K token entropy), algorithmic (pseudo-code consistency), and functional (behavioral consistency). Across five code LLMs, our three-axis ensemble improves average AUROC from 0.696 for the strongest NL-derived baseline to 0.776 (+8.1 points). Notably, on Qwen3-14B, our single-pass Top-K token entropy matches the strongest multi-pass baseline while being over 3x cheaper; across models, it remains a competitive low-cost signal. These results suggest that code UE deserves code-specific design rather than direct NL ports.