arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2601.10496cs.SEcs.AI
收藏

模型看见,模型做?基于暴露的bug-修复偏好评估

Model See, Model Do? Exposure-Aware Evaluation of Bug-vs-Fix Preference in Code LLMs

Delft University of Technology(代尔夫特理工大学);University of California at Davis(加州大学戴维斯分校)

Ali Al-Kaswan, Claudio Spiess, Prem Devanbu, Arie van Deursen, Maliheh Izadi

AI总结:

研究发现LLM在生成代码时更倾向于重复bug而非修复,暴露于bug的示例加剧了这一倾向,而修复暴露则仅有微小改进,揭示了LLM可能传播记忆错误的风险。

摘要:

大型语言模型越来越多地用于代码生成和调试,但其输出仍可能包含源自训练数据的bug。区分LLM是否更倾向于正确代码还是熟悉但错误的版本可能受训练期间暴露的内容影响。我们介绍了一个暴露意识的评估框架,量化了先前暴露于bug或修复代码对模型偏好的影响。使用ManySStuBs4J基准,我们通过数据肖像对Stack-V2语料库进行成员测试,以估计每个bug和修复变体是否在训练数据中出现。然后我们按暴露情况对示例进行分层,并通过代码补全以及多种基于概率的评分指标比较模型偏好。我们发现大多数示例(67%)在训练数据中都没有变体,当只有一种存在时,修复比bug更常出现。在模型生成中,模型更频繁地重复bug行而非修复,暴露于bug的示例加剧了这种倾向,而暴露于修复的示例仅显示微小改进。在概率评分中,最小和最大token-概率指标在所有条件下都倾向于修复代码,表明对正确修复的稳定偏爱。相比之下,如基尼系数等指标在只出现bug变体时会反转偏好。我们的结果表明,暴露可能扭曲bug-修复评估,并突显了LLM在实践中可能传播记忆中的错误的风险。

英文摘要:

Large language models are increasingly used for code generation and debugging, but their outputs can still contain bugs, that originate from training data. Distinguishing whether an LLM prefers correct code, or a familiar incorrect version might be influenced by what it's been exposed to during training. We introduce an exposure-aware evaluation framework that quantifies how prior exposure to buggy versus fixed code influences a model's preference. Using the ManySStuBs4J benchmark, we apply Data Portraits for membership testing on the Stack-V2 corpus to estimate whether each buggy and fixed variant was seen during training. We then stratify examples by exposure and compare model preference using code completion as well as multiple likelihood-based scoring metrics We find that most examples (67%) have neither variant in the training data, and when only one is present, fixes are more frequently present than bugs. In model generations, models reproduce buggy lines far more often than fixes, with bug-exposed examples amplifying this tendency and fix-exposed examples showing only marginal improvement. In likelihood scoring, minimum and maximum token-probability metrics consistently prefer the fixed code across all conditions, indicating a stable bias toward correct fixes. In contrast, metrics like the Gini coefficient reverse preference when only the buggy variant was seen. Our results indicate that exposure can skew bug-fix evaluations and highlight the risk that LLMs may propagate memorised errors in practice.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑