arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2602.03806cs.LGcs.AIcs.CLcs.SE
收藏

弥合在线与离线强化学习:多轮代码生成的上下文老虎机学习

COBALT: Contextual Bandit Learning with Offline Trajectories for Multi-Turn Code Generation

The Ohio State University(俄亥俄州立大学);Microsoft(微软)

Ziru Chen, Dongdong Chen, Ruinan Jin, Yingbin Liang, Yujia Xie, Huan Sun

AI总结:

Cobalt通过结合在线和离线强化学习,提出一种新的上下文老虎机学习方法,用于多轮代码生成任务,显著提升了模型性能并缓解了奖励黑客问题。

摘要:

最近,训练大语言模型(LLMs)以强化学习(RL)在现实任务中的应用引起了广泛关注,例如多轮代码生成。虽然在线RL在性能上优于离线RL,但其较高的训练成本和不稳定性阻碍了广泛应用。在本文中,我们基于多轮代码生成可以被建模为一步可恢复马尔可夫决策过程的观察,提出了一种新的方法:基于离线轨迹的上下文老虎机学习(Cobalt),该方法结合了在线和离线RL的优点。Cobalt首先使用参考LLM收集代码生成轨迹,并将它们划分为部分轨迹作为上下文提示。然后,在在线老虎机学习过程中,LLM被训练通过单步代码生成来完成每个部分轨迹提示。Cobalt在基于GRPO和VeRPO的两个多轮在线RL基线基础上表现更优,并在LiveCodeBench上显著提升了R1-Distill 8B和Qwen3 8B的Pass@1分数,分别提高了9.0和6.2个绝对分数。此外,我们分析了LLM的上下文奖励黑客行为,并通过扰动轨迹增强Cobalt训练以缓解这一问题。总体而言,我们的结果表明Cobalt是多轮代码生成等迭代决策任务的有前途的解决方案。我们的代码和数据可在https://github.com/OSU-NLP-Group/cobalt上获得。

英文摘要:

Training large language models (LLMs) for multi-turn code generation typically relies on online reinforcement learning (RL), in which models learn from repeatedly generated online rollouts. Although effective, online RL can be costly and unstable. In this paper, we present contextual bandit learning with offline trajectories (COBALT), a simple method that reuses offline multi-turn trajectories to efficiently train LLMs for multi-turn code generation. Building on the observation that multi-turn code generation is a one-step recoverable Markov decision process, COBALT first collects code generation trajectories using a reference LLM and divides them into partial trajectories. Then, during online bandit learning, the LLM is trained to complete each partial trajectory through single-step code generation. On LiveCodeBench, COBALT substantially improves R1-Distill 8B and Qwen3 8B by up to 9.0 and 6.2 absolute Pass@1 points and matches the performance of two multi-turn online RL baselines using GRPO and VeRPO. We also perform a perturbation-based analysis of in-context reward hacking and show that Cobalt can improve robustness to misleading execution feedback. Overall, our results demonstrate that Cobalt is a promising solution for multi-turn code generation. Our code and data are available at https://github.com/OSU-NLP-Group/cobalt.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑