Bridging Online and Offline RL: Contextual Bandit Learning for Multi-Turn Code Generation

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Chen, Ziru, Chen, Dongdong, Jin, Ruinan, Liang, Yingbin, Xie, Yujia, Sun, Huan
Formato: Preprint
Publicado: 2026
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866911419934441472
author Chen, Ziru
Chen, Dongdong
Jin, Ruinan
Liang, Yingbin
Xie, Yujia
Sun, Huan
author_facet Chen, Ziru
Chen, Dongdong
Jin, Ruinan
Liang, Yingbin
Xie, Yujia
Sun, Huan
contents Recently, there have been significant research interests in training large language models (LLMs) with reinforcement learning (RL) on real-world tasks, such as multi-turn code generation. While online RL tends to perform better than offline RL, its higher training cost and instability hinders wide adoption. In this paper, we build on the observation that multi-turn code generation can be formulated as a one-step recoverable Markov decision process and propose contextual bandit learning with offline trajectories (Cobalt), a new method that combines the benefits of online and offline RL. Cobalt first collects code generation trajectories using a reference LLM and divides them into partial trajectories as contextual prompts. Then, during online bandit learning, the LLM is trained to complete each partial trajectory prompt through single-step code generation. Cobalt outperforms two multi-turn online RL baselines based on GRPO and VeRPO, and substantially improves R1-Distill 8B and Qwen3 8B by up to 9.0 and 6.2 absolute Pass@1 scores on LiveCodeBench. Also, we analyze LLMs' in-context reward hacking behaviors and augment Cobalt training with perturbed trajectories to mitigate this issue. Overall, our results demonstrate Cobalt as a promising solution for iterative decision-making tasks like multi-turn code generation. Our code and data are available at https://github.com/OSU-NLP-Group/cobalt.
format Preprint
id arxiv_https___arxiv_org_abs_2602_03806
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Bridging Online and Offline RL: Contextual Bandit Learning for Multi-Turn Code Generation
Chen, Ziru
Chen, Dongdong
Jin, Ruinan
Liang, Yingbin
Xie, Yujia
Sun, Huan
Machine Learning
Artificial Intelligence
Computation and Language
Software Engineering
Recently, there have been significant research interests in training large language models (LLMs) with reinforcement learning (RL) on real-world tasks, such as multi-turn code generation. While online RL tends to perform better than offline RL, its higher training cost and instability hinders wide adoption. In this paper, we build on the observation that multi-turn code generation can be formulated as a one-step recoverable Markov decision process and propose contextual bandit learning with offline trajectories (Cobalt), a new method that combines the benefits of online and offline RL. Cobalt first collects code generation trajectories using a reference LLM and divides them into partial trajectories as contextual prompts. Then, during online bandit learning, the LLM is trained to complete each partial trajectory prompt through single-step code generation. Cobalt outperforms two multi-turn online RL baselines based on GRPO and VeRPO, and substantially improves R1-Distill 8B and Qwen3 8B by up to 9.0 and 6.2 absolute Pass@1 scores on LiveCodeBench. Also, we analyze LLMs' in-context reward hacking behaviors and augment Cobalt training with perturbed trajectories to mitigate this issue. Overall, our results demonstrate Cobalt as a promising solution for iterative decision-making tasks like multi-turn code generation. Our code and data are available at https://github.com/OSU-NLP-Group/cobalt.
title Bridging Online and Offline RL: Contextual Bandit Learning for Multi-Turn Code Generation
topic Machine Learning
Artificial Intelligence
Computation and Language
Software Engineering
url https://arxiv.org/abs/2602.03806