R1-Code-Interpreter: 지도 학습 및 강화 학습을 통해 코드로 추론하는 LLM 훈련
R1-Code-Interpreter: Training LLMs to Reason with Code via Supervised and Reinforcement Learning
May 27, 2025
저자: Yongchao Chen, Yueying Liu, Junwei Zhou, Yilun Hao, Jingquan Wang, Yang Zhang, Chuchu Fan
cs.AI
초록
R1과 유사한 모델들의 추론 및 계획 능력이 발전했음에도 불구하고, 대형 언어 모델(LLMs)은 정밀한 계산, 기호 조작, 최적화, 알고리즘적 추론이 필요한 작업에서 여전히 어려움을 겪고 있으며, 이는 텍스트 기반 추론이 코드 실행의 엄격함을 갖추지 못하기 때문입니다. 주요 과제는 LLM이 텍스트 기반 추론과 코드 생성을 언제 사용할지 결정할 수 있도록 하는 것입니다. OpenAI는 필요에 따라 코드 인터프리터를 호출하도록 모델을 훈련시키지만, 공개된 연구에서는 사전 훈련된 LLM이 코드를 효과적으로 활용하고 다양한 작업에서 일반화할 수 있도록 조정하는 방법에 대한 지침이 부족합니다. 본 논문에서는 텍스트 전용 LLM을 확장한 R1-Code-Interpreter를 제시하며, 이 모델은 다중 턴 지도 미세 조정(SFT)과 강화 학습(RL)을 통해 단계별 추론 중에 여러 코드 쿼리를 자율적으로 생성하도록 훈련되었습니다. 우리는 144개의 추론 및 계획 작업(훈련용 107개, 테스트용 37개)을 선별했으며, 각 작업에는 200개 이상의 다양한 질문이 포함되어 있습니다. Qwen-2.5 모델(3B/7B/14B)을 다양한 SFT 및 RL 전략을 사용하여 미세 조정하며, 다양한 답변 형식, 추론 모델 대 비추론 모델, 콜드 스타트 대 웜 스타트, GRPO 대 PPO, 마스킹된 코드 출력 대 마스킹되지 않은 코드 출력 등을 조사했습니다. 이전의 좁은 도메인에 대한 RL 연구와 달리, 코드 인터프리터 훈련은 높은 작업 다양성과 비용이 많이 드는 코드 실행으로 인해 상당히 어려운 것으로 나타났으며, 이는 SFT 단계의 중요성을 강조합니다. 우리의 최종 모델인 R1-CI-14B는 37개의 테스트 작업에서 평균 정확도를 44.0%에서 64.1%로 향상시켰으며, GPT-4o(텍스트 전용: 58.6%)를 능가하고 코드 인터프리터를 사용한 GPT-4o(70.9%)에 근접한 성능을 보였으며, 코드 생성을 통한 자기 점검 행동이 나타났습니다. 데이터셋, 코드, 모델은 https://github.com/yongchao98/R1-Code-Interpreter와 https://huggingface.co/yongchao98에서 확인할 수 있습니다.
English
Despite advances in reasoning and planning of R1-like models, Large Language
Models (LLMs) still struggle with tasks requiring precise computation, symbolic
manipulation, optimization, and algorithmic reasoning, in which textual
reasoning lacks the rigor of code execution. A key challenge is enabling LLMs
to decide when to use textual reasoning versus code generation. While OpenAI
trains models to invoke a Code Interpreter as needed, public research lacks
guidance on aligning pre-trained LLMs to effectively leverage code and
generalize across diverse tasks. We present R1-Code-Interpreter, an extension
of a text-only LLM trained via multi-turn supervised fine-tuning (SFT) and
reinforcement learning (RL) to autonomously generate multiple code queries
during step-by-step reasoning. We curate 144 reasoning and planning tasks (107
for training, 37 for testing), each with over 200 diverse questions. We
fine-tune Qwen-2.5 models (3B/7B/14B) using various SFT and RL strategies,
investigating different answer formats, reasoning vs. non-reasoning models,
cold vs. warm starts, GRPO vs. PPO, and masked vs. unmasked code outputs.
Unlike prior RL work on narrow domains, we find that Code Interpreter training
is significantly harder due to high task diversity and expensive code
execution, highlighting the critical role of the SFT stage. Our final model,
R1-CI-14B, improves average accuracy on the 37 test tasks from 44.0\% to
64.1\%, outperforming GPT-4o (text-only: 58.6\%) and approaching GPT-4o with
Code Interpreter (70.9\%), with the emergent self-checking behavior via code
generation. Datasets, Codes, and Models are available at
https://github.com/yongchao98/R1-Code-Interpreter and
https://huggingface.co/yongchao98.