arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2410.03103cs.LGcs.CLcs.SE
收藏

基于视界长度预测的具备规划感知能力的代码填充

Planning-Aware Code Infilling via Horizon-Length Prediction

University of Illinois Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校);AWS AI Labs(AWS人工智能实验室);Meta

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

AI总结:

针对当前代码中间填充(FIM)训练范式下模型难以结合上下文生成匹配内容的问题,提出视界长度预测(HLP)训练目标,通过前瞻规划提升填充效果,且训练开销低、无额外推理成本。

摘要:

中间填充(Fill-in-the-Middle,简称FIM)又称代码补全填充,已成为代码语言模型不可或缺的功能,可在给定左右上下文的情况下生成缺失代码。然而,当前FIM训练范式对重排序列执行下一词元预测(next-token prediction,简称NTP),往往导致模型难以生成与周围上下文高度契合的内容。我们假设,仅靠NTP不足以让模型学习到基于远距离右侧上下文的有效规划,而这是实现成功代码填充的关键因素。为解决这一问题,我们提出视界长度预测(Horizon-Length Prediction,简称HLP)——一种全新的训练目标,指导模型在每一步预测剩余的中间词元数量。HLP通过前瞻规划改进FIM,使模型能够固有地学习任意左右上下文下的填充边界,无需依赖特定于数据集的后处理。我们在不同模型家族和规模上开展的评估显示,HLP在文件级和仓库级的各类基准上,将FIM性能相对提升最高达24%。此外,通过HLP获得的增强规划能力还提升了模型在代码推理任务上的表现。重要的是,HLP带来的训练开销可忽略不计,且不会增加推理成本,确保了其在真实场景中的实用性。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑