Abstract
Scaling laws serve as critical guides for optimizing the training of Large Language Models (LLMs), yet most existing frameworks are derived from natural language (NL) data. This paper presents the first large-scale empirical study of scaling laws specifically for code. Through 117 experimental runs, we demonstrate that code models are significantly more "data-hungry" than their NL counterparts, requiring a much higher data-to-parameter ratio to reach optimality. We find that the Farseer law outperforms the standard Chinchilla law for code and identify a "natural language reversal" where mixing NL data into code training becomes detrimental at high compute budgets.
Introduction
Scaling laws provide the "instruction manuals" for balancing model size ($N$) and training data ($D$) to maximize performance for a given compute budget ($C$). While the Chinchilla law has become a standard for NL, code possesses unique characteristics—strict syntax, high repetitiveness, and complex dependencies—that suggest it may follow a different scaling trajectory. This study investigates whether AI engineers can continue to rely on NL-derived recipes for training the next generation of Code LLMs.
Methodology
To derive robust scaling laws for code, we conducted a massive sweep of 117 experimental runs. Models ranged from 0.2B to 3.8B parameters, trained on token counts between 2B and 128B.
Experimental Setup
- Architecture: All models utilized a modern decoder-only Transformer architecture incorporating SwiGLU, RoPE, and RMSNorm to ensure results were independent of architectural variations.
- Optimization: We employed "StepLaw" rules to automatically determine near-optimal learning rates and batch sizes, minimizing the influence of sub-optimal hyperparameters.
- Data: The training set was a curated, deduplicated version of the OpenCoder corpus (895.51B tokens), while validation was performed on a high-quality, 6.3M token internal codebase with zero training overlap.
Scaling Law Analysis
Our analysis compared the standard Chinchilla law (a power-law relationship) against the Farseer law, which allows scaling exponents to vary as functions of model size. The Farseer law achieved a lower mean relative error (0.82‰) compared to Chinchilla (1.03‰) when predicting validation loss.
The "Data-Hungry" Nature of Code
A primary finding is that code requires a significantly higher data-to-parameter ($D/N$) ratio than NL. At a compute budget of $5.36 \times 10^{21}$ FLOPs, the optimal $D/N$ ratio for code is approximately 150, whereas the standard Chinchilla-optimal ratio for NL is typically around 20. This suggests that because code is highly repetitive (lower information density), models must process far more tokens to encounter novel logic.
The Role of Natural Language Data
We explored the impact of mixing NL data with code at various ratios. We observed a phenomenon we term the "NL Reversal": in low-compute settings, NL data acts as a helpful regularizer and provides general world knowledge. However, as the compute budget increases, this benefit vanishes. At higher scales, NL data becomes a "distributional distraction," and pure code data yields superior performance.
Conclusion and Future Outlook
Code models exhibit sustained scalability and a near-zero irreducible loss, likely reflecting the deterministic nature of programming languages. As shown in the comparison of scaling surfaces, code models operate in a distinct loss regime compared to NL models.
Limitations
While this study provides a comprehensive map for models up to 3.8B parameters, future work is required to determine if these dynamics hold for frontier models exceeding 70B parameters. Additionally, while we focused on data quantity, the interplay between data quality (e.g., upsampling complex logic) and scaling remains an open area for investigation.
Summary updated