Abstract
While existing code large language models (code LLMs) exhibit impressive capabilities in code generation, their autoregressive sequential generation inherently lacks reversibility. This limitation hinders them from timely correcting previous missing statements during coding as humans do, often leading to error propagation and suboptimal performance. We introduce JumpCoder, a novel model-agnostic framework that enables human-like online modification and non-sequential generation to augment code LLMs. The key idea behind JumpCoder is to insert new code into the currently generated code when necessary during generation, which is achieved through an auxiliary infilling model that works in tandem with the code LLM. Since identifying the best infill position beforehand is intractable, we adopt an infill-first, judge-later strategy, which experiments with filling at the k most critical positions following the generation of each line, and uses an Abstract Syntax Tree (AST) parser alongside the Generation Model Scoring to effectively judge the validity of each potential infill. Extensive experiments using six state-of-the-art code LLMs across multiple and multilingual benchmarks consistently indicate significant improvements over all baselines.
Introduction: The Irreversibility Limitation
Current Large Language Models (LLMs) for code generation operate primarily on an autoregressive principle: they predict the next token based strictly on the preceding context, moving from left to right. While effective, this creates a major "irreversibility limitation." Unlike human programmers, who frequently "jump back" to initialize a variable, import a library, or correct a logic error in a previous line, standard LLMs cannot modify what they have already written.
If a model misses a critical declaration early in the process, it typically results in a NameError or leads the model to "hallucinate" incorrect logic to compensate for the missing state. Research indicates that for models like CodeLlama, nearly 18.6% of errors on the HumanEval benchmark are due to undefined identifiers. JumpCoder addresses this by introducing a framework for online modification, allowing models to retrospectively insert missing code during the generation process.
The JumpCoder Framework
JumpCoder is a model-agnostic framework that pairs a primary generation model with an auxiliary infilling model. It operates through a three-stage "infill-first, judge-later" pipeline:
1. Hybrid Generation
As the generation model drafts the next line of code, JumpCoder identifies the top-$k$ most "uncertain" positions in the existing code—lines where the model's logit scores were lowest. The auxiliary infilling model (utilizing Fill-In-the-Middle capabilities) then generates potential code insertions for these positions in parallel.
2. The Judging Stage
Because it is computationally intractable to know the perfect infill position in advance, JumpCoder generates multiple candidates and then filters them using two distinct methods:
- AST Parser: An Abstract Syntax Tree parser performs a "hard" check to see if an infill resolves a specific syntax error, such as a missing variable name.
- Generation Model Scoring: For logic-based improvements, the system calculates whether the new insertion increases the overall confidence (logit scores) of the subsequent lines of code.
3. Combination
Once a valid infill is identified and verified, it is integrated into the current code buffer, and the generation model continues from the updated state.
Experimental Results
The researchers evaluated JumpCoder using six state-of-the-art models, including variants of CodeLlama and WizardCoder, across benchmarks like HumanEval, MBPP, and MultiPL-E.
Key findings include:
- Performance Boosts: JumpCoder consistently improved the Pass@1 rate across all tested models. For instance, CodeLlama-7B-Instruct saw an improvement from 36.0% to 39.6% on HumanEval.
- Multilingual Efficacy: The framework proved particularly effective for statically typed languages like Java and C++, where strict declaration requirements often trip up autoregressive models. Pass rates in multilingual benchmarks increased by up to 8.2%.
- Error Mitigation: The system successfully eradicated a significant portion of
NameErrorinstances, demonstrating its ability to catch and fix missing declarations in real-time.
Conclusion and Future Work
JumpCoder demonstrates that breaking the sequential constraints of LLMs can lead to more robust and human-like code generation. While the framework introduces some computational overhead—running approximately 30% slower than standard models—it offers a significant accuracy trade-off without requiring any model retraining.
Future iterations of JumpCoder may expand beyond simple insertions to include the ability to delete or modify existing incorrect lines. Additionally, addressing tokenizer-specific issues (such as those found in StarCoder) will be essential for broader model compatibility.
Summary updated