Code verifiers play a critical role in post-verification for LLM-based code generation, yet existing supervised fine-tuning methods suffer from data scarcity, high failure rates, and poor inference efficiency. While reinforcement learning (RL) offers a promising alternative by optimizing models through execution-driven rewards without labeled supervision, our preliminary results show that naive RL with only functionality rewards fails to generate effective unit tests for difficult branches and samples. We first theoretically analyze showing that branch coverage, sample difficulty, syntactic and functional correctness can be jointly modeled as RL rewards, where optimizing these signals can improve the reliability of unit-test-based verification. Guided by this analysis, we design syntax- and functionality-aware rewards and further propose branch- and sample-difficulty--aware RL using exponential reward shaping and static analysis metrics. With this formulation, CVeDRL achieves state-of-the-art performance with only 0.6B parameters, yielding up to 28.97% higher pass rate and 15.08% higher branch coverage than GPT-3.5, while delivering over $20\times$ faster inference than competitive baselines. Code is available at https://github.com/LIGHTCHASER1/CVeDRL.git
翻译:代码验证器在基于大语言模型的代码生成后验证中扮演着关键角色,然而现有的监督微调方法存在数据稀缺、失败率高和推理效率低下的问题。虽然强化学习通过无需标注监督的执行驱动奖励来优化模型,提供了一种有前景的替代方案,但我们的初步结果表明,仅使用功能奖励的朴素强化学习无法为困难分支和样本生成有效的单元测试。我们首先从理论上分析表明,分支覆盖率、样本难度、语法和功能正确性可以共同建模为强化学习奖励,优化这些信号能够提高基于单元测试的验证的可靠性。在此分析指导下,我们设计了语法和功能感知的奖励,并进一步提出了基于指数奖励塑形和静态分析度量的分支与样本难度感知强化学习。通过这种设计,CVeDRL 仅用 0.6B 参数就实现了最先进的性能,与 GPT-3.5 相比,其通过率最高提升 28.97%,分支覆盖率最高提升 15.08%,同时推理速度比竞争基线快 20 倍以上。代码可在 https://github.com/LIGHTCHASER1/CVeDRL.git 获取。