ReflexiCoder: Teaching Large Language Models to Self-Reflect on Generated Code and Self-Correct It via Reinforcement Learning
While Large Language Models (LLMs) have revolutionized code generation, standard "System 1" approaches, generating solutions in a single forward pass, often hit a performance ceiling when faced with complex algorithmic tasks. Existing iterative refinement strategies attempt to bridge this gap at inference time, yet they predominantly rely on external oracles, execution feedback, or computationally expensive prompt-response cycles. In this work, we propose ReflexiCoder, a novel reinforcement learning (RL) framework that internalizes the structured reasoning trajectory, encompassing initial generation, bug and optimization aware reflection, and self-correction, directly into the model's weights. Unlike prior methods, ReflexiCoder shifts the paradigm from external-dependent refinement to an intrinsic, fully autonomous self-reflection and self-correction capabilities at inference time. We utilize an RL-zero training paradigm with granular reward functions to optimize the entire reflection-correction trajectory, teaching the model how to debug without reliance on ground-truth feedback or execution engines at inference time. Extensive experiments across seven benchmarks demonstrate that our ReflexiCoder-8B establishes a new state-of-the-art (SOTA) among leading open-source models in the 1.5B-14B range, achieving 94.51% (87.20%) on HumanEval (Plus), 81.80% (78.57%) on MBPP (Plus), 35.00% on BigCodeBench, 52.21% on LiveCodeBench, and 37.34% on CodeForces in a single-attempt setting, rivaling or surpassing proprietary models like GPT-5.1. Notably, our framework is significantly more token-efficient than base models, reducing inference-time compute overhead by approximately 40% through disciplined, high-speed reasoning and reflection patterns. Source code is available at https://github.com/juyongjiang/ReflexiCoder.
69aeb1f79893f58272f742e5
Juyong Jiang
claimed_verified
2026-03-12T09:07:56.169Z
64b63712b3b69063d9aff341
https://cdn-avatars.huggingface.co/v1/production/uploads/64b63712b3b69063d9aff341/nP6GyBKBtnWWoA0TvQF3K.jpeg
John
juyongjiang
user
juyongjiang
69aeb1f79893f58272f742e6
Jiasi Shen
69aeb1f79893f58272f742e7
Sunghun Kim
69aeb1f79893f58272f742e8
Kang Min Yoo
69aeb1f79893f58272f742e9
Jeonghoon Kim
claimed_verified
2026-04-01T08:36:50.715Z
64383d54c5a91b84ece18d62
https://cdn-avatars.huggingface.co/v1/production/uploads/64383d54c5a91b84ece18d62/4myD1o3yWpLVorb_H33ez.png
Jeonghoon Kim
PenPaperKeyCode
user
PenPaperKeyCode
69aeb1f79893f58272f742ea
Sungju Kim
claimed_verified
2026-03-16T10:44:39.300Z
61b4b36c04d3f0cdf3fdf755
https://cdn-avatars.huggingface.co/v1/production/uploads/61b4b36c04d3f0cdf3fdf755/mJfHdwXBpLGsaO3lBG3BZ.jpeg
Sungju Kim
goddoe
user
goddoe
ReflexiCoder: Teaching Large Language Models to Self-Reflect on Generated Code and Self-Correct It via Reinforcement Learning
While Large Language Models (LLMs) have revolutionized code generation, standard "System 1" approaches, generating solutions in a single forward pass, often hit a performance ceiling when faced with complex algorithmic tasks. Existing iterative refinement strategies attempt to bridge this gap at inference time, yet they predominantly rely on external oracles, execution feedback, or computationally expensive prompt-response cycles. In this work, we propose ReflexiCoder, a novel reinforcement learning (RL) framework that internalizes the structured reasoning trajectory, encompassing initial generation, bug and optimization aware reflection, and self-correction, directly into the model's weights. Unlike prior methods, ReflexiCoder shifts the paradigm from external-dependent refinement to an intrinsic, fully autonomous self-reflection and self-correction capabilities at inference time. We utilize an RL-zero training paradigm with granular reward functions to optimize the entire reflection-correction trajectory, teaching the model how to debug without reliance on ground-truth feedback or execution engines at inference time. Extensive experiments across seven benchmarks demonstrate that our ReflexiCoder-8B establishes a new state-of-the-art (SOTA) among leading open-source models in the 1.5B-14B range, achieving 94.51% (87.20%) on HumanEval (Plus), 81.80% (78.57%) on MBPP (Plus), 35.00% on BigCodeBench, 52.21% on LiveCodeBench, and 37.34% on CodeForces in a single-attempt setting, rivaling or surpassing proprietary models like GPT-5.1. Notably, our framework is significantly more token-efficient than base models, reducing inference-time compute overhead by approximately 40% through disciplined, high-speed reasoning and reflection patterns. Source code is available at https://github.com/juyongjiang/ReflexiCoder.
ReflexiCoder uses reinforcement learning to enable large language models to perform autonomous code debugging and optimization through internalized reflection and correction mechanisms, achieving state-of-the-art performance with reduced computational overhead.
Large Language Models reinforcement learning code generation iterative refinement external oracles prompt-response cycles RL-zero training granular reward functions self-reflection self-correction inference time token efficiency computational overhead