通过三阶段框架提升代码生成的正确性,无需修改模型结构
Route-Align-Verify for Functional Correctness in Code Generation

- 分三步优化:任务路由、提示对齐、执行验证
- 在MBPP数据集上准确率提升至0.8911(净化版)
- 适合追求高可靠性代码生成的开发者使用
大型语言模型在代码生成方面取得显著进展,但在异构编程任务中实现强功能性正确性仍具挑战。本文提出RAV轻量级模块化框架,通过三个协同阶段改进固定主干模型的代码生成:路由阶段在生成前应用任务感知提示路由;对齐阶段通过适配的LoRA减少微调提示与推理时提示的不匹配;验证阶段通过执行多个候选输出与公开测试用例对比选择最终结果。在MBPP基准下,完整RAV流程在净化设置和全设置上分别达到0.8911和0.8520的准确率,较基线模型分别提升6.35和9.92个百分点。组件消融实验表明,任务感知路由与对齐适应在结合执行验证后效果显著增强。额外的鲁棒性与污染分析支持结果可靠性。总体表明,无需修改主干架构,仅通过联合优化提示方式、模型适应策略与输出选择机制,即可显著提升代码生成的功能正确性。
原文摘要 · Abstract (English)
Large language models (LLMs) have substantially improved code generation, yet achieving strong functional correctness remains difficult, especially for heterogeneous programming tasks where a single prompting strategy and a single directly generated output are often insufficient. In this paper, we present RAV, a lightweight and modular framework that improves code generation with a fixed backbone model through three coordinated stages: Route, which applies task-aware prompt routing before generation; Align, which reduces the mismatch between fine-tuning prompts and inference-time prompts through aligned LoRA adaptation; and Verify, which selects the final output by executing multiple candidates against visible public tests. We evaluate RAV on the MBPP benchmark under both the sanitized and full settings. The complete RAV pipeline achieves the best performance among all evaluated configurations, reaching 0.8911 on MBPP Sanitized and 0.8520 on MBPP Full. Compared with the base model, these results represent improvements of 6.35 and 9.92 percentage points, respectively. Component-wise ablation experiments further show that task-aware routing and aligned adaptation become substantially more effective when combined with execution-based verification. Additional robustness and contamination analyses support the reliability of the observed improvements. Overall, the results indicate that functional correctness in code generation can be meaningfully improved without modifying the backbone architecture, by jointly optimizing how tasks are prompted, how the model is adapted, and how final outputs are selected.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。