Skip to main content
CenXiv.org
此网站处于试运行阶段,支持我们!
我们衷心感谢所有贡献者的支持。
贡献
赞助
cenxiv logo > cs > arXiv:2507.16407v1

帮助 | 高级搜索

计算机科学 > 软件工程

arXiv:2507.16407v1 (cs)
[提交于 2025年7月22日 ]

标题: 通过层感知模型编辑提高代码LLM对提示扰动的鲁棒性

标题: Improving Code LLM Robustness to Prompt Perturbations via Layer-Aware Model Editing

Authors:Shuhan Liu, Xing Hu, Kerui Huang, Xiaohu Yang, David Lo, Xin Xia
摘要: 大型语言模型(LLMs)在代码生成方面表现出色,其中自然语言提示在向模型传达用户意图方面起着关键作用。 然而,先前的研究表明,LLMs对提示扰动非常敏感。措辞、语法或格式的微小修改可能会显著降低生成代码的功能正确性。 由于扰动在现实场景中经常发生,提高LLMs对提示扰动的鲁棒性对于确保实际代码生成中的可靠性能至关重要。 在本文中,我们引入了CREME(通过模型编辑增强代码鲁棒性),这是一种通过有针对性的参数更新来增强LLMs鲁棒性的新方法。 CREME首先通过比较原始提示与其扰动变体之间的隐藏状态来识别鲁棒性敏感层。 然后,它在识别出的层上进行轻量级参数编辑,以减少性能下降。 我们在两个广泛使用的代码生成基准(HumanEval和MBPP)及其扰动版本上评估了CREME。 实验结果表明,CREME在扰动提示上的Pass@1准确率提高了63%,同时在干净输入上保持稳定性能,准确率偏差在1%以内。 进一步分析表明,鲁棒性敏感层主要集中在网络的中间和深层,且它们的位置在不同的模型架构中有所不同。 这些见解为开发未来的面向鲁棒性的编辑策略提供了有价值的基础。
摘要: Large language models (LLMs) have demonstrated impressive capabilities in code generation, where the natural language prompt plays a crucial role in conveying user intent to the model. However, prior studies have shown that LLMs are highly sensitive to prompt perturbations. Minor modifications in wording, syntax, or formatting can significantly reduce the functional correctness of generated code. As perturbations frequently occur in real-world scenarios, improving the robustness of LLMs to prompt perturbations is essential for ensuring reliable performance in practical code generation. In this paper, we introduce CREME (Code Robustness Enhancement via Model Editing), a novel approach that enhances LLM robustness through targeted parameter updates. CREME first identifies robustness-sensitive layers by comparing hidden states between an original prompt and its perturbed variant. Then, it performs lightweight parameter editing at the identified layer to reduce performance degradation. We evaluate CREME on two widely used code generation benchmarks (HumanEval and MBPP) along with their perturbed counterparts. Experimental results show that CREME improves Pass@1 accuracy by 63% on perturbed prompts while maintaining stable performance on clean inputs, with accuracy deviations within 1%. Further analysis reveals that robustness-sensitive layers are primarily concentrated in the middle and deeper layers of the network, and their locations vary across different model architectures. These insights provide a valuable foundation for developing future robustness-oriented editing strategies.
主题: 软件工程 (cs.SE)
引用方式: arXiv:2507.16407 [cs.SE]
  (或者 arXiv:2507.16407v1 [cs.SE] 对于此版本)
  https://doi.org/10.48550/arXiv.2507.16407
通过 DataCite 发表的 arXiv DOI

提交历史

来自: Shuhan Liu [查看电子邮件]
[v1] 星期二, 2025 年 7 月 22 日 09:57:55 UTC (194 KB)
全文链接:

获取论文:

    查看标题为《》的 PDF
  • 查看中文 PDF
  • 查看 PDF
  • HTML(实验性)
  • TeX 源代码
  • 其他格式
查看许可
当前浏览上下文:
cs.SE
< 上一篇   |   下一篇 >
新的 | 最近的 | 2025-07
切换浏览方式为:
cs

参考文献与引用

  • NASA ADS
  • 谷歌学术搜索
  • 语义学者
a 导出 BibTeX 引用 加载中...

BibTeX 格式的引用

×
数据由提供:

收藏

BibSonomy logo Reddit logo

文献和引用工具

文献资源探索 (什么是资源探索?)
连接的论文 (什么是连接的论文?)
Litmaps (什么是 Litmaps?)
scite 智能引用 (什么是智能引用?)

与本文相关的代码,数据和媒体

alphaXiv (什么是 alphaXiv?)
CatalyzeX 代码查找器 (什么是 CatalyzeX?)
DagsHub (什么是 DagsHub?)
Gotit.pub (什么是 GotitPub?)
Hugging Face (什么是 Huggingface?)
带有代码的论文 (什么是带有代码的论文?)
ScienceCast (什么是 ScienceCast?)

演示

复制 (什么是复制?)
Hugging Face Spaces (什么是 Spaces?)
TXYZ.AI (什么是 TXYZ.AI?)

推荐器和搜索工具

影响之花 (什么是影响之花?)
核心推荐器 (什么是核心?)
IArxiv 推荐器 (什么是 IArxiv?)
  • 作者
  • 地点
  • 机构
  • 主题

arXivLabs:与社区合作伙伴的实验项目

arXivLabs 是一个框架,允许合作伙伴直接在我们的网站上开发和分享新的 arXiv 特性。

与 arXivLabs 合作的个人和组织都接受了我们的价值观,即开放、社区、卓越和用户数据隐私。arXiv 承诺这些价值观,并且只与遵守这些价值观的合作伙伴合作。

有一个为 arXiv 社区增加价值的项目想法吗? 了解更多关于 arXivLabs 的信息.

这篇论文的哪些作者是支持者? | 禁用 MathJax (什么是 MathJax?)
  • 关于
  • 帮助
  • contact arXivClick here to contact arXiv 联系
  • 订阅 arXiv 邮件列表点击这里订阅 订阅
  • 版权
  • 隐私政策
  • 网络无障碍帮助
  • arXiv 运营状态
    通过...获取状态通知 email 或者 slack

京ICP备2025123034号