Route-Align-Verify for Functional Correctness in Code Generation
作者: Erxue Zhou, Jingxiang Meng, Aofan Liu
分类: cs.SE, cs.AI
发布日期: 2026-08-04
💡 一句话要点
提出RAV框架以提升代码生成的功能正确性
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 代码生成 功能正确性 大型语言模型 任务感知 LoRA适应性 执行验证 模块化框架
📋 核心要点
- 现有的代码生成方法在处理异构编程任务时,往往依赖单一的提示策略和直接生成的输出,导致功能正确性难以保证。
- RAV框架通过任务感知的提示路由、对齐的LoRA适应性和执行验证三个阶段,优化了代码生成过程,提升了生成代码的功能正确性。
- 在MBPP基准测试中,RAV的完整管道在清理和完整设置下分别达到了0.8911和0.8520的性能,相较于基线模型分别提升了6.35和9.92个百分点。
📝 摘要(中文)
大型语言模型(LLMs)在代码生成方面取得了显著进展,但在异构编程任务中实现强功能正确性仍然困难。本文提出了RAV,一个轻量级模块化框架,通过三个协调阶段(Route、Align和Verify)来改善代码生成。Route阶段在生成前应用任务感知的提示路由;Align阶段通过对齐的LoRA适应性减少微调提示与推理时提示之间的不匹配;Verify阶段通过执行多个候选输出并与可见公共测试进行对比来选择最终输出。实验结果表明,RAV在MBPP基准测试中表现优异,显著提升了功能正确性。
🔬 方法详解
问题定义:本文旨在解决大型语言模型在代码生成中面临的功能正确性挑战,尤其是在异构编程任务中,现有方法常常无法有效处理多样化的提示和输出。
核心思路:RAV框架通过三个阶段的协调工作,优化了提示的使用、模型的适应性以及最终输出的选择,从而提升代码生成的功能正确性。
技术框架:RAV框架包括三个主要阶段:Route阶段负责任务感知的提示路由,Align阶段通过对齐的LoRA适应性减少提示不匹配,Verify阶段则通过执行候选输出进行验证。
关键创新:RAV的创新之处在于其模块化设计和执行验证机制,使得功能正确性得以在不改变基础模型架构的情况下显著提升。
关键设计:在Align阶段,采用了对齐的LoRA适应性来优化提示,确保微调提示与推理时提示的一致性;在Verify阶段,通过执行多个候选输出并与公共测试进行对比,确保最终选择的输出具备更高的正确性。
🖼️ 关键图片
📊 实验亮点
RAV框架在MBPP基准测试中表现出色,清理设置下达到了0.8911,完整设置下达到了0.8520,相较于基线模型分别提升了6.35和9.92个百分点。实验结果表明,任务感知路由和执行验证的结合显著增强了代码生成的功能正确性。
🎯 应用场景
RAV框架在软件开发、自动化测试和智能编程助手等领域具有广泛的应用潜力。通过提升代码生成的功能正确性,RAV可以帮助开发者更高效地生成高质量代码,减少调试和测试的时间成本,进而推动软件开发的智能化进程。
📄 摘要(原文)
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.