ACECode:一个用于在代码语言模型中对齐代码效率与正确性的强化学习框架
ACECode: A Reinforcement Learning Framework for Aligning Code Efficiency and Correctness in Code Language Models
AI总结:
本文提出基于强化学习的微调框架ACECode,通过结合actor CodeLLM生成代码、计算源自执行反馈的免训练奖励信号以及PPO算法,在无需预定义测试用例的前提下同时优化代码的效率与正确性,显著提升了多个SOTA CodeLLMs的pass@1并降低了运行时间。
摘要:
CodeLLMs在软件工程任务中展现出了显著的进步。然而,尽管这些模型能够生成功能正确的代码,但它们生成的代码在运行时效率方面往往低下。这种低效在资源受限的环境中尤为成问题,会影响软件的性能和可持续性。\n现有的优化CodeLLMs代码效率的方法(如SOAP和PIE)存在一定的局限性。SOAP需要兼容的执行环境和预定义的测试用例来进行迭代代码修改,而PIE侧重于指令微调,虽然提高了效率但损害了正确性。这些缺陷凸显了对一种微调框架的需求,该框架能同时优化效率和正确性,且不依赖预定义的测试用例或特定的执行环境。\n为了弥补这一差距,我们引入了ACECode,这是一个基于强化学习的微调框架,旨在使CodeLLMs与效率和正确性的双重目标保持一致。ACECode结合了三个关键步骤:(1) 使用actor CodeLLM生成代码;(2) 为每个生成的代码计算源自代码执行反馈的免训练奖励信号;(3) 通过近端策略优化(PPO)算法优化CodeLLM。该奖励信号能够在无需人工标注的情况下对效率和正确性进行联合评估。\n我们通过微调四个SOTA(state-of-the-art)CodeLLMs,并将它们的代码与三个基线进行比较:原始、指令微调和PIE微调的CodeLLMs,来评估ACECode。大量实验结果表明,ACECode在所有CodeLLMs中相对于所有基线都显著提高了生成代码的效率和正确性。具体而言,使用ACECode微调的CodeLLMs将pass@1提高了1.84%至14.51%,并且在65%至72%的案例中与原始CodeLLMs相比减少了运行时间。
英文摘要:
CodeLLMs have demonstrated remarkable advancements in software engineering tasks. However, while these models can generate functionally correct code, they often produce code that is inefficient in terms of runtime. This inefficiency is particularly problematic in resource-constrained environments, impacting software performance and sustainability. Existing approaches for optimizing code efficiency for CodeLLMs like SOAP and PIE exhibit certain limitations. SOAP requires a compatible execution environment and predefined test cases for iterative code modification, while PIE focuses on instruction tuning, improving efficiency but compromising correctness. These shortcomings highlight the need for a fine-tuning framework that optimizes both efficiency and correctness without relying on predefined test cases or specific execution environments. To bridge this gap, we introduce ACECode, a reinforcement learning-based fine-tuning framework that aligns CodeLLMs with dual objectives of efficiency and correctness. ACECode combines three key steps: (1) generating code with an actor CodeLLM, (2) calculating a training-free reward signal derived from code execution feedback for each generated code, and (3) optimizing the CodeLLM via Proximal Policy Optimization (PPO) algorithm. This reward signal enables joint assessment of efficiency and correctness without manual labeling. We evaluate ACECode by fine-tuning four SOTA (state-of-the-art) CodeLLMs and comparing their code with three baselines: original, instruction-tuned, and PIE-tuned CodeLLMs. Extensive experiment results suggest that \tool{} significantly improves the efficiency and correctness of generated code against all baselines for all CodeLLMs. Specifically, CodeLLMs fine-tuned with ACECode improve pass@1 by 1.84% to 14.51% and reduce runtime in 65% to 72% of cases compared to original CodeLLMs.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。