ReCode: 강화 학습을 통한 코드 API 지식 업데이트
ReCode: Updating Code API Knowledge with Reinforcement Learning
June 25, 2025
저자: Haoze Wu, Yunzhi Yao, Wenhao Yu, Huajun Chen, Ningyu Zhang
cs.AI
초록
대규모 언어 모델(LLMs)은 뛰어난 코드 생성 능력을 보이지만, 외부 라이브러리 API의 빈번한 업데이트에 적응하는 데는 어려움을 겪습니다. 이는 훈련 데이터에서 얻은 구식 API 지식에 의존하기 때문에 발생하는 중요한 한계로, 최신 문서에 접근할 수 있음에도 불구하고 동적 환경에서 신뢰할 수 있는 코드 생성을 방해합니다. 이 문제를 해결하기 위해, 우리는 인간 프로그래머가 API 변경에 적응하는 방식을 모방한 새로운 프레임워크인 ReCode(규칙 기반 강화 학습을 통한 코드 업데이트)를 제안합니다. 구체적으로, 우리는 약 2,000개의 데이터 항목으로 구성된 데이터셋을 구축하여 LLMs가 업데이트된 정보를 기반으로 버전 마이그레이션을 수행하도록 훈련시킵니다. 그런 다음, 강화 학습의 보상으로 사용하기 위해 수정된 문자열 유사성 메트릭을 코드 평가에 도입합니다. 우리의 실험 결과, ReCode는 특히 보이지 않는 CodeUpdateArena 작업에서 동적 API 시나리오에서 LLMs의 코드 생성 성능을 크게 향상시킵니다. 중요한 점은, 지도 학습 미세 조정과 비교했을 때 ReCode가 LLMs의 일반적인 코드 생성 능력에 미치는 영향이 적다는 것입니다. 우리는 다양한 LLMs와 강화 학습 알고리즘(GRPO 및 DAPO)에 ReCode를 적용하여 모두 일관된 개선을 달성했습니다. 특히, 훈련 후 Qwen2.5-Coder-7B는 32B 매개변수 코드 명령어 튜닝 모델 및 동일한 아키텍처를 가진 추론 모델의 성능을 능가했습니다. 코드는 https://github.com/zjunlp/ReCode에서 확인할 수 있습니다.
English
Large Language Models (LLMs) exhibit remarkable code generation capabilities
but falter when adapting to frequent updates in external library APIs. This
critical limitation, stemming from reliance on outdated API knowledge from
their training data, even with access to current documentation, impedes
reliable code generation in dynamic environments. To tackle this issue, we
propose ReCode (rule-based Reinforcement learning for Code Update), a novel
framework that mimics human programmer adaptation to API changes. Specifically,
we construct a dataset of approximately 2,000 data entries to train the LLMs to
perform version migration based on updated information. Then, we introduce a
modified string similarity metric for code evaluation as the reward for
reinforcement learning. Our experiments demonstrate that ReCode substantially
boosts LLMs' code generation performance in dynamic API scenarios, especially
on the unseen CodeUpdateArena task. Crucially, compared to supervised
fine-tuning, ReCode has less impact on LLMs' general code generation abilities.
We apply ReCode on various LLMs and reinforcement learning algorithms (GRPO and
DAPO), all achieving consistent improvements. Notably, after training,
Qwen2.5-Coder-7B outperforms that of the 32B parameter code instruction-tuned
model and the reasoning model with the same architecture. Code is available at
https://github.com/zjunlp/ReCode.