发表机构
Michigan Technological University(密歇根理工大学)
机构由 AI 辅助整理,请以论文原文为准。AI 中文总结
研究LLMs代码生成中隐式假设问题,提出AssumptionMiner框架,能生成显式假设层并实现针对性代码再生。通过新基准测试评估,结果显示该框架提升了代码生成的透明度与可控性。
AI 中文摘要
大语言模型(LLMs)根据自然语言提示生成代码,但现实世界的提示很少提供完整规范。当提示未指定输入格式、错误处理或设计决策时,LLMs会用隐式假设填补这些空白,这可能导致生成的代码违反开发者意图。我们提出了假设挖掘器(AssumptionMiner)框架,它使隐式假设成为基于LLMs代码生成的一等工件。除了代码,该框架还生成一个显式假设层,基于AST的依赖图可实现仅受修订假设影响的代码的有针对性的重新生成。我们还引入了一个包含180个模糊编程任务和676个带注释假设的基准测试。评估结果表明,使假设显式化可提高基于LLMs代码生成的透明度和可控性。
英文摘要
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.
Comments20 pages, 6 figures, 9 tables. Submitted to IEEE Transactions on Software Engineering. Replication package: https://doi.org/10.5281/zenodo.21535058