Planning-Aware Code Infilling via Horizon-Length Prediction

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Ding, Yifeng, Ding, Hantian, Wang, Shiqi, Sun, Qing, Kumar, Varun, Wang, Zijian
Format: Preprint
Veröffentlicht: 2024
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866915625924820992
author Ding, Yifeng
Ding, Hantian
Wang, Shiqi
Sun, Qing
Kumar, Varun
Wang, Zijian
author_facet Ding, Yifeng
Ding, Hantian
Wang, Shiqi
Sun, Qing
Kumar, Varun
Wang, Zijian
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2410_03103
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Planning-Aware Code Infilling via Horizon-Length Prediction
Ding, Yifeng
Ding, Hantian
Wang, Shiqi
Sun, Qing
Kumar, Varun
Wang, Zijian
Machine Learning
Computation and Language
Software Engineering
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.
title Planning-Aware Code Infilling via Horizon-Length Prediction
topic Machine Learning
Computation and Language
Software Engineering
url https://arxiv.org/abs/2410.03103