测试大模型在模糊任务描述下的代码生成鲁棒性
When Prompts Go Wrong: Evaluating Code Model Robustness to Ambiguous, Contradictory, and Incomplete Task Descriptions
- 通过模拟真实开发场景中的错误描述,扩展评测基准
- 小缺陷即导致性能显著下降,矛盾描述引发大量逻辑错误
- 大模型更抗干扰但仍有不足,适合关注实际应用的开发者
大型语言模型在理想条件下代码生成表现优异,但在实践中任务描述常含模糊、不完整或自相矛盾等问题。本文首次系统评估主流代码生成模型在这些不清晰指令下的鲁棒性。我们通过有指导的变异策略,在HumanEval和MBPP基准上引入真实感缺陷,构建了反映非正式开发指令混乱性的数据集。评估多个不同规模与架构的LLM,分析其在各类描述下的功能正确性与失败模式。结果表明,即使微小的表述瑕疵也会造成显著性能下降,矛盾描述导致大量逻辑错误。尽管大模型相对更稳健,但仍无法完全应对不明确需求。进一步分析语义错误模式,发现描述清晰度、模型行为与错误类型间存在关联。研究强调需提升模型对自然用户任务固有缺陷的鲁棒性,对训练策略、评测基准设计及实际部署具有重要启示。
原文摘要 · Abstract (English)
Large Language Models (LLMs) have demonstrated impressive performance in code generation tasks under idealized conditions, where task descriptions are clear and precise. However, in practice, task descriptions frequently exhibit ambiguity, incompleteness, or internal contradictions. In this paper, we present the first empirical study examining the robustness of state-of-the-art code generation models when faced with such unclear task descriptions. We extend the HumanEval and MBPP benchmarks by systematically introducing realistic task descriptions flaws through guided mutation strategies, producing a dataset that mirrors the messiness of informal developer instructions. We evaluate multiple LLMs of varying sizes and architectures, analyzing their functional correctness and failure modes across task descriptions categories. Our findings reveal that even minor imperfections in task description phrasing can cause significant performance degradation, with contradictory task descriptions resulting in numerous logical errors. Moreover, while larger models tend to be more resilient than smaller variants, they are not immune to the challenges posed by unclear requirements. We further analyze semantic error patterns and identify correlations between description clarity, model behavior, and error types. Our results underscore the critical need for developing LLMs that are not only powerful but also robust to the imperfections inherent in natural user tasks, highlighting important considerations for improving model training strategies, designing more realistic evaluation benchmarks, and ensuring reliable deployment in practical software development environments.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。