From Completion to Editing: Unlocking Context-Aware Code Infilling via Search-and-Replace Instruction Tuning

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Zhang, Jiajun, Cui, Zeyu, Yang, Jiaxi, Zhang, Lei, Jing, Yuheng, Ma, Zeyao, Bai, Tianyi, Wang, Zilei, Liu, Qiang, Wang, Liang, Hui, Binyuan, Lin, Junyang
Format: Preprint
Veröffentlicht: 2026
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866914265273729024
author Zhang, Jiajun
Cui, Zeyu
Yang, Jiaxi
Zhang, Lei
Jing, Yuheng
Ma, Zeyao
Bai, Tianyi
Wang, Zilei
Liu, Qiang
Wang, Liang
Hui, Binyuan
Lin, Junyang
author_facet Zhang, Jiajun
Cui, Zeyu
Yang, Jiaxi
Zhang, Lei
Jing, Yuheng
Ma, Zeyao
Bai, Tianyi
Wang, Zilei
Liu, Qiang
Wang, Liang
Hui, Binyuan
Lin, Junyang
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2601_13384
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle From Completion to Editing: Unlocking Context-Aware Code Infilling via Search-and-Replace Instruction Tuning
Zhang, Jiajun
Cui, Zeyu
Yang, Jiaxi
Zhang, Lei
Jing, Yuheng
Ma, Zeyao
Bai, Tianyi
Wang, Zilei
Liu, Qiang
Wang, Liang
Hui, Binyuan
Lin, Junyang
Software Engineering
Computation and Language
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.
title From Completion to Editing: Unlocking Context-Aware Code Infilling via Search-and-Replace Instruction Tuning
topic Software Engineering
Computation and Language
url https://arxiv.org/abs/2601.13384