从补全到编辑:通过搜索和替换指令微调解锁上下文感知的代码填充
From Completion to Editing: Unlocking Context-Aware Code Infilling via Search-and-Replace Instruction Tuning
AI总结:
通过搜索和替换指令微调,SRI框架实现了上下文感知的代码填充,提升了补全性能并保持低延迟。
摘要:
主流的中间填充(FIM)范式在代码补全中受到其刚性无法纠正上下文错误和依赖于不匹配、不安全的基模型的限制。尽管聊天大语言模型提供安全性和代理工作流提供灵活性,但它们分别面临性能下降和不可接受的延迟问题。为了解决这一矛盾,我们提出了搜索和替换填充(SRI),一种将代理的验证和编辑机制内化到统一、单次推理过程中的框架。通过结构化地通过显式搜索阶段来定位编辑,SRI将补全任务与聊天大语言模型的指令遵循先验相结合,将范式从静态填充扩展到动态上下文感知编辑。我们合成了一个高质量的数据集,SRI-200K,并对SRI-Coder系列进行了微调。广泛的评估表明,使用少量数据(20k样本),SRI-Coder使聊天模型在补全性能上超越其基模型。关键的是,与FIM式微调不同,SRI保留了通用编程能力,并且保持了与标准FIM相当的推理延迟。我们使整个Qwen3-Coder系列具备SRI,鼓励开发者社区利用这一框架进行高级自动补全和辅助开发。
英文摘要:
The dominant Fill-in-the-Middle (FIM) paradigm for code completion is constrained by its rigid inability to correct contextual errors and reliance on unaligned, insecure Base models. While Chat LLMs offer safety and Agentic workflows provide flexibility, they suffer from performance degradation and prohibitive latency, respectively. To resolve this dilemma, we propose Search-and-Replace Infilling (SRI), a framework that internalizes the agentic verification-and-editing mechanism into a unified, single-pass inference process. By structurally grounding edits via an explicit search phase, SRI harmonizes completion tasks with the instruction-following priors of Chat LLMs, extending the paradigm from static infilling to dynamic context-aware editing. We synthesize a high-quality dataset, SRI-200K, and fine-tune the SRI-Coder series. Extensive evaluations demonstrate that with minimal data (20k samples), SRI-Coder enables Chat models to surpass the completion performance of their Base counterparts. Crucially, unlike FIM-style tuning, SRI preserves general coding competencies and maintains inference latency comparable to standard FIM. We empower the entire Qwen3-Coder series with SRI, encouraging the developer community to leverage this framework for advanced auto-completion and assisted development.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。