언어 모델이 코드로 생각하도록 가르치기
Teaching Language Models to Think in Code
May 11, 2026
저자: Hyeon Hwang, Jiwoo Lee, Jaewoo Kang
cs.AI
초록
도구 통합 추론(Tool-integrated reasoning, TIR)은 자연어(NL) 추론과 코드 실행을 결합하여 언어 모델에서 수학적 문제 해결을 위한 지배적인 패러다임으로 부상했습니다. 그러나 이러한 교차 방식에는 세 가지 주요 한계가 있습니다. 코드가 종종 사후 검증기 역할을 하고, 중간 NL 계산은 오류가 발생하기 쉬우며, NL과 코드가 명확히 구분된 역할보다는 중복된 역할을 수행한다는 점입니다. 우리는 NL이 호출하는 도구가 아닌 코드 자체가 추론기 역할을 하는 프레임워크인 ThinC(Thinking in Code)를 제안합니다. ThinC 궤적은 간단한 NL 계획 단계로 시작되며, 이후 모든 추론은 실행 출력만으로 연결된 코드 블록을 통해 전개됩니다. 우리는 교사 모델에서 12.2k개의 코드 중심 궤적을 추출하고, 지도 학습 미세 조정과 강화 학습을 통해 ThinC-1.7B 및 ThinC-4B를 훈련했습니다. ThinC-4B는 5개의 경쟁 수준 수학 벤치마크에서 모든 TIR 기준선을 지속적으로 능가하며, 훨씬 더 큰 Qwen3-235B-A22B-Thinking조차 앞지릅니다. 추가 분석에 따르면 ThinC는 코드를 통해 추론합니다. 최종 답변의 99.2%가 인터프리터 출력에 기반하며, 모델은 중간 NL 추론 없이 코드 실행 실패로부터 안정적으로 복구됩니다. 우리의 코드와 모델은 곧 공개될 예정입니다.
English
Tool-integrated reasoning (TIR) has emerged as a dominant paradigm for mathematical problem solving in language models, combining natural language (NL) reasoning with code execution. However, this interleaved setup has three key limitations: code often acts as a post-hoc verifier, intermediate NL computations are error-prone, and NL and code play overlapping rather than clearly distinct roles. We propose ThinC (Thinking in Code), a framework in which code itself serves as the reasoner rather than as a tool invoked by NL. A ThinC trajectory begins with a brief NL planning step, after which all reasoning unfolds through code blocks connected only by their execution outputs. We distill 12.2k code-centric trajectories from a teacher model and train ThinC-1.7B and ThinC-4B with supervised fine-tuning followed by reinforcement learning. ThinC-4B consistently outperforms every TIR baseline on five competition-level math benchmarks and even surpasses the much larger Qwen3-235B-A22B-Thinking. Further analysis shows that ThinC reasons through code: 99.2% of its final answers are grounded in interpreter output, and the model recovers reliably from code execution failures without intermediate NL reasoning. Our code and models will be released soon.