arXiv:2411.06638cs.SEcs.CL2024-11中稿 · ICSE2025被引 14

首次系统评估代码大模型编辑技术,发现记忆增强法最有效。

Model Editing for LLMs4Code: How Far are We?

  • 用外部记忆机制修正代码模型错误知识,避免重训练
  • GRACE方法在21000+生成样本上实现最高编辑精度和特异性
  • 提出A-GRACE改进版,提升对语义相同输入的泛化能力

代码大模型(LLMs4Code)在软件工程领域表现优异,但难免存在错误或过时的代码知识。由于训练成本高,重新训练不现实。模型编辑技术可在不重训练的情况下高效修正错误知识。然而,当前缺乏对主流编辑技术在多种代码任务中表现的系统性评估。为此,我们提出首个系统研究,构建名为CLMEEval的基准,包含21000+代码生成样本(CoNaLa-Edit)和16000+代码摘要样本(CodeSearchNet-Edit)。在CodeLlama(7B)、CodeQwen1.5(7B)和Stable-Code(3B)上评估六种先进编辑技术。结果表明,基于外部记忆的GRACE方法在编辑效果与特异性方面最优;但现有方法普遍存在泛化能力不足的问题。基于深入案例分析,我们提出A-GRACE,引入对比学习以更好捕捉输入语义,显著提升泛化性能。

原文摘要 · Abstract (English)

Large Language Models for Code (LLMs4Code) have been found to exhibit outstanding performance in the software engineering domain, especially the remarkable performance in coding tasks. However, even the most advanced LLMs4Code can inevitably contain incorrect or outdated code knowledge. Due to the high cost of training LLMs4Code, it is impractical to re-train the models for fixing these problematic code knowledge. Model editing is a new technical field for effectively and efficiently correcting erroneous knowledge in LLMs, where various model editing techniques and benchmarks have been proposed recently. Despite that, a comprehensive study that thoroughly compares and analyzes the performance of the state-of-the-art model editing techniques for adapting the knowledge within LLMs4Code across various code-related tasks is notably absent. To bridge this gap, we perform the first systematic study on applying state-of-the-art model editing approaches to repair the inaccuracy of LLMs4Code. To that end, we introduce a benchmark named CLMEEval, which consists of two datasets, i.e., CoNaLa-Edit (CNLE) with 21K+ code generation samples and CodeSearchNet-Edit (CSNE) with 16K+ code summarization samples. With the help of CLMEEval, we evaluate six advanced model editing techniques on three LLMs4Code: CodeLlama (7B), CodeQwen1.5 (7B), and Stable-Code (3B). Our findings include that the external memorization-based GRACE approach achieves the best knowledge editing effectiveness and specificity (the editing does not influence untargeted knowledge), while generalization (whether the editing can generalize to other semantically-identical inputs) is a universal challenge for existing techniques. Furthermore, building on in-depth case analysis, we introduce an enhanced version of GRACE called A-GRACE, which incorporates contrastive learning to better capture the semantics of the inputs.

代码大模型模型编辑GRACE对比学习

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。