Scaling Laws for Neural Language Models
Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361)
Subscriber deck — free during early access
19 cards
1.1 Summary
- What is the main finding of “Scaling Laws for Neural Language Models”?Transformer language model test loss falls as a smooth power law in model size \(N\), dataset size \(D\) and training compute \(C\), each when not bottlenecked by the others, over more than six orders of magnitude, while depending only weakly on architecture details like depth versus width.
Schematic: a power law is a straight line on log–log axes - Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §1.1
- How does model shape affect language model loss at fixed parameter count, according to Kaplan et al.?Very weakly: at fixed non-embedding \(N\), loss varied only a few percent over wide ranges of depth, width, number of heads and feed-forward ratio; e.g. a 6-layer model with \(d_{\text{model}} = 4288\) came within 3% of a 48-layer, 1600-wide model.
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §1.1
- What does “universality of overfitting” mean in Kaplan et al.?Performance improves predictably if \(N\) and \(D\) grow together, but with one fixed, returns diminish; the penalty depends on \(N^{0.74}/D\), so an 8× larger model needs only about 5× more data to avoid it.
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §1.1
- What did Kaplan et al. find about sample efficiency and convergence?Larger models are more sample-efficient, reaching a given loss with fewer steps and fewer tokens. Under a fixed compute budget, optimal training uses very large models stopped well before convergence, with data growing only as \(D \sim C^{0.27}\).
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §1.1
- What did Kaplan et al. find about generalization to other text distributions?Loss on other distributions (books, Wikipedia, Common Crawl) improved in parallel with in-distribution loss, with a roughly constant offset; generalization depended almost only on in-distribution validation loss, not on training duration or depth.
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §1.1
1.2 Summary of Scaling Laws
- Give Kaplan et al.’s three basic power laws for the loss.Limited by parameters (trained to convergence on enough data): \(L(N) = (N_c/N)^{\alpha_N}\), \(\alpha_N \approx 0.076\). Limited by data (large model, early stopping): \(L(D) = (D_c/D)^{\alpha_D}\), \(\alpha_D \approx 0.095\). Limited by optimally used compute: \(L(C_{\min}) = (C_c^{\min}/C_{\min})^{\alpha_C^{\min}}\), \(\alpha_C^{\min} \approx 0.050\).
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §1.2
- By how much does doubling the number of parameters reduce the loss under \(L(N) \propto N^{-0.076}\)?By a factor \(2^{-0.076} \approx 0.95\), about 5%. The constants \(N_c\), \(D_c\), \(C_c\) depend on vocabulary and tokenization and have no fundamental meaning; the exponents carry the content.
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §1.2
- Give Kaplan et al.’s combined law for loss as a function of model and data size.\(L(N, D) = \Big[\big(\frac{N_c}{N}\big)^{\alpha_N/\alpha_D} + \frac{D_c}{D}\Big]^{\alpha_D}\). It reduces to \(L(N)\) as \(D \to \infty\) and \(L(D)\) as \(N \to \infty\), allows rescaling by tokenization, and has a \(1/D\) expansion; it implies data should grow as \(D \propto N^{\alpha_N/\alpha_D} \approx N^{0.74}\).
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §1.2
- How should a fixed compute budget be split, according to Kaplan et al.?Mostly into model size: \(N \propto C_{\min}^{0.73}\), batch size \(B \propto C_{\min}^{0.24}\), and serial steps \(S \propto C_{\min}^{0.03}\) (almost none). For a billion-fold increase in compute, most should go to a bigger model, a little to more data, and that mostly via larger batches.
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §1.2
1.3 Notation
- How do Kaplan et al. estimate training compute, and why exclude embeddings from \(N\)?\(C \approx 6NBS\) non-embedding FLOPs (about \(2N\) per token forward, twice that backward), quoted in PF-days (\(8.64 \times 10^{19}\) FLOPs). Counting non-embedding parameters gives much cleaner trends: with embeddings, models of different depth seem to follow different curves.
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §1.3
- Estimate the training compute for a model with \(N = 10^9\) non-embedding parameters trained on \(2 \times 10^{10}\) tokens.\(C \approx 6 N D = 6 \cdot 10^9 \cdot 2 \cdot 10^{10} = 1.2 \times 10^{20}\) FLOPs, about \(1.2 \times 10^{20} / 8.64 \times 10^{19} \approx 1.4\) PF-days.
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §1.3
2 Background and Methods
- On what data and models were the scaling laws measured?Decoder-only Transformers (768 to 1.5B non-embedding parameters; also LSTMs and Universal Transformers for comparison) trained on WebText2 (about 23B BPE tokens from Reddit-linked pages through Oct 2018), with 1024-token contexts, cross-entropy loss in nats as the metric.
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §2
- What is the approximate non-embedding parameter count of a Transformer in terms of its shape?\(N \approx 2 d_{\text{model}} n_{\text{layer}} (2 d_{\text{attn}} + d_{ff}) = 12 n_{\text{layer}} d_{\text{model}}^2\) with the standard \(d_{\text{attn}} = d_{ff}/4 = d_{\text{model}}\), ignoring biases and other sub-leading terms.
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §2
3.2.1 Comparing to LSTMs and Universal Transformers
- How did Transformers compare with LSTMs in the scaling study?LSTMs matched Transformers on tokens early in the context but plateaued after under 100 tokens, while Transformers kept improving across the whole context, so Transformers asymptotically outperform LSTMs by using long contexts better.
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §3.2.1
4 Charting the Infinite Data Limit and Overfitting
- How much data avoids overfitting, according to Kaplan et al.?To stay within about 0.02 nats (the seed-to-seed variation) of the infinite-data loss, \(D \gtrsim 5 \times 10^3 \, N^{0.74}\) tokens: data can grow sublinearly with model size, so models under about \(10^9\) parameters barely overfit WebText2’s 22B tokens.
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §4
5.1 Adjustment for Training at B_crit(L)
- What is the critical batch size, and how does it scale?The batch size up to which larger batches cost almost no extra compute; beyond it returns diminish. Training at \(B_{\text{crit}}\) roughly balances time and compute. It depends on the loss, not the model size: \(B_{\text{crit}}(L) \approx B_* / L^{1/\alpha_B}\) with \(B_* \approx 2 \times 10^8\) tokens, \(\alpha_B \approx 0.21\), roughly doubling for every 13% decrease in loss.
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §5.1
5.2 Results for L(N, S_min) and Performance with Model Size and Compute
- How does loss depend on model size and training steps?After a transient, \(L(N, S) = \big(\frac{N_c}{N}\big)^{\alpha_N} + \big(\frac{S_c}{S_{\min}}\big)^{\alpha_S}\) with \(\alpha_S \approx 0.76\), where \(S_{\min}\) adjusts steps to large-batch training; extrapolating early learning curves predicts the loss of longer training.
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §5.2
6.3 Contradictions and a Conjecture
- What contradiction did Kaplan et al. find in their own scaling laws, and what did they conjecture?Compute-efficient training uses data so slowly (\(D \propto C^{0.27}\)) that eventually it would overfit, so the \(L(C_{\min})\) and \(L(D)\) trends must cross, around \(10^4\) PF-days, \(10^{12}\) parameters and \(10^{12}\) tokens (very uncertain). They conjectured this marks where models extract all reliable information from text, with \(L^* \approx 1.7\) nats/token as a rough entropy estimate.
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §6.3
8 Discussion
- How did Kaplan et al. interpret their scaling laws, and what open question did they flag?As analogues of the ideal gas law: universal relations independent of most microscopic details, possibly holding for other generative tasks. Open: whether smooth loss improvements translate into relevant task improvements, since smooth quantitative change can hide qualitative changes (“more is different”); they concluded big models may matter more than big data.
- Kaplan et al., 2020, Scaling Laws for Neural Language Models (arXiv preprint arXiv:2001.08361), §8
Source
- Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B. Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu and Dario Amodei. 2020. Scaling Laws for Neural Language Models. In arXiv preprint arXiv:2001.08361. https://arxiv.org/abs/2001.08361