arXiv:2607.24884cs.SEcs.AI2026-07

让代码生成更聪明:主动管理检索信息的不确定性

Beyond "What to Retrieve": Uncertainty in Retrieval-Augmented Code Generation

论文配图:Beyond "What to Retrieve": Uncertainty in Retrieval-Augmented Code Generation
图 1 · 摘自论文原文
  • 引入不确定性感知框架,动态评估不同来源证据的可信度
  • 在32个任务上将GPT代码正确率从56.25%提升至78.13%
  • 适合关注代码生成可靠性与模型可解释性的研究者

仓库级代码生成依赖于异构证据,其相关性、兼容性和完整性存在固有不确定性。相似代码示例、仓库上下文和项目特定API可能提供互补信息,但也可能引入噪声、冗余或冲突信号。现有检索增强方法主要优化检索相关性,未显式建模检索证据不确定性对下游生成的影响。我们提出OpenCoder,一种不确定性感知框架,通过估计源特定不确定性,过滤并排序异构证据,指导生成、验证与修复。在API知识、仓库上下文和相似代码证据上的因子分析显示,不存在通用的加性来源排序;显著的跨源交互依赖于伴随证据和LLM后端。在扩展的32任务RepoExec-inline评估中,OpenCoder使GPT选中输出正确率从56.25%提升至78.13%。然而,其效果与验证-修复对照组相当,且对应Gemini提升无统计显著性,表明收益具有后端依赖性。目标导向的API精炼也显著提升API集检索效果。这些发现支持将不确定性作为可操作的控制信号,用于仓库级检索、验证与修复。

原文摘要 · Abstract (English)

Repository-level code generation relies on heterogeneous evidence whose relevance, compatibility, and completeness are inherently uncertain. Similar-code examples, repository context, and project-specific APIs may provide complementary information, but can also introduce noisy, redundant, or conflicting signals. Existing retrieval-augmented approaches primarily optimize retrieval relevance without explicitly modeling how uncertainty in retrieved evidence affects downstream generation. We introduce OpenCoder, an uncertainty-aware framework that estimates source-specific uncertainty, uses it to filter and rank heterogeneous evidence, and guides generation, verification, and repair. A factorial analysis over API knowledge, repository context, and similar-code evidence reveals no universal additive source ranking; instead, significant cross-source interactions depend on the accompanying evidence and LLM backend. On an expanded 32-task RepoExec-inline evaluation, OpenCoder improves GPT selected-output correctness over Baseline RAG from 56.25\% to 78.13\%. However, it matches a verification-and-repair control, and the corresponding Gemini improvement is not statistically supported, indicating backend-dependent benefits. Target-aware API refinement also substantially improves API-set retrieval. These findings support treating uncertainty as an actionable control signal for repository-level retrieval, verification, and repair.

代码生成检索增强不确定性建模LLM应用

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。