Abstract
The scaling law is becoming a fundamental law in many machine learning areas. That is, test error falls off with the power law when increasing training data, model size, and computing resource. However, whether this law is suitable for the task of code understanding is not well studied, and most current language models for code understanding are about 100M parameters, which are relatively "small" compared to large language models. In this paper, we conduct extensive experiments to investigate the scaling law for the code understanding task by varying training data, model size, and computing resource. We validate that the test error of code understanding models falls off with the power law when using larger models, indicating that the scaling law is suitable for the code understanding task. Besides, we apply different scales of models to two downstream code understanding tasks, and find that the performance increases with larger scale of models. Finally, we train a large-scale code understanding model named CoLSBERT with 1.5B parameters on a large dataset using more computing resource, which outperforms previous work by a large margin. We will release our code and the CoLSBERT model when our paper is published.
Introduction
In the field of Large Language Models (LLMs), the "Scaling Law" has become a foundational principle: increasing training data, model parameters, or computing power leads to a predictable power-law decay in model error. While this has been extensively validated for generative models like GPT-4 and Codex, its applicability to code understanding—tasks requiring models to "read" and categorize code (e.g., via transformer-encoders)—remains under-explored. Most current state-of-the-art encoder models for code, such as CodeBERT, are relatively small (~100M parameters). This research investigates whether the scaling law holds for code comprehension or if these models hit a point of diminishing returns.
Methodology
The study isolates three primary dimensions of scale:
- Model Size: Architectures ranging from 124M to 1.5B parameters.
- Training Data: Scaling from standard CodeSearchNet volumes up to 8x that size.
- Computing Resource: Varying training iterations from 100K to 600K steps.
The researchers utilized a Transformer-Encoder architecture with Pre-LN (Layer Normalization) to ensure stability at the 1.5B parameter scale. The resulting model, CoLSBERT, was trained on 351 billion tokens from a filtered version of "The Stack" repository.
Scaling Analysis
The core finding of this work is that test error in code understanding follows the power-law decay ($e = kx^{-\alpha}$), mirroring trends in natural language processing.
As shown in the figures, increasing both model capacity and training iterations leads to a consistent reduction in test error. This suggests that there is currently no "complexity ceiling" for code understanding models, and further scaling is likely to yield continued performance improvements.
Performance and Insights
Beyond pre-training metrics, the authors found that lower test error directly correlates with improved performance on downstream tasks.
- Code Search: CoLSBERT achieved an MRR (Mean Reciprocal Rank) of 77.0 on CodeSearchNet, outperforming UniXcoder (74.4).
- Clone Detection: On the POJ-104 dataset, it reached a MAP (Mean Average Precision) of 92.91, a significant jump from CodeBERT’s 83.79.
Interestingly, clone detection exhibited a "turning point" in performance as scale increased, similar to emergent capabilities in generative LLMs. Probing experiments also revealed that deeper layers in these larger models manage complex semantic and structural understanding, while shallow layers handle surface-level features like code length.
Conclusion
This research confirms that "bigger is better" holds true for code understanding. While scaling is resource-intensive—often requiring an order of magnitude more data for marginal gains—the power law remains a reliable predictor of performance. Future work should explore even larger encoder models (10B+) and seek to identify the compute-optimal balance between data, size, and compute specifically for the domain of code.
Summary updated