轻量级模型编辑用于LLMs纠正过时的API推荐
Don't Use a Cannon to Kill a Fly: Lightweight Model Editing for LLMs to Correct Deprecated API Recommendations
AI总结:
本文提出AdaLoRA-L方法,通过区分通用API层和特定API层,提升LLMs生成最新API的能力。
摘要:
预训练或在大规模代码语料上微调的大型语言模型(LLMs)在代码补全任务中表现出强大的性能。然而,其嵌入的知识受到训练数据时效性的限制,通常包含使用过时API的代码。因此,LLMs经常生成不再被第三方库未来版本支持的过时API。尽管重新训练LLMs以更新代码库可以刷新其API知识,但这种方法计算成本高昂。最近,轻量级模型编辑方法出现,以高效地纠正LLMs中的特定知识。然而,仍然不清楚这些方法是否能有效更新过时的API知识,并使编辑后的模型生成最新的API。为解决这一差距,我们进行了首次系统研究,将10种最先进的模型编辑技术应用于三个LLMs中:Qwen2.5-Coder、StarCoder2和DeepSeek-Coder,以更新过时的API知识。我们引入了EDAPIBench,一个专门设计的基准测试,包含来自8个流行Python库的70多个过时API,以及超过3000个编辑实例。我们的结果表明,参数高效的微调方法AdaLoRA在使编辑后的模型生成正确、最新的API方面表现最佳,但在特定性(即编辑影响非目标知识)方面有所不足。为解决这一问题,我们提出了AdaLoRA-L,它定义了“通用API层”(在所有API中具有高重要性的LLM层,存储通用知识并排除在编辑之外)和“特定API层”(仅对目标API具有高重要性的LLM层,存储API特定的知识)。实验结果表明,AdaLoRA-L在提高特定性的同时,其他评估指标的表现与之相当。
英文摘要:
Pre-trained or fine-tuned on large code corpora, Large Language Models (LLMs) have demonstrated strong performance in code completion tasks. However, their embedded knowledge is constrained by the timeliness of training data, which often includes code using deprecated APIs. Consequently, LLMs frequently generate deprecated APIs that will no longer be supported in future versions of third-party libraries. While retraining LLMs on updated codebases could refresh their API knowledge, this approach is computationally expensive. Recently, lightweight model editing methods have emerged to efficiently correct specific knowledge in LLMs. However, it remains unclear whether these methods can effectively update deprecated API knowledge and enable edited models to generate up-to-date APIs. To address this gap, we conduct the first systematic study applying 10 state-of-the-art model editing techniques to update deprecated API knowledge in three LLMs: Qwen2.5-Coder, CodeGemma, and DeepSeek-Coder. We introduce EDAPIBench, a dedicated benchmark featuring over 70 deprecated APIs from 8 popular Python libraries, with more than 3,000 editing instances. Our results show that the parameter-efficient fine-tuning method AdaLoRA achieves the best performance in enabling edited models to generate correct, up-to-date APIs, but falls short in Specificity (i.e., the editing influences untargeted knowledge). To resolve this, we propose AdaLoRA-L, which defines "Common API Layers" (layers within the LLMs with high importance across all APIs, storing general knowledge and excluded from editing) and restricts edits exclusively to "Specific API Layers" (layers with high importance only for the target API, storing the API-specific knowledge). Experimental results demonstrate that AdaLoRA-L significantly improves Specificity while maintaining comparable performance across other evaluation metrics.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。