Lune

EMNLP2025顶会

Planning-Aware Code Infilling via Horizon-Length Prediction

Yifeng Ding, Hantian Ding, Shiqi Wang, Qing Sun, Varun Kumar, Zijian Wang

摘要

Fill-in-the-Middle (FIM), or infilling, has become integral to code language models, enabling generation of missing code given both left and right contexts. However, the current FIM training paradigm which performs next-token prediction (NTP) over reordered sequence often leads to models struggling to generate content that aligns well with the surrounding context. We hypothesize that NTP alone is insufficient for models to learn effective planning conditioned on the distant right context, a critical factor for successful code infilling. To overcome this, we propose Horizon-Length Prediction (HLP), a novel training objective that teaches models to predict the number of remaining middle tokens at each step. HLP advances FIM with lookahead planning, enabling models to inherently learn infilling boundaries for arbitrary left and right contexts without relying on dataset-specific post-processing. Our evaluation across different model families and sizes shows that HLP significantly improves FIM performance by up to 24% relatively on diverse benchmarks, across file-level and repository-level. Furthermore, the enhanced planning capability gained through HLP boosts model performance on code reasoning. Importantly, HLP incurs negligible training overhead and no additional inference cost, ensuring its practicality for real-world scenarios. 1 We opt to use PSM setting in this work given our base models DeepSeek-Coder and StarCoder2 were both pre-trained with PSM. We expect that our method is generalizable to SPM setting as well.

问 Lune

几分钟读透这篇 Paper,不用再花一下午。

Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。

可以从这些问题问起

Lune 可以查阅

全文 · 相关的 Paper

获取答案

免费开始,无需绑卡

脉络

  • CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis 引用了 InCoder: A Generative Model for Code Infilling and Synthesis
  • CRUXEval: A Benchmark for Code Reasoning, Understanding and Execution 引用了 CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis
  • RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generation 引用了 CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis
它引用的引用它的从左到右按年份排列,引用越多,位置越高。

它引用的 Paper11

  1. Better & Faster Large Language Models via Multi-token PredictionFabian Gloeckle, Badr Youbi Idrissi, Baptiste Rozière, David Lopez-Paz 等ICML 2024 · 286 次引用
  2. CRUXEval: A Benchmark for Code Reasoning, Understanding and ExecutionAlex Gu, Baptiste Rozière, Hugh James Leather, Armando Solar-Lezama 等ICML 2024 · 270 次引用
  3. CodeGen: An Open Large Language Model for Code with Multi-Turn Program SynthesisErik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu 等ICLR 2023 · 234 次引用
  4. InCoder: A Generative Model for Code Infilling and SynthesisDaniel Fried, Armen Aghajanyan, Jessy Lin, Sida Wang 等ICLR 2023 · 140 次引用
  5. RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and GenerationFengji Zhang, Bei Chen, Yue Zhang, Jacky Keung 等EMNLP 2023 · 110 次引用

相关 Paper

  1. Evaluation of LLMs on Syntax-Aware Code Fill-in-the-Middle TasksLinyuan Gong, Sida Wang, Mostafa Elhoushi, Alvin CheungICML 2024 · 33 次引用
  2. Meet in the Middle: A New Pre-training ParadigmAnh Nguyen, Nikos Karampatziakis, Weizhu ChenNeurIPS 2023 · 29 次引用
  3. Mask-Enhanced Autoregressive Prediction: Pay Less Attention to Learn MoreXialie Zhuang, Zhikai Jia, Jianjin Li, Zhenyu Zhang 等ICML 2025
  4. JumpCoder: Go Beyond Autoregressive Coder via Online ModificationMouxiang Chen, Hao Tian, Zhongxin Liu, Xiaoxue Ren 等ACL 2024 · 4 次引用
  5. Beyond Multi-Token Prediction: Pretraining LLMs with Future SummariesDivyat Mahajan, Sachin Goyal, Badr Youbi Idrissi, Mohammad Pezeshki 等ICLR 2026 · 15 次引用
黄昏的海面,两侧是细线勾勒的悬崖