ReCode: Updating Code API Knowledge with Reinforcement Learning
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.
Code (1)
Tasks
Code Generationreinforcement-learningReinforcement LearningSimilar Papers 제목 키워드 기반
PrecoderNet: Hybrid Beamforming for Millimeter Wave Systems with Deep Reinforcement Learning
In this letter, we investigate the hybrid beamforming for millimeter wave massive multiple-input multiple-output (MIMO) system based on deep reinforcement learning (DRL). Imperfect channel state information (CSI) is assu…
Deep Reinforcement Learningreinforcement-learningReinforcement LearningReinforcement Learning (RL)ReCoDe: Reinforcement Learning-based Dynamic Constraint Design for Multi-Agent Coordination
Constraint-based optimization is a cornerstone of robotics, enabling the design of controllers that reliably encode task and safety requirements such as collision avoidance or formation adherence. However, handcrafted co…
Multi-agent Reinforcement LearningCollision AvoidanceMM-ReCoder: Advancing Chart-to-Code Generation with Reinforcement Learning and Self-Correction
Multimodal Large Language Models (MLLMs) have recently demonstrated promising capabilities in multimodal coding tasks such as chart-to-code generation. However, existing methods primarily rely on supervised fine-tuning (…
Reinforcement LearningCode GenerationA Syntax-Guided Edit Decoder for Neural Program Repair
Automated Program Repair (APR) helps improve the efficiency of software development and maintenance. Recent APR techniques use deep learning, particularly the encoder-decoder architecture, to generate patches. Though exi…
Code CompletionCode GenerationDecoderProgram RepairCORECODE: A Common Sense Annotated Dialogue Dataset with Benchmark Tasks for Chinese Large Language Models
As an indispensable ingredient of intelligence, commonsense reasoning is crucial for large language models (LLMs) in real-world scenarios. In this paper, we propose CORECODE, a dataset that contains abundant commonsense …
Causal InferenceCommon Sense Reasoning