{"notes":[{"id":"transformers/scaling_laws","category":"transformers","legacyPath":"transformers/2001-scaling_laws","legacySlug":"2001-scaling_laws","legacyPaths":[],"title":"Scaling Laws","subtitle":"Scaling Laws for Neural Language Models","author":"Z. Yuan","paperDate":"2020-01-23","publishedOn":"2024-05-24","paperTitle":"Scaling Laws for Neural Language Models","paperUrl":"https://arxiv.org/abs/2001.08361","bibliography":{"title":"Scaling Laws for Neural Language Models","authors":["Jared Kaplan","Sam McCandlish","Tom Henighan","Tom B. Brown","Benjamin Chess","Rewon Child","Scott Gray","Alec Radford","Jeffrey Wu","Dario Amodei"],"url":"https://arxiv.org/abs/2001.08361","pdfUrl":"https://arxiv.org/pdf/2001.08361","codeUrl":null,"preprint":{"id":"2001.08361","submittedOn":"2020-01-23","url":"https://arxiv.org/abs/2001.08361"},"publication":null,"citation":"@misc{transformersscalinglaws2020,\n  title = {{Scaling Laws for Neural Language Models}},\n  author = {Jared Kaplan and Sam McCandlish and Tom Henighan and Tom B. Brown and Benjamin Chess and Rewon Child and Scott Gray and Alec Radford and Jeffrey Wu and Dario Amodei},\n  year = {2020},\n  eprint = {2001.08361},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2001.08361}\n}\n","citationPath":"/content/papers/citations/transformers/scaling_laws.a1ab0069ac66.bib"},"thumbnail":{"src":"/content/papers/assets/1a680a937f0c09dd160f2661fc04c4598f9bec153e122a7b92c264ef213558c1.jpg","width":1696,"height":544},"locale":"en","path":"/content/papers/en/transformers/scaling_laws.f5c1f7d57894.md","headings":[{"id":"problem-definition","text":"Problem Definition","depth":2},{"id":"solution","text":"Solution","depth":2},{"id":"training-process","text":"Training Process","depth":3},{"id":"dataset","text":"Dataset","depth":3},{"id":"variation-factors","text":"Variation Factors","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"size-matters-most","text":"Size Matters Most","depth":3},{"id":"power-laws","text":"Power Laws","depth":3},{"id":"the-universality-of-overfitting","text":"The Universality of Overfitting","depth":3},{"id":"test-performance-vs-downstream-performance","text":"Test Performance vs. Downstream Performance","depth":3},{"id":"sample-efficiency","text":"Sample Efficiency","depth":3},{"id":"convergence-is-inefficient","text":"Convergence is Inefficient","depth":3},{"id":"optimal-batch-size","text":"Optimal Batch Size","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"transformers/gpt_3","relation":"background","topic":"Trading model size against training data"},{"id":"transformers/chinchilla","relation":"next","topic":"Trading model size against training data"}]},{"id":"transformers/gpt_3","category":"transformers","legacyPath":"transformers/2005-gpt_3","legacySlug":"2005-gpt_3","legacyPaths":[],"title":"GPT-3","subtitle":"Ninety-Six Layer Decoder","author":"Z. Yuan","paperDate":"2020-05-28","publishedOn":"2024-06-04","paperTitle":"Language Models are Few-Shot Learners","paperUrl":"https://arxiv.org/abs/2005.14165","bibliography":{"title":"Language Models are Few-Shot Learners","authors":["Tom B. Brown","Benjamin Mann","Nick Ryder","Melanie Subbiah","Jared Kaplan","Prafulla Dhariwal","Arvind Neelakantan","Pranav Shyam","Girish Sastry","Amanda Askell","Sandhini Agarwal","Ariel Herbert-Voss","Gretchen Krueger","Tom Henighan","Rewon Child","Aditya Ramesh","Daniel M. Ziegler","Jeffrey Wu","Clemens Winter","Christopher Hesse","Mark Chen","Eric Sigler","Mateusz Litwin","Scott Gray","Benjamin Chess","Jack Clark","Christopher Berner","Sam McCandlish","Alec Radford","Ilya Sutskever","Dario Amodei"],"url":"https://arxiv.org/abs/2005.14165","pdfUrl":"https://arxiv.org/pdf/2005.14165","codeUrl":null,"preprint":{"id":"2005.14165","submittedOn":"2020-05-28","url":"https://arxiv.org/abs/2005.14165"},"publication":{"venue":"NeurIPS","year":2020,"kind":"conference","url":"https://proceedings.neurips.cc/paper_files/paper/2020/hash/1457c0d6bfcb4967418bfb8ac142f64a-Abstract.html"},"citation":"@misc{transformersgpt32020,\n  title = {{Language Models are Few-Shot Learners}},\n  author = {Tom B. Brown and Benjamin Mann and Nick Ryder and Melanie Subbiah and Jared Kaplan and Prafulla Dhariwal and Arvind Neelakantan and Pranav Shyam and Girish Sastry and Amanda Askell and Sandhini Agarwal and Ariel Herbert-Voss and Gretchen Krueger and Tom Henighan and Rewon Child and Aditya Ramesh and Daniel M. Ziegler and Jeffrey Wu and Clemens Winter and Christopher Hesse and Mark Chen and Eric Sigler and Mateusz Litwin and Scott Gray and Benjamin Chess and Jack Clark and Christopher Berner and Sam McCandlish and Alec Radford and Ilya Sutskever and Dario Amodei},\n  year = {2020},\n  eprint = {2005.14165},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2005.14165}\n}\n","citationPath":"/content/papers/citations/transformers/gpt_3.e117d4f773ec.bib"},"thumbnail":{"src":"/content/papers/assets/7cf129fba1be78b1b43198edc35c44063ba70cb8fc082136055a265ee022b092.jpg","width":1204,"height":1080},"locale":"en","path":"/content/papers/en/transformers/gpt_3.091cea326188.md","headings":[{"id":"problem-definition","text":"Problem Definition","depth":2},{"id":"diverse-language-task-requirements","text":"Diverse Language Task Requirements","depth":3},{"id":"dependence-on-large-supervised-datasets","text":"Dependence on Large Supervised Datasets","depth":3},{"id":"over-specialization-and-generalization-issues","text":"Over-Specialization and Generalization Issues","depth":3},{"id":"human-learning-efficiency-vs-model-efficiency","text":"Human Learning Efficiency vs. Model Efficiency","depth":3},{"id":"solution","text":"Solution","depth":2},{"id":"model-architecture","text":"Model Architecture","depth":3},{"id":"dataset-setup","text":"Dataset Setup","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"lambada","text":"LAMBADA","depth":3},{"id":"closed-book-question-answering","text":"Closed Book Question Answering","depth":3},{"id":"conclusion","text":"Conclusion","depth":2},{"id":"1-gender-bias","text":"1. Gender Bias","depth":3},{"id":"2-racial-bias","text":"2. Racial Bias","depth":3},{"id":"3-religious-bias","text":"3. Religious Bias","depth":3}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"transformers/gpt_2","relation":"background","topic":"From language pretraining to in-context learning"},{"id":"transformers/scaling_laws","relation":"next","topic":"Trading model size against training data"},{"id":"model-evaluation/jev-evaluation","relation":"comparison","topic":"Adapting to a task through prompts or structured decisions"}]},{"id":"transformers/chinchilla","category":"transformers","legacyPath":"transformers/2203-chinchilla","legacySlug":"2203-chinchilla","legacyPaths":[],"title":"Chinchilla","subtitle":"Chinchilla's Gaze","author":"Z. Yuan","paperDate":"2022-03-29","publishedOn":"2024-12-13","paperTitle":"Training Compute-Optimal Large Language Models","paperUrl":"https://arxiv.org/abs/2203.15556","bibliography":{"title":"Training Compute-Optimal Large Language Models","authors":["Jordan Hoffmann","Sebastian Borgeaud","Arthur Mensch","Elena Buchatskaya","Trevor Cai","Eliza Rutherford","Diego de Las Casas","Lisa Anne Hendricks","Johannes Welbl","Aidan Clark","Tom Hennigan","Eric Noland","Katie Millican","George van den Driessche","Bogdan Damoc","Aurelia Guy","Simon Osindero","Karen Simonyan","Erich Elsen","Jack W. Rae","Oriol Vinyals","Laurent Sifre"],"url":"https://arxiv.org/abs/2203.15556","pdfUrl":"https://arxiv.org/pdf/2203.15556","codeUrl":null,"preprint":{"id":"2203.15556","submittedOn":"2022-03-29","url":"https://arxiv.org/abs/2203.15556"},"publication":{"venue":"NeurIPS","year":2022,"kind":"conference","url":"https://doi.org/10.52202/068431-2176"},"citation":"@misc{transformerschinchilla2022,\n  title = {{Training Compute-Optimal Large Language Models}},\n  author = {Jordan Hoffmann and Sebastian Borgeaud and Arthur Mensch and Elena Buchatskaya and Trevor Cai and Eliza Rutherford and Diego de Las Casas and Lisa Anne Hendricks and Johannes Welbl and Aidan Clark and Tom Hennigan and Eric Noland and Katie Millican and George van den Driessche and Bogdan Damoc and Aurelia Guy and Simon Osindero and Karen Simonyan and Erich Elsen and Jack W. Rae and Oriol Vinyals and Laurent Sifre},\n  year = {2022},\n  eprint = {2203.15556},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2203.15556}\n}\n","citationPath":"/content/papers/citations/transformers/chinchilla.431d422c0970.bib"},"thumbnail":{"src":"/content/papers/assets/834457a467c9947344ae6910ab4baffd6be26ccd2be38c97bfd8a6c5d9f4bd5d.jpg","width":1660,"height":456},"locale":"en","path":"/content/papers/en/transformers/chinchilla.8eb9e6a0f75c.md","headings":[{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"approach-1-fixed-model-size-n","text":"Approach 1: Fixed Model Size (N)","depth":3},{"id":"approach-2-fixed-compute-budget-c","text":"Approach 2: Fixed Compute Budget (C)","depth":3},{"id":"approach-3-unified-parametric-model","text":"Approach 3: Unified Parametric Model","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"chinchillas-performance","text":"Chinchilla's Performance","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{"approach-2-fixed-training-data-size-d":"approach-2-fixed-compute-budget-c"},"guide":null,"relatedReading":[{"id":"transformers/scaling_laws","relation":"background","topic":"Trading model size against training data"}]}],"text":"OpenAI has been pushing the boundaries with the Transformer decoder architecture.\n\n## Problem Definition\n\nFrom previous articles, you might have noticed OpenAI's ambition: they aim to build a \"super-large\" language model.\n\nThus, this study addresses a fundamental question:\n\n- How exactly should one scale up a model?\n\nThis question is the core challenge this paper aims to solve.\n\n## Solution\n\nIn this paper, the following hyperparameters are used to parameterize the Transformer architecture:\n\n- **The dimension of the residual stream (model width)**\n- **The dimension of the feed-forward layer**\n- **The dimension of the attention output**\n- **The number of attention heads per layer**\n- **The number of layers**: The depth of the Transformer\n- **The number of tokens**: The context length, typically set to 1024\n\nThe paper measures language-model performance by autoregressive cross-entropy loss on the WebText2 test set. Below, model size $N$ counts parameters **excluding vocabulary and positional embeddings**.\n\n### Training Process\n\nUnless otherwise specified, the models are trained using the Adam optimizer for $2.5\\times10^{5}$ steps, with a batch size of 512 sequences, each containing 1024 tokens. Due to memory limitations, models with more than 1 billion parameters use Adafactor for training.\n\nThe authors tested several learning rates and schedules. In these settings, results near convergence were relatively insensitive to the choice of schedule. Unless stated otherwise, runs use a 3000-step linear warm-up followed by cosine decay to zero.\n\n### Dataset\n\nThe models are trained on an \"extended version of the WebText dataset.\"\n\n- The original WebText dataset uses outbound Reddit links through December 2017 with at least three karma points; that threshold is not a count of individually checked readers.\n- WebText2 adds outbound links from January through October 2018 under the same minimum three-karma threshold.\n- The text from these links was extracted using the Newspaper3k Python library, resulting in a dataset containing 20.3 million documents, totaling 96GB of text and $1.62\\times10^{10}$ words.\n- Byte-pair encoding (BPE) was applied for tokenization, yielding $2.29\\times10^{10}$ tokens, with $6.6\\times10^{8}$ tokens reserved for the test set.\n- The models were evaluated on Books Corpus, Common Crawl, English Wikipedia, and other publicly available online book samples.\n\n### Variation Factors\n\nTo comprehensively study the scaling characteristics of language models, this paper conducted extensive model training with variations in the following aspects:\n\n- **Model size**: Models ranging from 768 to 1.5 billion non-embedding parameters\n- **Dataset size**: Datasets ranging from 22 million to 23 billion tokens\n- **Model shape**: Including depth, width, number of attention heads, and feed-forward layer dimensions\n- **Context length**: Most training uses a context length of 1024, but shorter contexts were also tested\n- **Batch size**: Most training uses $2^{19}$ tokens per batch—that is, 512 sequences of 1024 tokens—but batch sizes were varied to measure the critical batch size\n\nThese experimental designs aim to systematically investigate the performance of models under different conditions and derive relevant scaling laws.\n\n## Discussion\n\n### Size Matters Most\n\nWithin the study’s experimental range, language-model cross-entropy loss depends strongly on scale and less on moderate changes in depth-to-width ratio. The three scale variables are:\n\n1. **N: Number of non-embedding parameters**\n2. **D: Dataset size**\n3. **C: Training compute used**\n\nExperiments indicate that within a reasonable range, performance dependency on other architectural hyperparameters (such as depth and width) is minimal.\n\n### Power Laws\n\n![Figure 1: fitted WebText2 test loss against training compute, dataset tokens and non-embedding parameters](/content/papers/assets/1a680a937f0c09dd160f2661fc04c4598f9bec153e122a7b92c264ef213558c1.jpg)\n\nWhen the other two factors are not bottlenecks, test loss follows an approximate power law with each of $N$, $D$, and compute. The plots cover different horizontal ranges. In the left plot, compute is the batch-efficiency-adjusted minimum $C_{min}$, rather than raw compute measured for every run.\n\n- **Left chart**: As $C_{min}$ increases, the lower envelope of test loss falls; pale-blue lines show individual training runs.\n- **Middle chart**: With model shape fixed, increasing the number of dataset tokens lowers early-stopped test loss.\n- **Right chart**: When trained toward convergence on enough data, models with more non-embedding parameters have lower test loss.\n\n\n> [!TIP]\n> \n> You might think this sounds like stating the obvious.\n> \n> It is not. What matters here is that, for the Transformers, WebText2 data, and loss metric studied in this paper, simple power laws fit curves spanning multiple orders of magnitude. The paper does not show that all architectures or data distributions share the same exponents.\n\n\n### The Universality of Overfitting\n\nExperiments indicate that when $N$ and $D$ grow together, early-stopped test loss predictably falls. If one is held fixed while the other grows, returns diminish. In this fit, the extra loss from the data bottleneck depends mainly on $N^{0.74}/D$: an eightfold increase in parameters calls for roughly five times as much data to keep the bottleneck at a similar level.\n\n### Test Performance vs. Downstream Performance\n\nWhen the models are evaluated on text from a distribution different from the training data, their loss tracks loss on the training validation set closely, with a roughly constant offset.\n\nIn other words, transfer to another text distribution incurs a roughly constant loss penalty, but otherwise improves along with in-distribution performance. This is about language-model loss, not a fixed accuracy gain on every downstream task.\n\n### Sample Efficiency\n\n![Figures 2 and 4 combined: upper plots show tokens/compute versus loss; lower plots show dataset size/steps versus loss](/content/papers/assets/2462204a5a5ec66c29def899e4a13dadc1baa5a436b2549836ddb09836e180a3.jpg)\n\nThis imported image combines paper Figure 2 on top and Figure 4 below. The upper-left plot uses tokens processed as its horizontal axis, and the upper-right uses compute. The lower-left compares dataset sizes, while the lower-right compares estimated minimum training steps. For the same test loss, a larger model usually needs fewer data tokens or steps, even though each step costs more compute.\n\n### Convergence is Inefficient\n\n![Figure 3: schematic fixed-compute allocation inferred from the 2020 fits, not a single measured run](/content/papers/assets/7a03dae861a5d3e9723c8224acea5f3e3e572abeff05f9fce99712c827f34534.jpg)\n\nFigure 3 illustrates a **billionfold increase in compute** allocated among model size, batch size, and serial steps according to the authors' fitted laws. It is a scenario, not a measured training curve.\n\nFor a fixed compute budget under the paper's WebText2 fit, and with no separate limit on model size or available data, choosing a larger model and stopping before convergence can yield lower loss than training a smaller model to convergence. The fit predicts rapid growth in the compute-efficient model size and much slower growth in data processed. If data is limited, repeatedly reused, or compute goes far beyond the measured range, the allocation in the figure cannot simply be carried over. Later [Chinchilla](/blog/papers/transformers/chinchilla) also finds a different parameter/data allocation.\n\n### Optimal Batch Size\n\nThe optimal batch size for training language models is not fixed but related to the loss function and can be determined by measuring the gradient noise scale.\n\nFor the largest model (about 1.5B non-embedding parameters), the estimated critical batch size **near convergence** is roughly 1–2 million tokens. It changes with the target loss and marks an approximate trade-off between training steps and compute efficiency, not a fixed setting for every phase.\n\n\n> [!TIP]\n> \n> Those 1–2 million are **tokens**, not sequences. At 1024 tokens per sequence, that is roughly 1,000–2,000 sequences in a batch. This estimate is for loss near convergence; it is not the best batch size for every training stage.\n\n\n## Conclusion\n\nThis paper conducted extensive experiments and summarized the training methods for language models.\n\nTo us, these conclusions are represented by large sums of money, and we gratefully accept these experimental results.\n","imageSizes":{"/content/papers/assets/1a680a937f0c09dd160f2661fc04c4598f9bec153e122a7b92c264ef213558c1.jpg":{"width":1696,"height":544},"/content/papers/assets/2462204a5a5ec66c29def899e4a13dadc1baa5a436b2549836ddb09836e180a3.jpg":{"width":2809,"height":2030},"/content/papers/assets/7a03dae861a5d3e9723c8224acea5f3e3e572abeff05f9fce99712c827f34534.jpg":{"width":1224,"height":560}}}
