arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2503.12899cs.SEcs.CLcs.LG
收藏

基于语义的优化方法用于修复大语言模型:代码生成的案例研究

A Semantic-based Optimization Approach for Repairing LLMs: Case Study on Code Generation

Monash University(墨尔本大学);Technical University of Munich(慕尼黑技术大学);Chongqing University(重庆大学)

Jian Gu, Aldeida Aleti, Chunyang Chen, Hongyu Zhang

AI总结:

本文提出STAR方法,通过基于语义的优化修复大语言模型,提升代码生成的准确性和效率。

摘要:

语言模型(LMs)在软件工程中被广泛用于代码生成,但它们可能会生成有错误的代码。与其修复输出,不如解决底层模型故障。LM修复提供了一种轻量级的解决方案:它需要最少的数据,降低了计算成本,并限制了副作用。与全量重新训练不同,LM修复专注于对目标神经元应用定制更新,使其适合资源有限、高性能需求或严格安全要求的情况。在本文中,我们提出了语义导向的分析修复(STAR),一种新颖的基于语义的优化方法用于修复大语言模型。STAR通过优化过程实现了修复LM的主要操作,包括定位“有bug的神经元”、解决“神经元补丁”以及修补“有bug的神经元”。神经元补丁通过一个坚实的基于语义的分析公式计算,该公式直接将logits的变化与神经元的delta联系起来,通过引导潜在表示。与LM修复的先前工作(MINT)和标准优化方法(SGD)相比,STAR整合了它们的优势并缓解了它们的局限性。通过将LM修复重新公式化为优化过程,STAR可能同时解决多个故障,显著提高了实用性。在使用流行代码LM的编码任务上,STAR在与最先进方法相比显示出优越的效果。此外,STAR还表现出更好的效率。在副作用方面,即通用性和特异性之间的平衡,STAR比先前工作有显著优势。此外,我们还评估了LM修复的过拟合风险以及累积影响。进一步,我们分析了与流水线方法的差异,并解释了为什么STAR更好以及它如何缓解LM修复的常见局限性。

英文摘要:

Language Models (LMs) are widely used in software engineering for code generation, but they may produce erroneous code. Rather than repairing outputs, a more thorough remedy is to address underlying model failures. LM repair offers a lightweight solution: it requires minimal data, lowers computational cost, and limits side effects. Unlike full retraining, LM repair focuses on applying tailored updates to targeted neurons, making it suitable for limited resources, high-performance demands, or strict safety requirements. In this paper, we propose Semantic Targeting for Analytical Repair (STAR), a novel semantic-based optimization method for repairing LLMs. STAR realizes the main operations of repairing LMs in an optimization process, including locating ``buggy neurons'', solving ``neuron patches'', and patching ``buggy neurons''. The neuron patches are computed with a solid semantic-based analytical formula, which directly bridges the changes to logits with the deltas of neurons, by steering latent representations. Compared to the prior work of LM repair (MINT) and standard optimization methods (SGD), STAR integrates their strengths while mitigating their limitations. By reformulating LM repair as an optimization process, STAR may solve multiple failures together, significantly improving the usefulness. Evaluated on coding tasks using popular code LMs, STAR demonstrates superior effectiveness compared with the state-of-the-art. Besides, STAR exhibits better efficiency. In terms of side effects, namely the balance between generalization and specificity, STAR outperforms prior work by a significant margin. Additionally, we conducted assessments on the overfitting risk of LM repair as well as the cumulative impact. Further, we analyzed the differences with pipeline-based methods and explained the reason why STAR is better and how it mitigated the common limitations of LM repair.

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

↑