Table of Contents
Fetching ...

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.

Think Like Human Developers: Harnessing Community Knowledge for Structured Code Reasoning

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.

Paper Structure

This paper contains 28 sections, 2 equations, 4 figures, 5 tables.

Figures (4)

  • Figure 1: An example of community discussions on LeetCode.
  • Figure 2: The pipeline of SVRC. SVRC begins with extracting community discussions and corresponding code solutions from community platforms. It then identifies and completes missing sections in discussions, and introduces format perturbations to code solutions to enhance original discussions. Finally, SVRC enriches the reasoning chains by rewriting the original discussion guided by software development principles and introducing refinement loops.
  • Figure 3: Comparison of CodeThinker and its base model on non-LeetCode coding problems (AtCoder and Codeforces), highlighting improved reasoning performance on medium-difficulty tasks.
  • Figure 4: Performance of CodeThinker on different stages of SVRC. The performance drop from S0 to S1 further suggests that LLMs struggle to learn reasoning patterns solely from raw community data, which motivates our design of SVRC.