arXiv:2607.22898cs.SEcs.CL2026-07

让大模型代码生成的隐含假设显性化,提升代码透明度与可控性。

AssumptionMiner: Extracting, Tracing, and Revising Implicit Assumptions in LLM Code Generation

论文配图:AssumptionMiner: Extracting, Tracing, and Revising Implicit Assumptions in LLM Code Generation
图 1 · 摘自论文原文
  • 通过抽象语法树构建依赖图,显式提取并追踪代码生成中的隐含假设。
  • 在180个模糊任务上,假设提取F1达0.816,较基线提升3.6倍。
  • 支持针对性重生成代码,减少修改范围,适合需要精确控制的开发者。

大型语言模型(LLMs)从自然语言提示生成代码,但真实提示通常不完整。当输入格式、错误处理或设计决策未明确时,LLMs会基于隐含假设填补空白,这些假设影响生成代码的行为和正确性。由于假设隐藏,代码可能通过测试却违背开发意图。我们提出AssumptionMiner框架,将隐含假设作为LLM代码生成的一阶产物。除代码外,该框架还生成结构化的假设层,包含推断出的约束与设计决策,供开发者检查、确认或修正。基于抽象语法树(AST)的依赖图可实现仅针对受影响代码的精准重生成。我们还构建了一个包含180个模糊编程任务、676个标注假设的基准数据集,其中包含经人工验证的子集用于评估代码定位能力。实验评估了假设提取、代码定位与假设引导的重生成效果。在开源LLM上,置信度加权集成的假设提取F1达到0.816,优于最强离线基线3.6倍。在人工验证的定位基准上,基于AST的定位比关键词和整文件基线更精准。修订假设后,目标重生成相比非目标方式修改代码更少,但暴露出级联修改的挑战。结果表明,使假设显性化能显著提升LLM代码生成的透明性与可控性。

原文摘要 · Abstract (English)

Large language models (LLMs) generate code from natural-language prompts, yet real-world prompts rarely provide complete specifications. When prompts leave input formats, error handling, or design decisions unspecified, LLMs fill these gaps with implicit assumptions that shape the generated code's behavior and correctness. Because these assumptions remain hidden, generated code may satisfy tests while violating developer intent. We present AssumptionMiner, a framework that makes implicit assumptions a first-class artifact of LLM-based code generation. In addition to code, AssumptionMiner produces an explicit assumption layer, a structured representation of inferred constraints and design decisions that developers can inspect, confirm, or revise. An AST-based dependency graph enables targeted regeneration of only the code affected by a revised assumption. We also introduce a benchmark of 180 ambiguous programming tasks with 676 annotated assumptions, including a human-verified subset for evaluating code localization. We evaluate assumption extraction, code localization, and assumption-guided regeneration. Across open-source LLMs, a confidence-weighted ensemble achieves an F1 score of 0.816 for assumption extraction, improving on the strongest offline baseline by 3.6x. On the human-verified localization benchmark, AST-guided localization identifies more precise code regions than keyword-based and whole-file baselines. During assumption revision, targeted regeneration modifies less code than non-targeted alternatives while exposing challenges in handling cascading edits. These results demonstrate that making assumptions explicit improves the transparency and controllability of LLM-based code generation.

大模型代码生成假设提取可解释性

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