DECoR: Boosting Coding LLMs Through Disciplined and Scalable Code Pre-Training Data Comment Rewriting

Haau-Sing Li, Ruizhe Jiang, Yongchi Zhao, Xiaosen Zheng, Man Ho Lam, Hongxin Li, Junhang Cheng, Tianyu Zheng, Jian Yang, Bryan DaiarXiv 2026

TL;DR

Code large language models (LLMs) learn to connect human intent with program logic through inline comments, yet real-world codebases are often sparsely or poorly commented. DECoR (Disciplined and Efficient Code Pre-Training Data Rewriting) tackles this by training a compact 1.5B-parameter rewriter with reinforcement learning to enrich code comments at scale—while strictly penalizing any edits to the underlying executable code. Pre-training 1B and 30B-A3B models from scratch on 52 billion tokens of DECoR-rewritten Python data yields substantial gains on coding benchmarks, nearly doubling pass@1 performance on BigCodeBench-Full.

What Problem Does This Paper Address?

To write good code, LLMs need strong alignment between natural language (NL) and programming languages (PL). While mixing tutorials, blogs, and documentation into pre-training corpora helps, inline comments inside source files offer a uniquely direct, line-by-line supervision signal.

The catch? Most large-scale code corpora are either sparsely commented or filled with unhelpful, outdated remarks. Standard data curation pipelines focus on filtering—deciding which files to keep or discard—rather than transforming the files we already have. Previous attempts at rewriting code data either used supervised fine-tuning (SFT) to imitate a teacher's comment style (which caps quality at the teacher's distribution) or prompted LLMs to rewrite entire files without strict constraints. Unconstrained rewriting can subtly alter executable code, which the authors show actually hurts downstream performance on benchmarks like MBPP.

Methods

DECoR is built on two core principles: discipline (leave executable code intact) and quality optimization through exploration (use reinforcement learning to discover better comments).

Figure 2: Training and applying the DECoR comment rewriter. (1) Claude 3.7 Sonnet uses Python docstrings to write inline comments. We keep code-preserving rewrites, then strip docstrings from both the input and the teacher reference. (2) We train a 1.5B rewriter with GRPO using two equally weighted rewards. An LLM judge scores candidate comments against the teacher reference, and the discipline reward penalizes changed regions in normalized Python. (3) We pre-train models from scratch on the trained rewriter’s output.
  1. Seed Data Creation: The authors filter Python files for high-quality, English docstrings that accurately match the code. They prompt Claude 3.7 Sonnet to use those docstrings to write inline comments, keep only code-preserving rewrites, and then strip the original docstrings from both the input and the teacher reference—yielding 6,240 training and 300 held-out examples.
  2. Rewriter Training with RL: Rather than stopping at SFT, the authors train a 1.5B-parameter rewriter (Qwen2.5-Coder-1.5B-Instruct) using GRPO (with DAPO's asymmetric clipping). The reward function combines two equally weighted terms:
  3. Quality reward: A frozen Claude 3.7 Sonnet judge scores the generated comments (0–5) on correctness, conciseness, structural understanding, inferential depth, and reference alignment.
  4. Discipline reward: Both the candidate and reference code are parsed into Python abstract syntax trees (ASTs) and unparsed into a canonical format. Using difflib, the system counts changed regions (hunks) and penalizes any edits to the underlying Python.
  5. At-Scale Rewriting & Pre-Training: The trained 1.5B rewriter is applied across entire pre-training corpora, generating ~52B tokens of comment-enriched code. To isolate the effect of the data without confounding pre-existing capabilities, the authors pre-train 1B dense and 30B-A3B Mixture-of-Experts (MoE) models from scratch.

Datasets

  • Pre-training Corpora (Python subsets):
  • The Stack (deduplicated): One pass contains 22.4B tokens for the Original corpus, 24.9B for SFT rewrites, and 32.0B for DECoR rewrites.
  • Internal GitHub Corpus (filtered using OpenCoder rules): One pass over DECoR rewrites contains 21.0B tokens.
  • Evaluation Benchmarks: Function-level Python code generation benchmarks: HumanEval(+), MBPP(+), and BigCodeBench (Full and Hard).

Key Insights and Ideas

  • Emergent structured documentation: During RL training, the rewriter spontaneously exhibits a two-phase behavior. First, it increases comment diversity (token entropy); then, without ever being explicitly instructed to do so, it invents structured documentation conventions like # Args: and # Returns: blocks. This emergent behavior is completely absent in the SFT rewriter.
  • Comment diversity alone isn't enough: Downstream models trained on SFT-rewritten data also generate more diverse comments than models trained on raw data, yet they fail to outperform—and sometimes underperform—the no-rewriting baseline. The accuracy and explanatory depth of the comments matter.
  • Comments act as a latent supervision channel: Pre-training on step-by-step comments helps models internalize program logic. As illustrated below, a model trained on DECoR data correctly navigates a multi-column DataFrame task where the baseline fails.
Figure 1: Excerpts from two model solutions to a task that asks for a histogram of the last DataFrame column. (a) The model trained on original files rejects inputs with multiple columns and returns a new figure. (b) The model trained on DECoR files selects the last column and returns the histogram axes.

Key Results

  • Rewriter Validation: On the held-out validation set, SFT and RL achieve nearly identical discipline scores (99.4% vs. 99.2%), but RL dramatically outperforms SFT on the LLM judge's quality score (91.4% vs. 78.7%).
  • 1B Dense Model (The Stack, 210B tokens): DECoR achieves 21.1% pass@1 on BigCodeBench-Full, nearly doubling Original (10.6%) and beating SFT (8.1%). It also leads on HumanEval (21.3% vs. 18.3% Original) and MBPP (39.2% vs. 36.5% Original), while tying Original on MBPP+ (33.9%).
  • 30B-A3B MoE Model (GitHub, 39B tokens): DECoR reaches 26.3% pass@1 on BigCodeBench-Full (vs. 12.7% Original and 13.3% SFT), 53.4% on MBPP (vs. 41.3% Original), and 33.5% on HumanEval (vs. 30.4% Original).
  • Downstream Comment Quality: In blind evaluations of 100 BigCodeBench solutions by two independent judges (Fable 5.1 and GPT-5.6-sol), the DECoR-trained 1B model earns the highest correctness and readability scores, with the lowest comment error rates (5.0% and 11.6%, respectively).
Figure 3: Pass@1 during pre-training of the 1B models on the Stack. All three runs use the same token budget. Curves show HumanEval(+), BigCodeBench (Hard and Full), and MBPP(+), with a running average over five checkpoints.

Limitations and Future Work

  • Scope: All pre-training and evaluation experiments focus exclusively on Python and relatively modest model/dataset sizes (1B and 30B-A3B). Whether these gains transfer to other programming languages with different documentation norms—or to much larger models—remains an open question.
  • Coupled variables: Because DECoR rewrites are longer (32.0B vs. 22.4B tokens per pass on the Stack), models trained at a fixed token budget see each source file fewer times. The authors note that their comparisons leave open how much of the gain comes from comment content, length, or file repetition.
  • Rewriter constraints: The choice of a 1.5B base model for the rewriter was dictated by inference throughput constraints, and rewritten files can still occasionally contain inaccurate comments or subtle behavioral changes.

Summary updated

BibTeX
@misc{li2026decor,
  author = {Haau-Sing Li and Ruizhe Jiang and Yongchi Zhao and Xiaosen Zheng and Man Ho Lam and Hongxin Li and Junhang Cheng and Tianyu Zheng and Jian Yang and Bryan Dai},
  title = {{DECoR: Boosting Coding LLMs Through Disciplined and Scalable Code Pre-Training Data Comment Rewriting}},
  year = {2026},
  eprint = {2612.05203},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2612.05203},
}
Figure