Large Language Models for Programming: Actually Fixing or Reimplementing Incorrect Code?
作者: Alexandru Stefan Stoica, Traian Rebedea, Marian Cristian Mihaescu
分类: cs.CL, cs.SE
发布日期: 2026-09-24
💡 一句话要点
探讨大型语言模型在编程中的错误修复与重实现问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 大型语言模型 编程错误修复 人类修复对比 AI辅助编程 问题解决策略 Codeforces 深度学习
📋 核心要点
- 现有方法未能有效评估大型语言模型在错误修复与问题解决之间的关系,导致对其能力的理解不够全面。
- 本文通过构建包含用户提交与人类修复的数据库,探讨LLM在修复错误时的偏差及其生成新解决方案的倾向。
- 实验结果表明,LLM在生成解决方案时更倾向于从头开始,而非简单修复错误,且在某些情况下表现出更高的正确率。
📝 摘要(中文)
近期研究表明,大型语言模型(LLM)能够有效解决各种编程环境中的问题并修复错误,包括竞赛编程。然而,现有方法主要独立评估LLM在问题解决或错误修复方面的表现,未探讨这两者之间的关系。本文旨在确定LLM在修复错误时与人类修复方案的偏差程度,以及其是否倾向于生成全新解决方案。我们构建了一个包含约3000个提交的数据库,并将每个有缺陷的提交与其对应的人类修复进行匹配。通过评估LLM生成的错误修复质量,我们发现LLM在修复时修改的行数往往超过人类修复,并且在某些情况下生成全新解决方案。这对AI辅助编程工具的设计具有重要意义,尤其是在支持用户调试过程和促进增量问题解决策略方面。
🔬 方法详解
问题定义:本文旨在探讨大型语言模型在修复编程错误时的表现,尤其是其与人类修复方案的偏差,以及是否倾向于生成全新解决方案。现有方法主要独立评估问题解决和错误修复,未能综合考虑这两者的关系。
核心思路:通过构建一个包含用户提交和人类修复的数据库,本文评估LLM生成的错误修复质量,并与人类修复进行比较,以了解LLM的修复策略和效果。
技术框架:研究首先收集Codeforces平台上的用户提交数据,构建包含约3000个提交的数据库。然后,将每个有缺陷的提交与其对应的人类修复进行匹配,使用OpenAI的三个GPT模型进行错误修复生成,并通过相似度评估修复质量。
关键创新:本文的创新在于系统性地比较LLM生成的修复与人类修复之间的差异,揭示了LLM在修复过程中可能的过度修改和生成新解决方案的倾向,这是以往研究未曾深入探讨的。
关键设计:在实验中,使用Codeforces-R1数据集进行问题验证,评估LLM生成的解决方案是否有效。模型选择包括gpt-5-nano、gpt-5-mini和gpt-5.1,重点关注生成修复的行数和解决问题的正确率。实验设计考虑了相似度作为基线,以评估LLM的修复质量。
🖼️ 关键图片
📊 实验亮点
实验结果显示,LLM在修复错误时往往修改的行数超过必要的数量,并且在某些情况下生成全新解决方案。与人类修复相比,LLM在从头生成解决方案时表现出更高的正确率。这一发现对AI辅助编程工具的设计具有重要启示,强调了增量问题解决策略的重要性。
🎯 应用场景
该研究的潜在应用领域包括AI辅助编程工具的开发,特别是在用户调试和问题解决过程中。通过理解LLM的修复策略,可以优化编程环境中的错误修复功能,提升开发者的工作效率。此外,研究结果可能推动更智能的编程助手的设计,帮助开发者更好地应对复杂的编程挑战。
📄 摘要(原文)
Recent studies have shown that Large Language Models can effectively solve problems and fix bugs in diverse programming environments, including competitive programming. Existing approaches primarily evaluate LLM performance in problem solving or bug fixing independently, but do not explore the relationship between these two capabilities. This work focuses on determining how much the LLM deviates from a buggy solution to fix the bug compared to a human-written patch, and if there is a bias towards generating entirely new solutions. We construct a dataset with all the submissions ($\sim$ 3000) from a couple of users from Codeforces, and we match each buggy submission with its corresponding human fix. By using the similarity between the buggy solution and the human fix as a baseline, we evaluate the quality of LLM-generated bug fixes on 3 OpenAI GPT models (gpt-5-nano, gpt-5-mini, gpt-5.1). We check if the generated solutions solve the problem by using the Codeforces-R1 dataset, an openly available dataset that has tests generated with the DeepSeek-R1 model. Our findings suggest that LLMs tend to modify more lines than necessary compared to human fixes and, in some cases, generate entirely new solutions. We also observe that LLMs solve more problems correctly when allowed to generate solutions from scratch rather than patch buggy submissions, even when those submissions are close to the human patch. This has important implications for the design of AI-assisted programming tools, particularly in supporting user debugging processes and promoting incremental problem-solving strategies rather than solution replacement.