A Hitchhiker's Guide To Scaling AI. Chapter - 001
Kaplan et al. (2020)
Historical Context: From Moore's Law to AI Scaling Laws
In 1965, Gordon Moore observed that "the number of transistors that could be placed on an integrated circuit (IC) was doubling roughly every 2 years." This simple empirical observation became the foundation for Intel's growth strategy and helped drive the entire computer revolution. Moore's Law wasn't just an interesting observation—it was a road-map that guided decades of semiconductor development.
Fast forward to 2020, and we see a similar paradigm shift in artificial intelligence. OpenAI's paper "Scaling Laws for Neural Language Models," with core contributors Jared Kaplan and Sam McCandlish, systematically investigated what many AI researchers had intuitively suspected: that model performance improves in predictable ways as we scale up resources, AKA Bigger is Better.
The Fundamental Scaling Variables (The Big 3)
Before Understanding the mathematical relationships, let's clarify the three fundamental variables in scaling laws:
Model Parameters [N]:
- These are the trainable weights in the neural network
- More parameters allow the model to capture more complex patterns
- Measured simply as a count (e.g., 175 billion parameters in GPT-3)
Dataset Size [D]:
- The amount of text used to train the model
- Usually measured in tokens (word fragments)
- Larger datasets expose the model to more patterns and knowledge
Compute [C]:
- The computational resources used for training
- Often measured in petaflop/s-days (a unit of computation)
- Combines both the speed of calculation and duration of training
The Mathematical Relationships of Scaling Laws
The key insight from Kaplan et al. is that model performance follows power-law relationships with each of these variables. Let's break down each relationship in detail:
1. Scaling with Model Size [N]
Where:
- is the cross-entropy loss (lower means better performance)
- is the number of model parameters
- is the power-law exponent
- means "proportional to"
This equation tells us that as we increase the number of parameters, the loss decreases following a power law. The exponent means that doubling the model size reduces the loss by a factor of , or about 5.4% improvement.
Importantly, this relationship holds across many orders of magnitude—from models with millions of parameters to those with billions—suggesting a fundamental property of neural language models.
2. Scaling with Dataset Size [D]
Where:
- is the dataset size (typically measured in tokens)
- is the power-law exponent
This equation shows that as we increase the amount of training data, the loss also decreases following a power law. The exponent means that doubling the dataset size reduces the loss by a factor of , or about a 6.8% improvement.
3. Scaling with Compute [C]
Where:
- is the compute used for training
- is the power-law exponent
This equation describes how loss decreases as we increase the computational resources devoted to training. The exponent means that doubling the compute reduces the loss by a factor of , or about a 3.5% improvement.
This relationship assumes that compute is allocated optimally between model size and dataset size.
4. Optimal Allocation of Compute
One of the most practical insights from Kaplan et al. is how to optimally allocate compute between model size and dataset size:
This equation tells us that as we increase our compute budget, we should allocate roughly 27% to increasing the dataset size and the remaining 73% to increasing the model size.
The full derivation comes from:
Substituting the values and :
Then, because and , we get:
Kaplan et al. empirically found it closer to , which is the value commonly cited.
5. The Universality of Overfitting
The paper also introduced the concept of the "universality of overfitting," described by:
Where:
- is a constant related to the task
This equation elegantly captures two regimes:
- When (model size much smaller than dataset size), the denominator is approximately 1, and we get the standard power-law scaling:
- When approaches or exceeds , the denominator decreases, causing the loss to increase—this is overfitting
The term "universality" refers to the finding that this pattern of overfitting appears consistently across model architectures and sizes.
Practical Implications of Scaling Laws
These mathematical relationships have profound practical implications:
Predictable Improvements: Organizations can reliably predict how much better their models will get with more resources.
Resource Allocation: The optimal allocation formula () provides clear guidance on how to divide resources between collecting more data and building larger models.
Diminishing Returns: The power-law relationships mean each doubling of resources yields a smaller percentage improvement than the previous doubling—informing cost-benefit decisions.
Architecture Agnostic: The finding that performance depends weakly on model architecture ("shape") but strongly on scale suggests that simple architectures scaled appropriately can outperform complex architectures with fewer resources.
The Empirical Evidence
What makes the Kaplan et al. paper so compelling is the extensive empirical evidence. They trained over 60 different Transformer language models, varying in size from 768 to 1.5 billion parameters, with between 22 million and 17 billion tokens of training data.
The consistency of the scaling trends across this wide range of conditions is what gives the scaling laws their predictive power. There were "NO SIGNS OF DEVIATION from these trends on the upper end," suggesting that these relationships would continue to hold for even larger models—a prediction that has been borne out by the subsequent success of models like GPT-3 and GPT-4.
Critical Insight: L(N, D) ∝ N^(-0.78)/D
The Landmark Insights in the paper are as follows:
This is a simplified form of the overfitting equation that appears when N approaches D. The exponent -0.78 combines the effects of both the power-law scaling with model size and the overfitting term.
This relationship tells us that:
- Increasing model size (N) decreases loss with an exponent of approximately -0.78 (which is steeper than the -0.076 when N is much smaller than D)
- Increasing dataset size (D) decreases loss linearly (with exponent -1)
- The ratio between model size and dataset size is critical: if you increase model size without a proportional increase in dataset size, you'll hit diminishing returns due to overfitting
Scaling Laws Mathematical Relationships: Summary Table
Key Mathematical Relationships from Kaplan et al. (2020)
| Relationship | Mathematical Formula | Exponent Value | Practical Interpretation | Notes |
|---|---|---|---|---|
| Model Size Scaling | Doubling model size [N] reduces loss by ~5.4% | Applies when dataset size is sufficient to avoid overfitting | ||
| Dataset Size Scaling | Doubling dataset size [D] reduces loss by ~6.8% | Applies when model is large enough to utilize the data | ||
| Compute Scaling | Doubling compute [C] reduces loss by ~3.5% | Assumes optimal allocation between N and D | ||
| Optimal Model Size | Model size should scale as ~C^0.444 for optimal performance | About 73% of additional compute should go to increasing model size | ||
| Optimal Dataset Size | Dataset size should scale as ~C^0.27 for optimal performance | About 27% of additional compute should go to increasing dataset size | ||
| Model vs. Dataset Relation | For each 100% increase in model size, increase dataset by ~74% | Balances model capacity with information in the dataset | ||
| Overfitting Boundary | varies by task | Captures both scaling and overfitting regimes | Loss increases when N approaches or exceeds D | |
| Simplified Overfitting | -0.78 (combined) | Combined effect of model scaling and overfitting | Occurs when N approaches D |
Derived Relationships
| Variable | Formula | Value | Meaning |
|---|---|---|---|
| Optimal Token/Parameter Ratio | ~3-4 tokens per parameter | Kaplan et al.'s finding (later revised by Chinchilla) | |
| Chinchilla Optimal Ratio | ~20 tokens per parameter | Hoffmann et al.'s (2022) refinement | |
| Critical Compute Threshold | Task-dependent | Minimum compute needed for meaningful task performance | |
| Power-Law Coefficient | ~1.25 | Ratio that determines optimal allocation |
Units and Measurements
| Variable | Symbol | Typical Units | Example Scale |
|---|---|---|---|
| Model Size | N | Number of parameters | Millions to hundreds of billions |
| Dataset Size | D | Number of tokens | Billions to trillions |
| Compute | C | Petaflop/s-days | 10^-4 to 10^4 |
| Loss | L | Nats per token | 1.0 to 4.0 |
Bibliography: