All papersFoundations Classic
Scaling laws: bigger models, data and compute give smooth gains Paper: Scaling Laws for Neural Language Models
Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B. Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, Dario Amodei · arXiv preprint (OpenAI and Johns Hopkins University) · Posted 23 Jan 2020 · 20 min read · arXiv 2001.08361
1 The problem Show in original Teams must pick model size, data and training time . Nobody knew how loss changes with each. Bad choices waste a lot of compute. seven orders of magnitude of scale, over which smooth trends hold.
2 What they tested Show in original They trained Transformer models on WebText2. Sizes ran from 768 to 1.5 billion non-embedding parameters. Data ran from 22 million to 23 billion tokens. They also varied shape, context length and batch size. 3 What they found Show in original Loss follows power laws in size, data and compute. Shape matters very little. Scale matters most. Large models are more sample-efficient . The best use of compute is a big model, stopped early. In a chart Spend extra compute mostly on a bigger model From Table 6 0 0.25 0.5 0.75 1 Exponent: how fast each part grows with compute (Cmin) Model size 0.73 exponent Data (one epoch) 0.27 exponent Batch size 0.24 exponent Serial steps 0.03 exponent
Hover, tap or focus a bar to read its exact value.
Show as table What grows Exponent Model size 0.73 Data (one epoch) 0.27 Batch size 0.24 Serial steps 0.03
5 Watch out Show in original The fits come from WebText2 and Transformer models. The authors have no theory for why these laws hold. The laws must break down before loss reaches zero. Later work (Chinchilla) re-tested the size-versus-data split. Jump to A The abstract1.1 Summary of key findings1.2 Summary of the scaling laws1.3 Notation2 Background and methods3 Empirical results and basic power laws4 The infinite data limit and overfitting5 Training time and the critical batch size6 Optimal allocation of the compute budget7 Discussion8 SummaryA Appendix A: summary of power lawsB Appendix B: the compute-efficient frontierC Appendix C: caveatsD Appendix D: supplementary results (summary)W Words to knowEvery detail from the paper Cards follow the paper's own order. Dotted words link to Words to know. Numbers match the paper.
A The abstract Show in original The study They study scaling laws for language model cross-entropy loss . Loss follows a power law in model size, data set size and training compute. Some trends span more than seven orders of magnitude. Width and depth have minimal effects within a wide range. What the laws give Simple equations tell how overfitting depends on model and data size. They tell how training speed depends on model size. These let you pick the best split of a fixed compute budget. The surprise Larger models are far more sample-efficient . The best training uses a very large model on modest data. It stops well before convergence. 1.1 Summary of key findings Show in original Why study this Language is a natural domain for AI. Most reasoning tasks can be put in words. Text gives a lot of data for unsupervised learning. They study the Transformer and trends over more than seven orders of magnitude. 1. Scale matters, shape does not Performance depends most on three factors. They are parameters N (without embeddings), data size D and compute C. Depth against width has a very weak effect. 2. Smooth power laws Loss follows a power law in each of N, D and C. This holds when the other two do not limit it. The trends span more than six orders of magnitude. They see no sign of deviation at the top end. Loss must flatten out before it reaches zero. 3. Overfitting Gains stay predictable if you scale N and D together. If either is fixed, returns shrink. The penalty depends on the ratio N^0.74 / D. Each 8x in model size needs only about 5x more data to avoid a penalty. 4. Training is universal Training curves follow power laws, with parameters near-independent of model size. Extrapolating the early curve predicts the loss after much longer training. 5. Transfer On other text types, loss tracks the training-set loss with a near-constant offset. So transfer to a new distribution costs a constant penalty. 6. Sample efficiency Large models reach the same loss with fewer steps and fewer data points. 7. Convergence is inefficient With fixed compute and no other limits, train very large models and stop short. Data needs grow very slowly: D grows like C^0.27. 8. Batch size The best batch size follows a power of the loss, and the gradient noise scale. It is roughly 1-2 million tokens at convergence for the largest models. Overall Performance improves smoothly and predictably as you scale model, data and compute. Larger models will do better and be more sample-efficient. 1.2 Summary of the scaling laws Show in original Three laws Law 1: with limited parameters, trained to convergence on enough data. L(N) = (Nc / N)^αN, with αN about 0.076 and Nc about 8.8 x 10^13. Law 2: a large model with limited data and early stopping. L(D) = (Dc / D)^αD. αD is about 0.095. Dc is about 5.4 x 10^13 tokens. Law 3: limited compute, enough data, a best-size model and a small enough batch. L(Cmin) = (Ccmin / Cmin)^αCmin. αCmin is about 0.050. Ccmin is about 3.1 x 10^8 PF-days. Loss falls with each factor at a different, slow rate From Table 5 0 0.25 0.5 0.75 1 Power-law exponent Parameters (αN) 0.076 exponent Data (αD) 0.095 exponent Compute, fixed batch (αC) 0.057 exponent Compute, best batch (αC min) 0.050 exponent Critical batch (αB) 0.210 exponent Training steps (αS) 0.760 exponent
Hover, tap or focus a bar to read its exact value.
Show as table Law Exponent Parameters (αN) 0.076 Data (αD) 0.095 Compute, fixed batch (αC) 0.057 Compute, best batch (αC min) 0.050 Critical batch (αB) 0.210 Training steps (αS) 0.760
Reading the exponents These hold over eight orders of magnitude in Cmin and six in N. They hold over two orders of magnitude in D. They depend weakly on depth, width and the number of heads. Doubling the parameters cuts loss by a factor of 2^-αN, which is 0.95. The values of Nc, Ccmin and Dc depend on tokenization, so have no deep meaning. The critical batch size Bcrit(L) = B* / L^(1/αB). B* is about 2 x 10^8 tokens. αB is about 0.21. It depends only on the loss. Data against model size Equations 1.1 and 1.2 suggest data should grow like N^αD, about N^0.74. One equation joins them and governs overfitting. L(N, D) = [(Nc / N)^(αN/αD) + Dc / D]^αD. They guess this form may fit other generative tasks too. Training time For a finite number of steps S, with infinite data, the learning curve fits: L(N, S) = (Nc / N)^αN + (Sc / Smin(S))^αS. Sc is about 2.1 x 10^3. αS is about 0.76. Smin(S) is the fewest possible update steps. Best allocation of compute With a fixed budget, N, B and S grow as C^(αC/αN), C^(αC/αB) and C^(αC/αS). Data D equals B x S. Here αC = 1 / (1/αS + 1/αB + 1/αN). This matches the best results: N ∝ Cmin^0.73, B ∝ Cmin^0.24 and S ∝ Cmin^0.03. So spend extra compute mostly on bigger models. Training time and data barely change. Extras The paper adds theory for equation 1.5 and a per-token breakdown. It also compares to LSTMs and recurrent Transformers. 1.3 Notation Show in original Symbols L: cross-entropy loss in nats, averaged over tokens in a context. N: model parameters, excluding vocabulary and position embeddings. C ≈ 6NBS: an estimate of total non-embedding training compute. B is the batch size. S is the number of update steps. One PF-day is 10^15 x 24 x 3600 = 8.64 x 10^19 floating point operations. More symbols Bcrit: the critical batch size, a good trade between time and compute. Cmin: the least compute to reach a loss, at a small batch size. Smin: the fewest steps to reach a loss, at a large batch size. αX: the power-law exponent in L(X) ∝ 1/X^αX. 2 Background and methods Show in original 2.1 Setup and parameter counts Data and model They train on WebText2, an extended WebText. They use byte-pair encoding with a vocabulary of 50257. The main metric is loss on a 1024 token context. They mostly train decoder-only Transformers. They also train LSTMs and Universal Transformers to compare. Shape settings nlayer is the number of layers. dmodel is the size of the residual stream. dff is the feed-forward size. dattn is the attention output size. nheads is the number of heads per layer. nctx is the context size, 1024 unless noted. Model size N counts only non-embedding parameters, N ≈ 12 nlayer dmodel^2. Embeddings are left out. This gives much cleaner laws. A forward pass costs about 2N add-multiply operations per token. The backward pass costs about twice that. So C ≈ 6N per training token. Context-dependent cost is small when dmodel is much more than nctx / 12. 2.2 Training procedures Default: Adam, for a fixed 2.5 x 10^5 steps. Batch size 512 sequences of 1024 tokens. Models over 1B parameters used Adafactor, because of memory. Results at convergence barely depend on the learning rate schedule. Default schedule: 3000 step linear warmup, then cosine decay to zero. 2.3 Datasets WebText2 WebText was a scrape of outbound Reddit links up to December 2017. Each link had at least 3 karma. WebText2 adds links from January to October 2018, also with 3 karma. Total: 20.3M documents with 96 GB of text and 1.62 x 10^10 words. The tokenizer gives 2.29 x 10^10 tokens. They keep 6.6 x 10^8 tokens as a test set. They also test on Books Corpus, Common Crawl, English Wikipedia and more. What they varied Model size: 768 to 1.5 billion non-embedding parameters. Data size: 22 million to 23 billion tokens. Shape: depth, width, heads and feed-forward size. Context length: 1024 for most runs. Batch size: 2^19 tokens for most runs. 3 Empirical results and basic power laws Show in original Overview This section shows data with fits. Theory comes later. It covers shape, parameter count, other text types, data size and compute. 3.1 Shape and hyperparameter independence Method Performance depends very weakly on nlayer, nheads and dff at a fixed N. They varied one setting while holding N fixed. When they varied nlayer, they changed dmodel to keep N ≈ 12 nlayer dmodel^2. For dff, they also changed dmodel. What they found Loss varies only a few percent over a wide range of shapes. The aspect ratio can change by a factor of 40 with a small effect. A (6, 4288) shape is within 3% of the (48, 1600) model. That model was used in earlier work. Independence from depth would follow if deep models act as ensembles of shallow ones. 3.2 Performance with parameter count N Method They trained models from (2, 128) up to billion-parameter shapes. Shapes ran from (6, 4288) to (207, 768). They trained to near convergence on all of WebText2. They saw no overfitting, except maybe in the very largest models. What they found A steady power-law trend appears with non-embedding parameters N. With embeddings counted, the trend is blurred, as Figure 6 shows. So the embedding matrix could be smaller with no cost. Loss on other text types is also a power law in N. The exponent is nearly the same. 3.2.1 Against LSTMs LSTMs match Transformers for tokens early in the context. They cannot match Transformers for later tokens. Bigger models show larger exponents by position. Recurrent Transformers reuse parameters, so they do slightly better per parameter. They do slightly worse per unit of compute. 3.2.2 Other text types Models trained only on WebText2 were tested on other text sets. Loss on these improves smoothly with size, in parallel with WebText2. Generalization depends almost only on in-distribution loss. It does not depend on training time or closeness to convergence. It does not depend on depth either. 3.3 Performance with data size and compute Data size They trained a (36, 1280) model on fixed subsets of WebText2. They stopped when test loss stopped falling. The result fits a power law in dataset size. Compute Compute is C = 6NBS. For each C, they scan models of different N to find the best loss. Batch size B stayed fixed, so these results are not truly best. Later sections fix this with an adjusted Cmin. The data suggests sample efficiency improves with model size. 4 The infinite data limit and overfitting Show in original 4.1 The L(N, D) equation Three rules for the form One: a change in vocabulary should only rescale the loss. Two: fix D and let N grow large, and loss should approach L(D). Three: L(N, D) should be analytic at D = infinity. Support for the third rule is weaker. Why it makes sense Nc and Dc can be rescaled when vocabulary changes. So they have no fundamental meaning. A bigger model with early stopping should always beat a smaller one. With limited D, no model can reach the entropy of text. Overfitting should scale like 1/D at large D, since variance scales as 1/D. This explains why N and D play different roles in equation 1.5. 4.2 Results The fit They used 10% dropout and early stopping. Table 2 gives the fit of equation 1.5. The fit is excellent, with one exception. The exception: D cut by 1024 to about 2 x 10^7 tokens. There an epoch is only 40 updates, and overfitting starts very early. αN αD Nc Dc 0.076 0.103 6.4 x 10^13 1.8 x 10^13
Table 2: fits to L(N, D)
These differ slightly from Section 3, because the whole of L(N, D) is fit.
How much data to avoid overfitting On the full 22B token set, all but the largest models show no overfitting. Overfitting δL depends on one mix of N and D. The loss varies by about 0.02 across random seeds. Staying within that margin needs D ≳ (5 x 10^3) N^0.74. Models under 10^9 parameters train with little overfitting on the 22B token set. The largest models meet some mild overfitting. Data can grow sub-linearly with model size. This is not usually maximally compute-efficient. They did not tune regularization while varying data and model size. 5 Training time and the critical batch size Show in original Plan A simple law fits loss as a function of model size N and training time. Most models were not trained at the best batch size. So they define a universal step count Smin. Then they fit L(N, Smin) with equation 1.6. 5.1 Adjusting for the critical batch size The idea The critical batch size Bcrit is the point past which bigger batches give small gains. Up to Bcrit, a bigger batch costs almost no compute efficiency. Past Bcrit, returns shrink. Best practice is B ≈ Bcrit. A tiny batch minimizes compute. A huge batch minimizes steps. The relation For a fixed loss, steps S and examples E = BS follow a simple rule. The rule is (S / Smin - 1)(E / Emin - 1) = 1. Training at Bcrit takes 2Smin steps and 2Emin examples. They confirm this for Transformers. What they found Bcrit depends only on the loss, not on model size. It roughly doubles for every 13% decrease in loss. It is not far from the gradient noise scale. They fit Bcrit(L) = B* / L^(1/αB). They use Smin and Cmin for later analysis. 5.2 L(N, Smin) results The fit They fit stable Adam-trained runs after warmup with equation 1.6. Table 3 gives the parameters. The fits are imperfect but good for such a simple equation. Fits are poor at small S, as the power law needs time to settle. αN αS Nc Sc 0.077 0.76 6.5 x 10^13 2.1 x 10^3
Table 3: fits to L(N, S)
Meaning The power law in Smin reflects the optimizer and the loss landscape. It hints that the Hessian spectrum is about the same across model sizes. 5.3 A lower bound on the early stopping step Finite and infinite D curves match until Smin reaches Sstop. This gives a lower bound on when early stopping should happen. It is an underestimate, since loss falls more slowly with finite D. Figure 16 compares the bound to data. 6 Optimal allocation of the compute budget Show in original How to spend 10x more compute From Section 6.1 Get 10x more compute Grow the model about 5x Process only about 2x more data Serial steps barely change Stop well before convergence Most of the extra data goes into bigger batches, not more steps.
6.1 Optimal performance and allocations Loss against best compute They plot loss against the best-allocated compute Cmin in Figure 13. The trend is cleaner than the fixed batch plot. They also find the best model size N(Cmin). The finding Model size grows very fast with Cmin: 5x for each 10x of compute. Examples processed grow by only 2x. Batch-adjusted steps grow very slowly, if at all. Since Cmin = 6N Bcrit S, the best steps grow like Cmin^0.03. So scale up N and the batch size B ∝ Bcrit. Serial steps barely grow. Compute-efficient training uses few steps. Work on early training speed may pay off. Spend extra compute mostly on a bigger model From Table 6 0 0.25 0.5 0.75 1 Exponent: how fast each part grows with compute (Cmin) Model size 0.73 exponent Data (one epoch) 0.27 exponent Batch size 0.24 exponent Serial steps 0.03 exponent
Hover, tap or focus a bar to read its exact value.
Show as table What grows Exponent Model size 0.73 Data (one epoch) 0.27 Batch size 0.24 Serial steps 0.03
Off-size models Figure 12 shows training models of non-best sizes (Appendix B.4). Quantity Power law Exponent Scale Model size N Ne x Cmin^pN 0.73 1.3 x 10^9 parameters Batch size B Be x Cmin^pB 0.24 2.0 x 10^6 tokens Steps Smin (lower bound) Se x Cmin^pS 0.03 5.4 x 10^3 steps Data Dopt (1 epoch) De x Cmin^pD 0.27 2 x 10^10 tokens
Table 6: compute-efficient allocation
6.2 Predictions from L(N, Smin) They derive the compute results from the L(N, Smin) equation. Appendix B has the detail. They predict L(Cmin) with an exponent that agrees with Figure 13. They predict the best N(Cmin), within a few percent of Figure 14. So the laws give a predictive tool. 6.3 Contradictions and a conjecture No sign of bending They see no deviation from power laws at high compute, data or size. But trends must level off, since natural language has non-zero entropy. The contradiction At huge scale, L(Cmin) predicts a loss below what the data allows. Compute-efficient training needs data that grows only slowly. So the L(Cmin) line meets the L(D) bound at some point. Training for one epoch gives D growing slower than overfitting allows. The laws must break down before this point. The crossing point The values are very uncertain, by an order of magnitude either way. C* about 10^4 PF-days, N* about 10^12 parameters. D* about 10^12 tokens, and L* about 1.7 nats per token. The authors guess that L* may estimate the entropy of natural language. They expect loss to level off at or before L*. A noise-floor idea: add random text to shift the loss by a constant. Then distance above the floor is a better measure of progress. 7 Discussion Show in original Related ideas Power laws come from many sources. Early work found power laws between performance and data size. One earlier study found data grows faster than model size. This paper finds slower. EfficientNets scale depth and width. For language, width over depth should stay fixed. Architecture details matter less than overall scale. They see no 'jamming transition' when model size reaches data size. What the results say Loss scales as power laws in N, D and Cmin. Ties to other settings are weak. Power laws mean diminishing returns. The equations give predictions, not only observations. They are like an ideal gas law: universal, whatever the fine details. Open questions Do the laws apply to images, audio and video? No theory yet explains them. A 'statistical mechanics' view is needed. Does lower loss give better task skills? Smooth change can hide big shifts in ability: 'more is different'. Big models may matter more than big data. Future parallelism Deep models train with pipelining. Wide ones split across workers more easily. Sparsity, branching and growing networks may speed training further. 8 Summary Show in original The summary Loss follows power laws in N, D and optimized compute Cmin. It depends very weakly on many other settings. They model loss in N and D, and in N and S. They derived compute scaling, overfitting size, early stopping and data needs. Larger models will keep improving and be far more sample-efficient than thought. A Appendix A: summary of power laws Show in original Parameters Data Compute Batch size N infinite infinite Fixed infinite D Early stop Fixed Optimal infinite C Fixed Nopt Dopt Cmin B much more than Bcrit N D Early stop Fixed N infinite S steps B
Table 4: the laws and when they hold
In order: L(N), L(D), L(C) naive, L(Cmin), L(N, D), L(N, S).
Law Exponent Scale Unit αN 0.076 Nc = 8.8 x 10^13 params, non-embedding αD 0.095 Dc = 5.4 x 10^13 tokens αC 0.057 Cc = 1.6 x 10^7 PF-days αC min 0.050 Ccmin = 3.1 x 10^8 PF-days αB 0.21 B* = 2.1 x 10^8 tokens αS 0.76 Sc = 2.1 x 10^3 steps
Table 5: fitted values
Scales depend on tokenization.
B Appendix B: the compute-efficient frontier Show in original Convergence factor Researchers usually train near convergence. The paper defines a convergence factor f. Compute-efficient training has f = αN/αS, about 10%. Typical practice uses a smaller value, which they set at f' = 2%. Compute-efficient training then uses 7.7x fewer updates and 2.7x more parameters. It also uses 65% less compute. Off-size models Models between 0.6x and 2.2x the best size cost only 20% more compute. A smaller model helps if inference cost matters. A 2.2x larger model needs 45% fewer steps for 20% more compute. This helps when hardware allows more parallelism. It should not be trusted for very large models. C Appendix C: caveats Show in original Limits the authors list There is no solid theory for the scaling laws. Scaling with model size and compute is especially mysterious. It is hard to know when the laws can be trusted. They are not confident of Bcrit(L) far outside the range tested. More limits They did not study the small data regime well. The fits for L(N, D) were poor at the smallest D. They did not test regularization or data augmentation. C ≈ 6NBS ignores terms tied to nctx. This matters when nctx is above about 12 dmodel. They may have missed tuning a setting, such as initialization scale or momentum. The best learning rate depends on the target loss. They did not test higher rates for short runs. D Appendix D: supplementary results (summary) Show in original What it holds Appendix D has extra figures and fits (D.1 to D.8). Figure 16 shows the early stopping step against overfitting. It also shows train and test loss for 300M parameter models on data subsets. Figure 17 compares recurrent Transformers, which reuse parameters, with standard ones. Figure 18 shows fits of the batch size relation used to measure Bcrit. Coverage note The paper has 30 pages. The main body is covered in full above. Appendix D is summarized only. Its figures are not copied. Words to know Cross-entropy loss: A score of how badly the model predicts the next token. Lower is better.Sample-efficient: Reaching a good score with fewer training examples.Ask AI about this paper Stuck on a word or an idea? Ask in plain words. The answer comes from the write-up on this page.
Ask AI about this paper Explain it like I am new to AI How would a finance team use this? What are the limits?
Jump to