一句话:提出 RLAIF 框架,训练 Student 智能体迭代精化自然语言规约,从而提升 LLM 代码生成的正确率。
LLM 代码生成在复杂算法逻辑与边界情形上仍易出错,而迭代式自我精化常陷入重复失败循环,因为模型难以独立跳出自身的逻辑盲区。本文提出一种基于 AI 反馈的强化学习(RLAIF)框架,核心洞见是规约本身可以借助 LLM 自身输出的反馈被迭代精化,形成自改进回路;这与以往把规约视为静态输入的做法不同。方法上不更新基座模型参数:专有 LLM 通过 API 充当 Worker,另有 Tutor 与合成测试生成器提供监督与奖励信号,三者均由同一模型实例化,学习能力完全集中在较小的可训练 Student 智能体上,由它学习如何修改自然语言规约以引导生成。作者在 LiveCodeBench 与 HumanEvalPlus 上以 200 道题、Qwen 2.5-14B-Instruct 作 Student、GPT-4o-mini 扮演其余角色进行评估,pass@1 相对提升分别为 3.2%(64.0% vs. 62.0%)与 1.1%(96.0% vs. 95.0%)。
The use of Large Language Models (LLMs) for code generation has advanced rapidly, yet current systems often struggle with complex algorithmic logic and edge cases. Standard methods for improving code generation, such as iterative self-refinement, often cause repetitive failure cycles, as models cannot independently escape their own logical blind spots. To address this gap, we propose a novel Reinforcement Learning from AI Feedback (RLAIF) framework. Our key insight is that specifications can be iteratively refined by leveraging feedback from the LLM's own outputs, creating a self-improving loop. This approach contrasts with prior methods that treat specifications as static inputs. Rather than updating the parameters of the base model, a proprietary LLM (the Worker) is accessed via API, while a smaller, trainable Student agent learns to guide generation by modifying natural language specifications. A Tutor agent supervises these refinements, ensuring they are precise and actionable, and provides a reward signal driven by failures identified by a synthetic test generator. Crucially, the Worker, Tutor, and Test Generator roles are all instantiated using the same proprietary model, isolating the learning capacity entirely within the Student agent. We evaluate our approach on N = 200 problems using a Qwen 2.5-14B-Instruct Student and a GPT-4o-mini model fulfilling the Worker, Tutor, and Test Generator roles on the LiveCodeBench and HumanEvalPlus benchmarks. Our method achieves relative pass@1 improvements of 3.2% on LiveCodeBench (64.0% vs. 62.0%) and 1.1% on HumanEvalPlus (96.0% vs. 95.0%).