Reproduce “From Completion to Editing: Unlocking Context-Aware Code Infilling via Search-and-Replace Instruction Tuning” on OpenResearch

Turn your favorite coding agents into research agents that review literature, develop hypotheses, and run experiments.

Universal app for Apple silicon and Intel. Requires macOS 11 or later.

About this paper

Jiajun Zhang, Zeyu Cui, Jiaxi Yang, Lei Zhang, Yuheng Jing, Zeyao Ma, Tianyi Bai, Zilei Wang and 4 more

The paper introduces Search-and-Replace Infilling (SRI), a new paradigm for code completion that reframes it as context-aware micro-editing, generating explicit 'SEARCH' and 'REPLACE' blocks. This approach, implemented in Alibaba's Qwen3-Coder, enables large language models to correct contextual errors and resist code injection attacks while maintaining competitive inference speeds.

Key insights

  • The structured search-and-replace prompt format naturally aligns with the instruction-following priors of Chat LLMs, enabling them to perform FIM tasks effectively without performance degradation.
  • SRI leverages the safety alignment of Chat LLMs to drastically improve resistance to code injection attacks, a critical security vulnerability for traditional FIM models.
  • The framework enables true context-aware editing, allowing models to identify and rectify inconsistencies or errors in the surrounding code, going beyond static infilling.

Summary by alphaXiv.

Tip: change arxiv.org to autoarxiv.org in any arXiv abstract link to open the paper here.