[论文解读] Exploring the Robustness of Large Language Models for Solving Programming Problems
本文通过修改问题描述和提示格式,评估了大型语言模型(LLMs)如Codex、CodeGen、InstructGPT和ChatGPT在解决入门级编程问题时的鲁棒性。研究发现,像Codex这样的旧模型对表面变化(尤其是变量名)极为敏感,而像ChatGPT这样的新模型由于经过RLHF微调,表现出显著提升的鲁棒性,表明其正朝着更深层次的理解而非记忆化方向发展。
Using large language models (LLMs) for source code has recently gained attention. LLMs, such as Transformer-based models like Codex and ChatGPT, have been shown to be highly capable of solving a wide range of programming problems. However, the extent to which LLMs understand problem descriptions and generate programs accordingly or just retrieve source code from the most relevant problem in training data based on superficial cues has not been discovered yet. To explore this research question, we conduct experiments to understand the robustness of several popular LLMs, CodeGen and GPT-3.5 series models, capable of tackling code generation tasks in introductory programming problems. Our experimental results show that CodeGen and Codex are sensitive to the superficial modifications of problem descriptions and significantly impact code generation performance. Furthermore, we observe that Codex relies on variable names, as randomized variables decrease the solved rate significantly. However, the state-of-the-art (SOTA) models, such as InstructGPT and ChatGPT, show higher robustness to superficial modifications and have an outstanding capability for solving programming problems. This highlights the fact that slight modifications to the prompts given to the LLMs can greatly affect code generation performance, and careful formatting of prompts is essential for high-quality code generation, while the SOTA models are becoming more robust to perturbations.
研究动机与目标
- 探究大型语言模型是通过真正的理解还是通过检索记忆化解决方案来解决编程问题,这些解决方案依赖于表面线索。
- 评估提示格式和修改对多种SOTA大型语言模型代码生成性能的影响。
- 确定变量名和语义变化在代码生成任务中对模型行为的影响程度。
- 评估大型语言模型对问题描述中表面和语义扰动的鲁棒性。
- 为当前大型语言模型在自动编程问题求解中的局限性和能力提供实证洞察。
提出的方法
- 本研究使用Aizu Online Judge(AOJ)中的问题描述作为提示,用于大型语言模型生成Python代码。
- 开展两项主要实验:(1) 表面格式变化(如换行符、标点符号);(2) 语义和表面修改(如问题规格的反向表达、变量名随机化)。
- 通过隐藏测试用例衡量代码正确性,以解决率作为主要指标。
- 评估的模型包括CodeGen、Codex、InstructGPT和ChatGPT,涵盖多种训练方法,包括RLHF。
- 使用UUID对变量名进行匿名化,以测试模型对提示中词汇线索的依赖程度。
- 通过比较模型在扰动输入下的响应,评估其敏感性和泛化能力。

实验结果
研究问题
- RQ1大型语言模型在生成代码时在多大程度上依赖于表面线索(如格式和变量名)?
- RQ2提示格式如何影响不同大型语言模型的代码生成性能?
- RQ3语义修改(如问题规格的反向表达)如何影响模型输出和正确性?
- RQ4RLHF微调的引入在多大程度上提升了模型对提示扰动的鲁棒性?
- RQ5大型语言模型能否泛化到与原始提示语义相反的问题?
主要发现
- Codex在最差和最佳提示格式之间表现出25.9%的性能提升,表明其对格式高度敏感。
- CodeGen在格式变化下表现出14.7%的性能波动,同样表明其对格式有强烈依赖。
- 通过UUID随机化变量名显著降低了Codex的解决率,表明其严重依赖变量名的语义信息。
- ChatGPT和InstructGPT在格式和变量名扰动下均表现出更优的鲁棒性,表明其具备更深层次的理解能力。
- Codex有时在提示语义被反转(如求和→求积)的情况下仍能生成正确代码,表明其依赖记忆而非推理。
- 模型通常拒绝在生成的代码中使用匿名化变量名,而偏好原始名称,进一步证实其对词汇线索的依赖。

更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。