# Multi-Turn Code Generation Through Single-Step Rewards

단일 단계 보상을 통한 다중 턴 코드 생성

Jain, Arnav Kumar, Gonzalez-Pumariega, Gonzalo, Chen, Wayne, Rush, Alexander M, Zhao, Wenting, Choudhury, Sanjiban · arXiv · 2025년 2월 27일

- **연구 문제** 다중 턴 코드 생성에서 실행 피드백을 활용하면서도 복잡한 다단계 강화학습을 피하는 방법이 필요합니다.
- **연구 방법** µCODE는 코드 생성을 one-step recoverable MDP로 보고, 단일 단계 보상으로 검증기와 생성기를 반복 학습합니다.
- **주요 결과** 원문 표 1 기준 µCODE의 1B 모델 BoN@5는 MBPP 51.1, HumanEval 41.5를 기록했습니다.

## 다중 턴 코드 생성의 어려움

코드 생성 모델은 실행 오류를 보고 여러 차례 코드를 고쳐야 정답에 도달하는 경우가 많습니다. 원문은 프롬프트만으로는 제한된 문맥 안에서 가능한 모든 오류에서 회복하는 법을 가르칠 수 없다고 지적합니다. 기존 접근은 단일 턴 학습과 다중 턴 강화학습으로 나뉘며, 다중 턴 강화학습은 희소한 학습 신호 때문에 비효율적이라고 설명됩니다. 이 논문은 이 문제를 단일 단계 보상만으로 다루는 방법을 제안합니다.

## µCODE의 학습 반복과 단일 단계 보상

µCODE는 코드 생성을 one-step recoverable MDP로 보고, 임의의 중간 상태에서 정답 코드를 한 턴에 복구할 수 있다고 가정합니다. 학습은 현재 생성기로 다중 턴 환경에서 롤아웃 데이터를 모으고, 누적 데이터로 검증기 R\_ϕ를 학습하는 순서로 진행됩니다. 이후 학습된 검증기와 오라클 보상을 결합한 지역 탐색 전문가가 각 프롬프트의 최적 후보를 골라 데이터를 재라벨링하며, 생성기는 이 전문가 데이터로 미세조정됩니다. 이 과정은 강화학습 대신 모방 학습 형태로 재구성됩니다.

![Figure 1: (a) We define the task of multi-turn code generation where for an initial problem x, the generator πθ provides a solution y1. This solution is evalua…](https://refivu.com/papers/3a44621c-ecca-42d4-9e3c-2a7f14a7cf58/figures/figure-8c1a29267117c4c37bca943e49d3ee79.png?thumb=512)

**Figure 1** . (a) We define the task of multi-turn code generation where for an initial problem x, the generator πθ provides a solution y1. This solution is evaluated with the public test to get execution feedback o1. At a turn t, the generator is conditioned on the history to generate solution yt ∼ πθ(.\|x, y\<t, o\<t). The rollout ends when the turn limit is reached or the public tests pass upon which the solution is executed on private tests. Since, the agents can generate the optimal solution at any turn, this is a 1-step recoverable process. (b) Training loop of our method µCODE – which comprises of a generator and a learned verifier. During each iteration, rollouts are collected using πθ and we train a verifier Rϕ to rank candidate solutions for a prompt. The verifier Rϕ is then used to construct a local expert and relabel the collected rollouts. Lastly, the generator is fine-tuned with this expert dataset.

[원문](https://arxiv.org/abs/2502.20380v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jain, Arnav Kumar, Gonzalez-Pumariega, Gonzalo, Chen, Wayne, Rush, Alexander M, Zhao, Wenting, Choudhury, Sanjiban · Multi-Turn Code Generation Through Single-Step Rewards · 원문 그림 인용 · 원본 PDF 2쪽에서 그림 영역을 추출했습니다.

![Table 2: Comparison of using learned verifier (LV) and relabeling with one-step recoverability (One-Step) with the 1B-sized model. We observe that FT with the…](https://refivu.com/papers/3a44621c-ecca-42d4-9e3c-2a7f14a7cf58/figures/figure-15f40ca36b74df2fe0c4b69683dbb997.png?thumb=512)

**Table 2** . Comparison of using learned verifier (LV) and relabeling with one-step recoverability (One-Step) with the 1B-sized model. We observe that FT with the learned verifierRFTL Vperforms better than FT with the oracle verifier scores RFT. Moreover, µCODE performs best when from both verifiers are used for relabeling.

[원문](https://arxiv.org/abs/2502.20380v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jain, Arnav Kumar, Gonzalez-Pumariega, Gonzalo, Chen, Wayne, Rush, Alexander M, Zhao, Wenting, Choudhury, Sanjiban · Multi-Turn Code Generation Through Single-Step Rewards · 원문 그림 인용 · 원본 PDF 6쪽에서 그림 영역을 추출했습니다.

## 검증기 손실과 추론 시 다중 턴 탐색

검증기는 프롬프트와 현재 코드 해법을 입력받아 스칼라 점수를 출력합니다. 원문은 이진 교차 엔트로피 손실(BCE)과 Bradley Terry 손실(BT) 두 가지를 비교하며, BT 손실은 정답과 오답 쌍의 점수 차이를 키우는 방식입니다. 추론 시에는 생성기가 턴마다 N개의 후보를 만들고, 검증기가 가장 높은 후보를 골라 공개 테스트 실행 피드백을 얻습니다. 원문은 공개 테스트 통과 여부를 우선하고 학습된 검증기로 동점을 깨는 혼합 방식이 가장 좋았다고 보고합니다.

![Table 3: Comparing BoN with different ways of picking solutions at each turn for multi-turn BoN search using the 1B sized model. The hierarchical approach of u…](https://refivu.com/papers/3a44621c-ecca-42d4-9e3c-2a7f14a7cf58/figures/figure-49b52c79f55008cde99fdfd967084b48.png?thumb=512)

**Table 3** . Comparing BoN with different ways of picking solutions at each turn for multi-turn BoN search using the 1B sized model. The hierarchical approach of using public test and learned veri- fier (PT+LV) outperforms picking solutions with only using either public tests (PT) or the learned verifier (LV). The best performance for each dataset and model-size is highlighted in bold and similar performances (within 1%) are underlined.

[원문](https://arxiv.org/abs/2502.20380v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jain, Arnav Kumar, Gonzalez-Pumariega, Gonzalo, Chen, Wayne, Rush, Alexander M, Zhao, Wenting, Choudhury, Sanjiban · Multi-Turn Code Generation Through Single-Step Rewards · 원문 그림 인용 · 원본 PDF 6쪽에서 그림 영역을 추출했습니다.

![Figure 2: Compares the BoN performance at each turn (with 6 turns) on HumanEval, MBPP datasets. We also present results on a partially observable version of MB…](https://refivu.com/papers/3a44621c-ecca-42d4-9e3c-2a7f14a7cf58/figures/figure-2d57bb4273eb9e195d7c0439bf14f113.png?thumb=512)

**Figure 2** . Compares the BoN performance at each turn (with 6 turns) on HumanEval, MBPP datasets. We also present results on a partially observable version of MBPP where we remove the public tests from the prompt to test the efficacy of methods at incorporating execution feedback– MBPP (POMDP). We observe that all methods improve performance with more turns on MBPP and HumanEval datasets. However, on MBPP (POMDP) the performance drops at first turn and µCODE closes the gap with performance on MBPP compared to the baselines demonstrating its ability to incorporate execution feedback to improve code solutions at each turn.

[원문](https://arxiv.org/abs/2502.20380v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jain, Arnav Kumar, Gonzalez-Pumariega, Gonzalo, Chen, Wayne, Rush, Alexander M, Zhao, Wenting, Choudhury, Sanjiban · Multi-Turn Code Generation Through Single-Step Rewards · 원문 그림 인용 · 원본 PDF 7쪽에서 그림 영역을 추출했습니다.

![Figure 3: Test-time scaling with different values of candidate so- lutions N at each turn. The candidate solutions are obtained from the 1B-sized generator of…](https://refivu.com/papers/3a44621c-ecca-42d4-9e3c-2a7f14a7cf58/figures/figure-94904786aa4ecd1dccd9ea77e4a4fade.png?thumb=512)

**Figure 3** . Test-time scaling with different values of candidate so- lutions N at each turn. The candidate solutions are obtained from the 1B-sized generator of µCODE. We observe that the BoN per- formance improves with larger values of N on both datasets.

[원문](https://arxiv.org/abs/2502.20380v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jain, Arnav Kumar, Gonzalez-Pumariega, Gonzalo, Chen, Wayne, Rush, Alexander M, Zhao, Wenting, Choudhury, Sanjiban · Multi-Turn Code Generation Through Single-Step Rewards · 원문 그림 인용 · 원본 PDF 7쪽에서 그림 영역을 추출했습니다.

![Figure 4: Comparison between BCE and BT loss function for train- ing the verifier. We train the verifiers on samples generated by the base model (Llama-3.2-1B-…](https://refivu.com/papers/3a44621c-ecca-42d4-9e3c-2a7f14a7cf58/figures/figure-ab8606d957b288a9c4f6756875e60660.png?thumb=512)

**Figure 4** . Comparison between BCE and BT loss function for train- ing the verifier. We train the verifiers on samples generated by the base model (Llama-3.2-1B-Instruct). The learned verifier then ranks the candidate solutions from base model and the BoN per- formance of selected solution is reported. The verifier trained with BT loss performs better increasing value of N.

[원문](https://arxiv.org/abs/2502.20380v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jain, Arnav Kumar, Gonzalez-Pumariega, Gonzalo, Chen, Wayne, Rush, Alexander M, Zhao, Wenting, Choudhury, Sanjiban · Multi-Turn Code Generation Through Single-Step Rewards · 원문 그림 인용 · 원본 PDF 8쪽에서 그림 영역을 추출했습니다.

## 일단계 복구 가능성과 성능 상한

원문은 최적 정책의 이득 함수가 −1과 0 사이로 제한되는 경우를 one-step recoverable MDP로 정의합니다. 코드 생성에서는 최적 정책이 프롬프트에만 의존하므로 이 조건을 만족한다고 논증합니다. 정리 3.2는 N번의 µCODE 반복 후 최소 하나의 정책이 J(π\*) − J(π) ≤ O(T(ϵ + γ(N)))를 만족한다고 주장하며, 여기서 ϵ은 실현 가능성 오차이고 γ(N)은 평균 후회입니다. 이 상한은 위 가정을 전제로 한 결과입니다.

## 주요 비교 결과

Llama-3.2-1B-Instruct 기반 µCODE는 N=1에서 MBPP 37.9, HumanEval 35.4를, BoN@5에서 MBPP 51.1, HumanEval 41.5를 기록했다고 원문 표 1에 보고됩니다. 같은 표에서 8B 모델의 CodeContests BoN@5 점수는 16.3입니다. Qwen-2.5-1.5B-Instruct 추가 실험에서는 BoN@5가 MBPP 63.1, HumanEval 74.0입니다. 이 수치들은 각 표에 정의된 기반 모델과 측정 조건에서 얻은 결과입니다.

![Table 1: Comparison of our method µCODE with baselines across MBPP, HumanEval, and CodeContests datasets. N = 1denotes generating solutions with 0 temperature.…](https://refivu.com/papers/3a44621c-ecca-42d4-9e3c-2a7f14a7cf58/figures/figure-2a243fb21c65346fbacf161c8292a61d.png?thumb=512)

**Table 1** . Comparison of our method µCODE with baselines across MBPP, HumanEval, and CodeContests datasets. N = 1denotes generating solutions with 0 temperature. The Best-of-N (BoN) accuracy is computed with N = 5 candidate solutions at each where the public tests and learned verifier are used for selection. We observe that µCODE outperforms competing methods based on Llama-3.2-1B-Instruct and Llama-3.1-8B-Instruct models. The best performance for each dataset and model-sized is highlighted in bold and similar performances (within 1%) are underlined.

[원문](https://arxiv.org/abs/2502.20380v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jain, Arnav Kumar, Gonzalez-Pumariega, Gonzalo, Chen, Wayne, Rush, Alexander M, Zhao, Wenting, Choudhury, Sanjiban · Multi-Turn Code Generation Through Single-Step Rewards · 원문 그림 인용 · 원본 PDF 5쪽에서 그림 영역을 추출했습니다.

![Table 4: Comparison of our method µCODE with baselines across MBPP, HumanEval using the Qwen-2.5-1.5B-Instruct model](https://refivu.com/papers/3a44621c-ecca-42d4-9e3c-2a7f14a7cf58/figures/figure-ce8b26be09003d876c402e2c704903f2.png?thumb=512)

**Table 4** . Comparison of our method µCODE with baselines across MBPP, HumanEval using the Qwen-2.5-1.5B-Instruct model.

[원문](https://arxiv.org/abs/2502.20380v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jain, Arnav Kumar, Gonzalez-Pumariega, Gonzalo, Chen, Wayne, Rush, Alexander M, Zhao, Wenting, Choudhury, Sanjiban · Multi-Turn Code Generation Through Single-Step Rewards · 원문 그림 인용 · 원본 PDF 14쪽에서 그림 영역을 추출했습니다.

## 범위와 한계

저자들은 실험 모델이 최대 8B 규모였고 MBPP 학습 세트가 374개 문제에 그쳐 결론이 더 큰 모델이나 다른 언어로 일반화되지 않을 수 있다고 밝힙니다. 따라서 이 결과는 Python 데이터셋과 제시된 모델 규모에서의 근거로 읽어야 합니다.

## 논문 정보

- **저자**: Jain, Arnav Kumar, Gonzalez-Pumariega, Gonzalo, Chen, Wayne, Rush, Alexander M, Zhao, Wenting, Choudhury, Sanjiban
- **학회·저널**: arXiv · 프리프린트
- **최초 공개일**: 2025년 2월 27일
- **등록일**: 2026년 10월 29일
- **수정일**: 2025년 6월 27일
- **버전**: v2
- **arXiv**: 2502.20380
- **원문 이용 조건**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **제공 범위**: 논문 정보, 해설, 허용된 원문 그림

[논문 원문 ↗](https://arxiv.org/abs/2502.20380v2) · [원문 PDF ↗](https://arxiv.org/pdf/2502.20380v2)

AI 해설은 논문 원문과 별개의 설명이며 오류가 있을 수 있습니다. 원문과 그림은 각 출처의 이용 조건과 따로 표시된 권리를 따릅니다.

## 초록

We address the problem of code generation from multi-turn execution feedback. Existing methods either generate code without feedback or use complex, hierarchical reinforcement learning to optimize multi-turn rewards. We propose a simple yet scalable approach, $\\mu$Code, that solves multi-turn code generation using only single-step rewards. Our key insight is that code generation is a one-step recoverable MDP, where the correct code can be recovered from any intermediate code state in a single turn. $\\mu$Code iteratively trains both a generator to provide code solutions conditioned on multi-turn execution feedback and a verifier to score the newly generated code. Experimental evaluations show that our approach achieves significant improvements over the state-of-the-art baselines. We provide analysis of the design choices of the reward models and policy, and show the efficacy of $\\mu$Code at utilizing the execution feedback. Our code is available at https://github.com/portal-cornell/muCode.

## 원문 인용

Jain, Arnav Kumar, Gonzalez-Pumariega, Gonzalo, Chen, Wayne, Rush, Alexander M, Zhao, Wenting, Choudhury, Sanjiban (2025). Multi-Turn Code Generation Through Single-Step Rewards. arXiv:2502.20380v2. https://arxiv.org/abs/2502.20380v2

**BibTeX**

```
@misc{kumar2025multi,
  title = {{Multi-Turn Code Generation Through Single-Step Rewards}},
  author = {Jain, Arnav Kumar and Gonzalez-Pumariega, Gonzalo and Chen, Wayne and Rush, Alexander M and Zhao, Wenting and Choudhury, Sanjiban},
  year = {2025},
  eprint = {2502.20380},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.20380v2}
}
```

## 이 논문의 용어

- [HumanEval](https://refivu.com/terms/3c3dbcadfdda-humaneval)
- [MBPP](https://refivu.com/terms/717e657dd0b2-mbpp)
- [advantage function](https://refivu.com/terms/451ef9a0779f-advantage-function)
- [binary cross-entropy loss](https://refivu.com/terms/e6ec2f1d9bdf-binary-cross-entropy-loss)
- [DAGGER](https://refivu.com/terms/ffb47eca8ece-dagger)
- [expert iteration](https://refivu.com/terms/a264757a33d4-expert-iteration)
- [RFT](https://refivu.com/terms/31867cf09430-rft)
- [CodeContests](https://refivu.com/terms/9a8db31b5de7-codecontests)
- [performance difference lemma](https://refivu.com/terms/7701ec38382b-performance-difference-lemma)
- [public tests](https://refivu.com/terms/4388dde1d2a9-public-tests)

## 다른 논문 해설

- [Hardware and Software Platform Inference](https://refivu.com/papers/6781f817-b239-4485-abd3-92cc8cd29db4-hardware-and-software-platform-inference.md)
- [any4: Learned 4-bit Numeric Representation for LLMs](https://refivu.com/papers/7f8c7c0f-5cbf-497b-af22-9a5935d53aea-any4-learned-4-bit-numeric-representation-for-llms.md)
- [LaCache: Ladder-Shaped KV Caching for Efficient Long-Context Modeling of Large Language Models](https://refivu.com/papers/ab877a62-577c-4a9d-a2f5-5b6f0f04d0cb-lacache-ladder-shaped-kv-caching-for-efficient-long.md)
- [Selective Prompt Anchoring for Code Generation](https://refivu.com/papers/be59e15d-0126-4b8d-bbec-7db69f8d7ea5-selective-prompt-anchoring-for-code-generation.md)
- [Automatically Interpreting Millions of Features in Large Language Models](https://refivu.com/papers/6b0e4959-2567-4ba6-b0f9-04422e4af10b-automatically-interpreting-millions-of-features-in-large.md)
- [Pivoting Factorization: A Compact Meta Low-Rank Representation of Sparsity for Efficient Inference in Large Language Models](https://refivu.com/papers/ccf0a44e-f28b-4762-9dec-55d3069d68a9-pivoting-factorization-a-compact-meta-low-rank.md)
- [Residual Matrix Transformers: Scaling the Size of the Residual Stream](https://refivu.com/papers/649ad69b-40d7-44c6-8c92-55c66fc6bd14-residual-matrix-transformers-scaling-the-size-of-the.md)
- [Scalable Non-Equivariant 3D Molecule Generation via Rotational Alignment](https://refivu.com/papers/2cfa5006-f3bf-4410-9fa9-3ebad35af6d0-scalable-non-equivariant-3d-molecule-generation-via.md)
- [PEAKS: Selecting Key Training Examples Incrementally via Prediction Error Anchored by Kernel Similarity](https://refivu.com/papers/d4ad0f5e-2b66-4b2c-b036-16ca9b4435c0-peaks-selecting-key-training-examples-incrementally-via.md)
- [EvoPress: Accurate Dynamic Model Compression via Evolutionary Search](https://refivu.com/papers/9b751a25-3027-4f44-b8fd-a5a56de096fa-evopress-accurate-dynamic-model-compression-via-evolutionary.md)
- [Improving Consistency Models with Generator-Augmented Flows](https://refivu.com/papers/805b43bc-e24b-4a82-9b1d-0b75f3b5e976-improving-consistency-models-with-generator-augmented-flows.md)
- [Posterior Inference with Diffusion Models for High-dimensional Black-box Optimization](https://refivu.com/papers/df54b967-35f0-4217-af0f-4c91e3fffee5-posterior-inference-with-diffusion-models-for-high.md)

---

AI 해설에는 오류가 있을 수 있습니다. [Refivu](https://refivu.com/papers/3a44621c-ecca-42d4-9e3c-2a7f14a7cf58-multi-turn-code-generation-through-single-step-rewards)
