arXiv:2511.14022cs.SEcs.AI2025-11被引 1

让代码大模型保持更新,三种方法各有所长。

Keeping Code-Aware LLMs Fresh: Full Refresh, In-Context Deltas, and Incremental Fine-Tuning

  • 用增量微调+旧代码混合,防止遗忘旧代码。
  • 用最近修改摘要做上下文学习,上线最快。
  • 代码变动多时用差异文件,行为变化用完整文件。

现代代码库持续演进:文件重命名或删除,公共API漂移,模块行为变化。昨日训练的模型若今日仍映射开发者自然语言问题到相关文件路径,将因代码变更而退化,即使问题形式未变。本文在系统规模下,对Flask、SQLAlchemy、Pandas和Poetry等多个主流仓库研究如何在不丢失旧代码理解的前提下保持模型新鲜度。我们将新鲜度定义为基线快照与当前HEAD之间的领域漂移,并对比三类更新策略:(A) 全量重训;(B) 推理时注入近期变更(原始git diff或简洁英文摘要)的上下文学习(ICL);(C) 基于变更数据集的增量微调(Inc-FT),通过精细控制新旧数据比例来缓解灾难性遗忘。我们提出一种别名感知评估协议,在奖励重命名路径的同时永不奖励已删除路径,并设计一个遗忘探测器量化过时路径的残留输出。实验表明,在混合任务上,结合旧知识的Inc-FT表现最佳;当无法训练时,使用英文摘要的ICL能最快提升新代码准确率;全量重训在追求最高新代码精度时仍是上限。此外,对比基于diff的Inc-FT与全文件的Inc-FT发现:在重命名/删除密集场景中,diff更优;在行为变更密集场景中,全文件上下文更佳。

原文摘要 · Abstract (English)

Modern codebases evolve continuously: files are renamed or deleted; public APIs drift; behavior shifts within otherwise familiar modules. A model trained yesterday to map a developer's natural-language question to the exact set of repository file paths that matter will degrade tomorrow, even if the questions themselves look unchanged. In this paper we study, at system scale and across several widely used repositories, how to keep such a model fresh without surrendering retention on earlier code. We frame freshness as a form of domain drift between a base snapshot and the current HEAD, and we compare three families of update strategies: (A) Full Refresh, retraining the entire model at the new snapshot; (B) In-Context Learning (ICL) that injects recent deltas (raw git diffs or concise English summaries) at inference; and (C) Incremental Fine-Tuning (Inc-FT) on delta-derived training sets, with carefully controlled NEW:OLD mixing to mitigate catastrophic forgetting. We contribute an alias-aware evaluation protocol that credits rename while never rewarding deleted paths, and a practical Forgetting Probe that quantifies residual emissions of obsolete paths. Across Flask, SQLAlchemy, Pandas, and Poetry, Inc-FT with old-aware mixes delivers the best overall balance on mixed sets, ICL with English delta summaries delivers the fastest new-code lift when training is not feasible, and Full Refresh remains the ceiling when maximum NEW accuracy matters. We also compare Git-diff Inc-FT to full-file Inc-FT, showing that diffs excel in rename/delete-heavy windows while full-file context wins in behavior-change-heavy windows.

代码生成增量学习LLM优化

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