Think Like Human Developers: Harnessing Community Knowledge for Structured Code Reasoning
Chengran Yang, Zhensu Sun, Hong Jin Kang, Jieke Shi, David Lo
TL;DR
SVRC tackles the scarcity and noisiness of code-reasoning data by mining authentic, human-driven reasoning from community discussions and enriching it with SDLC-guided iterative refinement. This yields CodeThinker, a reasoning-augmented LLM fine-tuned on a curated SVRC_LC dataset (~12k samples), which substantially improves pass@1 on medium-difficulty coding tasks and generalizes to non-LeetCode platforms. Ablation confirms the contribution of each SVRC component, from completion and perturbation to SDLC-aligned enrichment, underscoring the value of domain-specific, reasoning-focused fine-tuning. Overall, the work demonstrates a scalable strategy to inject human-like, iterative reasoning into code generation by leveraging community knowledge and structured enrichment.
Abstract
Large Language Models (LLMs) have significantly advanced automated code generation, yet they struggle with complex coding tasks requiring multi-step logical reasoning. High-quality reasoning data is crucial for improving LLMs' reasoning capabilities, but such datasets remain scarce. Existing approaches either rely on computationally expensive reinforcement learning (RL) or error-prone reasoning chains synthesized by LLMs, posing challenges in scalability and accuracy. To address this challenge, we propose SVRC (Structured and Validated Reasoning Chains for Code Generation), a novel framework that mines, restructures, and enriches reasoning chains from community-driven discussions on software engineering platforms. SVRC refines unstructured and incomplete discussions of coding problems by aligning them with Software Development Life Cycle (SDLC) principles, ensuring that reasoning chains capture real-world problem-solving strategies and support iterative refinement. To evaluate the effectiveness of SVRC, we introduce CodeThinker, an LLM fine-tuned on 12,444 reasoning-augmented samples generated by SVRC. Experiments on LiveCodeBench show that CodeThinker surpasses its base model by 42.86\% on medium-level code problems in terms of pass@1 and outperforms GPT-4o-mini and GPT-4o by 73.14\% and 115.86\%, respectively. Our ablation study further highlights that each component of SVRC contributes to the reasoning capabilities of CodeThinker.
