Targeting the problem of improving functional correctness of code generation with a fixed backbone LLM, this paper proposes the lightweight modular RAV framework, consisting of three stages: Route (task-aware prompt routing), Align (prompt-alignment LoRA adaptation), and Verify (execution-based candidate selection), and completes an empirical validation on the MBPP benchmark.
The RAV framework is a lightweight modular solution for optimizing functional correctness in code generation. It can be plugged into existing code generation pipelines without modifying the LLM backbone, and consists of three clearly positioned independent components corresponding to pre-generation, training, and post-generation stages. The pre-generation routing module selects the prompt suited to the current task based on task keywords and docstrings; the alignment module in the training stage reduces the mismatch between prompts and tasks by rewriting prompts according to the routed style; the post-generation verification module selects better generated candidates based on execution scores on public test sets. Together with the accompanying figure below, you can intuitively grasp the stage division of the full RAV pipeline and the arrangement of its modules.
The task-aware prompt routing logic of the Route module, taking its implementation in the MBPP setting as an example, dispatches input tasks into three different prompt styles via lexical and task-structure cues: tasks dense in string processing trigger the string relaxed style, with trigger keywords including substring, palindrome, and other text-processing-related markers; algorithm- or math-oriented tasks trigger the algo relaxed style, with trigger keywords including prime number, greatest common divisor, and other arithmetic patterns; tasks with explicit boundary-case hints and relatively dense test descriptions trigger the edge relaxed style.
The Align module adopts the design of an aligned LoRA adapter, with the core goal of narrowing the distribution mismatch between the prompts used during fine-tuning and those used at inference. Unlike the common practice of training on generic instruction prompts and testing on routed prompts, this method rewrites the training inputs to be exactly consistent with the routed style used at inference, so that the resulting adapter can better fit the prompt mechanism actually used by the whole system.
The complete coordinated workflow of the three modules can be fully defined through formalized steps: first, the routing function maps the raw task to a routed prompt , satisfying ; then the generator , parameterized jointly by the backbone LLM and the optional aligned LoRA adapter , samples one or more sets of candidate programs , where each candidate is sampled from the distribution ; if verification is disabled, the system directly returns the first sampled candidate as the final output; if verification is enabled, the verifier scores each candidate and selects the highest-scoring candidate as the final output, i.e., the final result satisfies .
The study evaluates the RAV framework on the MBPP benchmark under the sanitized and full settings. The full RAV pipeline achieves the best results among all tested configurations, reaching 0.8911 on MBPP Sanitized and 0.8520 on MBPP Full, delivering performance improvements of 6.35 and 9.92 percentage points over the base model, respectively.
Component ablation results show clear differences across two-component combinations: the combination keeping only the Route and Align modules yields very limited improvement over the base model, whereas every two-component combination that includes the Verify module achieves performance gains close to those of the full RAV pipeline.
The interpretation of the experimental results indicates that the role of the Route and Align modules is to generate a candidate pool more favorable for producing correct solutions, and their effects fully materialize only when combined with the Verify module. The core value of routing and alignment adaptation is not to directly improve the quality of a single generation output, but to increase the probability that correct or near-correct candidates appear in the generation pool, after which the Verify module can select a better final program from this higher-quality candidate pool.
The overall test-time inference overhead of the RAV framework can be quantified with a unified formula: let G be the cost of generating a single candidate program and E the cost of executing a single candidate on the public test cases; the framework's overall test-time cost is , where n is the total number of sampled candidate programs. This expression clearly delineates the inference overhead boundary of the framework.
The paper's final core conclusion is that improvements in the functional correctness of code generation can be achieved without modifying the backbone architecture of the LLM itself: by coordinating the task's prompting approach, the model's adaptation logic, and the final output selection mechanism, significant performance gains can be obtained. The paper also notes that future work, through more complete full-factorial ablation experiments, broader benchmark coverage, and the introduction of stronger verification signals, can further clarify the framework's contribution boundaries and generality.