Scaling Laws for Code: A More Data-Hungry Regime

Xianzhen Luo, Wenzhen Zheng, Qingfu Zhu, Rongyi Zhang, Houyi Li, Siming Huang, YuanTao Fan, Wanxiang Che

TL;DR

This paper presents the first large-scale empirical study of scaling laws specifically tailored for code language models, spanning 117 experimental training runs. The authors reveal that while code models scale robustly with parameter size, code is a significantly more "data-hungry" regime than natural language, requiring a much higher data-to-parameter ratio to reach optimal performance. Furthermore, they demonstrate that while mixing natural language data helps small models, it becomes a detriment at larger compute scales.

What Problem Does This Paper Address?

Large Language Models (LLMs) optimized for code have revolutionized software engineering. However, the scaling laws used to guide their efficient training—determining how to balance model size ($N$) and dataset size ($D$) given a compute budget ($C$)—have been almost exclusively derived from Natural Language (NL) data.

Code is fundamentally different from NL: it features strict syntax, highly repetitive structures, and complex long-range dependencies. As a result, prominent code LLMs often deviate significantly from standard NL scaling predictions like Chinchilla, opting for much higher data-to-parameter ratios without a clear theoretical framework (see Figure 1). This paper bridges the gap by establishing a dedicated, principled scaling law for code pretraining.

The relationship between compute budget and optimal data-to-parameter ratio, showing how code LLMs deviate from NL curves.

Methods

The authors executed a systematic sweep of 117 experimental runs, varying model sizes from 0.2B to 3.8B parameters and training tokens from 2B to 128B. All models shared a consistent decoder-only Transformer architecture utilizing modern components like SwiGLU activations, Rotary Position Embeddings (RoPE), and RMSNorm. Hyperparameters were scaled dynamically using StepLaw rules to ensure near-optimal learning rates and batch sizes without expensive individual tuning.

The empirical results were fit to two scaling law formulations:

  1. The Chinchilla Law: A standard power-law relationship with constant exponents.
  2. The Farseer Law: A more expressive formulation where the scaling exponents are themselves functions of model size ($N$).

To validate their findings, they performed a large-scale validation experiment at a fixed compute budget ($C = 5.36 \times 10^{21}$ FLOPs) across three distinct data-to-parameter ($D/N$) ratios. They also conducted 234 additional runs to explore code-NL data mixtures.

Datasets

  • Training Set: Sourced from the OpenCoder pre-training corpus (public GitHub repositories). The authors downsampled the initial 1,216.93B token corpus to a more balanced 895.51B token train set to prevent high-volume languages from dominating the distribution.
  • Validation Set: A high-quality, 6.3M token internal codebase consisting of production-grade code, rigorously filtered to ensure zero overlap or contamination with the training set.
  • NL Data: Used for data-mixing experiments, sourced from previous Farseer literature.

Key Insights and Ideas

  • Code is Inherently "Data-Hungry": Code has lower intrinsic entropy than natural language due to its strict syntax and repetitive idioms. Because models master these common structural patterns early in training, massive token volumes are required to introduce genuinely new logic and application scenarios.
  • The Optimal $D/N$ Ratio is Dynamic: Unlike Chinchilla's assumption of a near-constant data-to-parameter ratio, the optimal $D/N$ ratio for code grows super-linearly with the compute budget. Larger models accelerate learning from data, demanding even more data to achieve convergence at higher scales.
  • The Data-Mixing Reversal: Incorporating natural language data into code pretraining acts as a helpful regularizer and provides transferable world knowledge only in low-compute or data-scarce settings. At larger scales, the distributional shift introduced by NL data acts as a performance impediment, making pure code data superior.
3D visualization comparing scaling surfaces for different code-NL data mixtures.

Key Results

  • Farseer Outperforms Chinchilla: The more expressive Farseer formulation provided a significantly better fit for code scaling, achieving a lower mean relative error (0.82‰ vs. 1.03‰) and predicting an irreducible loss approaching zero.
  • Empirical Validation: In high-compute validation tests, the model trained at the Farseer-predicted optimal code ratio ($D/N = 150$) achieved a significantly lower validation loss than the model trained at the traditional NL-optimal ratio ($D/N = 20$).
  • Sustained Scalability: The scaling surface for code shows a consistent, steep downward gradient along the parameter axis, indicating that code models are not approaching a saturation point and will continue to derive substantial benefits from scaling up parameters, provided they are fed sufficient data.
3D visualization of the fitted Farseer scaling-law surfaces for Code vs. Natural Language.

Limitations and Future Work

  • Compute and Scale Caps: Due to computational constraints, the study was limited to 117 baseline points and capped at a maximum model size of 3.8B parameters. Evaluating these laws at extreme industrial scales (e.g., 30B+ parameters) remains an open area for future work.
  • Coarse Data-Mixing Ratios: The code-NL mixture analysis only evaluated two distant points on the spectrum (70/30 and 30/70). A more granular exploration is required to map the exact optimal blend across varying compute budgets.

Summary updated

BibTeX
@inproceedings{luo2026scaling,
  author = {Xianzhen Luo and Wenzhen Zheng and Qingfu Zhu and Rongyi Zhang and Houyi Li and Siming Huang and YuanTao Fan and Wanxiang Che},
  title = {{Scaling Laws for Code: A More Data-Hungry Regime}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.acl-long.1101},
}
Figure