通过动态增加单元测试数量,提升代码生成的奖励信号质量。
Dynamic Scaling of Unit Tests for Code Reward Modeling
- 动态调整单元测试数量,随问题难度自动增减。
- 在HumanEval Plus上使Llama3-8B性能提升18.43%。
- 提出轻量级测试生成器CodeRM-8B,兼顾效率与质量。
当前大语言模型在复杂推理任务(如代码生成)中常首次尝试即出错。已有研究通过生成多个候选解并用LLM生成的单元测试验证,以执行结果作为奖励信号识别正确解。然而,由于LLM总是自信地犯错,单元测试不可靠,导致奖励信号质量下降。我们观察到扩大解的数量可提升模型性能,进而探索扩展单元测试对奖励信号的影响。初步实验显示,单元测试数量与奖励信号质量呈正相关,且在更难题目中收益更显著。基于此,我们提出CodeRM-8B——一个轻量高效的单元测试生成器,支持高质高效测试扩展。同时设计动态扩缩机制,根据问题难度自适应调节测试数量。实验表明,该方法在三个基准上显著提升性能,例如在HumanEval Plus上使Llama3-8B提升18.43%,GPT-4o-mini提升3.42%。
原文摘要 · Abstract (English)
Current large language models (LLMs) often struggle to produce accurate responses on the first attempt for complex reasoning tasks like code generation. Prior research tackles this challenge by generating multiple candidate solutions and validating them with LLM-generated unit tests. The execution results of unit tests serve as reward signals to identify correct solutions. As LLMs always confidently make mistakes, these unit tests are not reliable, thereby diminishing the quality of reward signals. Motivated by the observation that scaling the number of solutions improves LLM performance, we explore the impact of scaling unit tests to enhance reward signal quality. Our pioneer experiment reveals a positive correlation between the number of unit tests and reward signal quality, with greater benefits observed in more challenging problems. Based on these insights, we propose CodeRM-8B, a lightweight yet effective unit test generator that enables efficient and high-quality unit test scaling. Additionally, we implement a dynamic scaling mechanism that adapts the number of unit tests based on problem difficulty, further improving efficiency. Experimental results show that our approach significantly improves performance across various models on three benchmarks (e.g., with gains of 18.43% for Llama3-8B and 3.42% for GPT-4o-mini on HumanEval Plus).
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。