AI Logic

Architectures

Chinchilla

Updated:

The idea behind Chinchilla. On the left, the relationship between parameter count and loss at fixed compute, computed from the paper's loss formula (a valley-shaped curve with its minimum for each compute budget; on the curve for Gopher's compute, points for Gopher at 280 billion and Chinchilla at 70 billion). On the right, bar charts comparing Gopher and Chinchilla in parameter count, training tokens, training compute, and MMLU accuracy

Background and Overview

Chinchilla is a 70-billion-parameter language model built on the analysis that for a fixed training compute budget, it is optimal to scale model size and the number of training tokens in equal proportion. It was presented in 2022 by Hoffmann et al. at DeepMind in the paper "Training Compute-Optimal Large Language Models."

Large language models of the time, such as GPT-3 (175 billion), Gopher (280 billion), and Megatron-Turing NLG (530 billion), had grown greatly in parameter count, but the number of training tokens stayed at about 300 billion. This was because earlier work (Kaplan et al. 2020) recommended that a 10× increase in compute be spent on a 5.5× larger model and only 1.8× more tokens.

The Chinchilla paper revisited this question by training more than 400 models with 70 million to 16 billion parameters on 5 to 500 billion tokens. Its conclusions are as follows.

  • When increasing compute, every doubling of model size should be matched by a doubling of the number of training tokens.
  • By this standard, the large language models of the time were undertrained for their size.

To verify this, Chinchilla was trained with the same compute as Gopher, at one quarter the size (70 billion) and on more than four times as much data (1.4 trillion tokens). Chinchilla outperformed Gopher, GPT-3, Megatron-Turing NLG, and others on most tasks, reaching 67.6% 5-shot accuracy on MMLU, 7.6 points above Gopher (60.0%). Because it is small, fine-tuning and inference are also cheaper.

Theory: Finding the Optimal Compute Allocation

The paper solves the following problem. Let NN be the number of parameters, DD the number of training tokens, and CC the training compute (number of floating-point operations). Given a fixed compute CC, find the NN and DD that minimize the final loss LL.

Nopt(C), Dopt(C)=argminN, D s.t. FLOPs(N,D)=CL(N,D)N_{\mathrm{opt}}(C),\ D_{\mathrm{opt}}(C) = \mathop{\mathrm{argmin}}_{N,\,D \ \text{s.t.}\ \mathrm{FLOPs}(N, D) = C} L(N, D)

Compute is roughly C≈6NDC \approx 6ND (about 2 operations per parameter per token in the forward pass, and twice that in backpropagation). Increasing NN reduces the number of tokens DD that can be trained with the same CC. The paper estimated this allocation with three approaches.

  1. Trace the lower envelope of the training curves: models of fixed sizes are each trained with four different learning-rate decay lengths (cosine cycle lengths). From all training curves, the point with the lowest loss is collected for each compute level, and the corresponding NN and DD are fit with power laws in compute.
  2. Fix compute and vary size (IsoFLOP): for each of 9 compute budgets (6×10186 \times 10^{18} to 3×10213 \times 10^{21}), models of different sizes are trained and their final losses compared. The loss forms a valley as a function of size, and the bottom of the valley (the optimal size) is found by fitting a parabola.
  3. Model the loss with a formula and fit it: the following formula is fit to all results from approaches 1 and 2.
L^(N,D)=E+ANα+BDβ\hat{L}(N, D) = E + \frac{A}{N^{\alpha}} + \frac{B}{D^{\beta}}

EE is the loss that remains even for an ideal model (the entropy of natural text itself). A/NαA/N^{\alpha} is the loss due to the model being small, and B/DβB/D^{\beta} is the loss due to insufficient training. The fitted values are E=1.69E = 1.69, A=406.4A = 406.4, B=410.7B = 410.7, α=0.34\alpha = 0.34, and β=0.28\beta = 0.28 (Appendix D.2 of the paper). The fit minimizes the outlier-robust Huber loss with L-BFGS.

Minimizing this formula under the constraint C=6NDC = 6ND gives the optimal size and token count as power laws in compute.

Nopt(C)=G(C6)a,Dopt(C)=G−1(C6)b,G=(αAβB)1α+β, a=βα+β, b=αα+βN_{\mathrm{opt}}(C) = G \left(\frac{C}{6}\right)^{a}, \quad D_{\mathrm{opt}}(C) = G^{-1} \left(\frac{C}{6}\right)^{b}, \quad G = \left(\frac{\alpha A}{\beta B}\right)^{\frac{1}{\alpha + \beta}},\ a = \frac{\beta}{\alpha + \beta},\ b = \frac{\alpha}{\alpha + \beta}

The left side of the figure at the top of this article uses this formula to plot loss against size at fixed compute. Every compute budget gives a valley, and on the curve for Gopher's compute, Chinchilla (70 billion) is closer to the bottom of the valley than Gopher (280 billion).

The results of the three approaches (the exponents in Nopt∝CaN_{\mathrm{opt}} \propto C^{a} and Dopt∝CbD_{\mathrm{opt}} \propto C^{b}; Table 2 of the paper) are as follows.

Approachaa (size)bb (tokens)
1. Lower envelope of training curves0.500.50
2. IsoFLOP0.490.51
3. Fitting the loss formula0.460.54
Kaplan et al. (2020)0.730.27

All three give a≈b≈0.5a \approx b \approx 0.5: when increasing compute, size and tokens should be scaled in equal proportion. Estimating the required tokens for each size with approach 1 gives the following (excerpt from Table 3 of the paper).

ParametersCompute (FLOPs)Training tokens
1 billion1.21×10201.21 \times 10^{20}20.2 billion
10 billion1.23×10221.23 \times 10^{22}205.1 billion
67 billion5.76×10235.76 \times 10^{23}1.5 trillion
175 billion3.85×10243.85 \times 10^{24}3.7 trillion
280 billion9.90×10249.90 \times 10^{24}5.9 trillion
1 trillion1.27×10261.27 \times 10^{26}21.2 trillion

At every size, the rule of thumb is to train on roughly 20 tokens per parameter. GPT-3, with 175 billion parameters, would need 3.7 trillion tokens; the 300 billion tokens it actually used were less than a tenth of that.

At Gopher's compute (5.76×10235.76 \times 10^{23}), the optimal size was estimated at about 63–67 billion by approaches 1 and 2, and about 40 billion by approach 3. Of this 40–70 billion range, the paper chose the larger end, 70 billion, to train Chinchilla.

Architecture and Training Setup: Differences from Gopher

Chinchilla's architecture and training setup are almost identical to those of Gopher. It is a decoder-only Transformer with RMSNorm at the input of each sublayer and Transformer-XL relative positional encoding. The size settings are as follows (Table 4 of the paper).

ModelLayersHeadsKey/value sizedmodeld_{\text{model}}Max learning rateBatch (tokens)
Gopher 280B8012812816,3844×10−54 \times 10^{-5}3M → 6M
Chinchilla 70B80641288,1921×10−41 \times 10^{-4}1.5M → 3M

In both, the feed-forward inner size is 4 times dmodeld_{\text{model}}, and the batch size is doubled partway through training. The differences from Gopher are the following four (Section 4.1 of the paper).

  1. Slightly change the data mixture: the same MassiveText is used, but the sampling proportions are adjusted for the larger number of tokens (MassiveWeb 45%, Books 30%, C4 10%, News 10%, GitHub 4%, Wikipedia 1%). Over 1.4 trillion tokens of training, MassiveWeb is used 1.24 times and Wikipedia 3.40 times.
  2. Use AdamW as the optimizer: Gopher used Adam. AdamW gives better language modeling loss and better performance after fine-tuning.
  3. Change tokenizer normalization: NFKC normalization in SentencePiece is dropped. 94.15% of the vocabulary is shared with Gopher. This makes mathematical and chemical notation easier to represent.
  4. Keep a float32 copy of the weights: forward and backward passes are computed in bfloat16, and the sharded optimizer state (ZeRO) holds float32 weights. This reflects the lesson from Gopher that small updates were lost with bfloat16 weights.

The learning rate is decayed with a cosine schedule to one tenth of its maximum. The paper's analysis shows that it is important to match the cosine cycle to the actual number of training tokens; when the cycle is more than 25% longer than training, performance drops noticeably.

Why a Smaller Model Trained Longer Is Better

This is easiest to understand through the loss formula L^=E+A/Nα+B/Dβ\hat{L} = E + A/N^{\alpha} + B/D^{\beta}.

  • A/NαA/N^{\alpha} (the shortfall in size) decreases as the model gets larger.
  • B/DβB/D^{\beta} (the shortfall in training) decreases as the number of tokens grows.

With compute C≈6NDC \approx 6ND fixed, increasing one decreases the other. Both terms show diminishing returns as they grow, so increasing both moderately gives a smaller total than favoring one. This is why the figure shows valleys: the left side of a valley is a model that is too small, and the right side is a model that is too large and trained on too few tokens. Because the two exponents α=0.34\alpha = 0.34 and β=0.28\beta = 0.28 are close, the optimal allocation also scales size and tokens in nearly equal proportion.

As an analogy, when training chefs on a fixed budget, hiring too many leaves each one too little apprenticeship time, while too much apprenticeship time leaves too few hands. The restaurant's food is best where the two are balanced.

Why, then, did earlier work (Kaplan et al. 2020) recommend making the model larger? The paper cites the learning-rate schedule as the main reason. Kaplan et al. used a cosine learning rate of the same length (130 billion tokens) for every model and also used losses from partway through training in their analysis. Midway through a cycle the learning rate has not yet decayed enough, so the losses of short runs were overestimated, and the performance of training on less data was underestimated. In addition, the Chinchilla paper includes larger models, up to 16 billion parameters, in its analysis.

Beyond training loss, deployment costs also go down. Chinchilla is one quarter the size of Gopher, so the memory and compute needed for inference and fine-tuning are also roughly one quarter.

Experimental Results

Chinchilla is evaluated on almost the same tasks as Gopher. The values below are from Tables 6–9 of the paper (accuracy %).

Knowledge and reading comprehension

BenchmarkSettingChinchilla 70BGopher 280BGPT-3 175BMT-NLG 530B
MMLU (average over 57 subjects)5-shot67.660.043.9-
LAMBADAZero-shot77.474.576.276.6
RACE-mFew-shot86.875.158.1-
RACE-hFew-shot82.371.646.847.9
BIG-bench (average over 62 tasks)-65.154.4--

On MMLU, Chinchilla beats Gopher on 51 of 57 subjects, ties on 2, and falls behind on only 4 (college mathematics, econometrics, moral scenarios, and formal logic). Its 67.6% also exceeds the 63.4% that expert forecasters had expected to be reached by June 2023. The GPT-3 and MT-NLG numbers on RACE use a different input format and are not directly comparable.

Commonsense reasoning (zero-shot)

BenchmarkChinchilla 70BGopher 280BGPT-3 175BMT-NLG 530BSupervised SOTA
HellaSwag80.879.278.980.293.9
PIQA81.881.881.082.090.1
WinoGrande74.970.170.273.091.3
SIQA51.350.6--83.2
BoolQ83.779.360.578.291.4

Closed-book question answering (exact match)

BenchmarkSettingChinchilla 70BGopher 280BGPT-3 175B
Natural QuestionsZero-shot16.610.114.6
Natural Questions64-shot35.528.229.9
TriviaQA (unfiltered)Zero-shot67.052.864.3
TriviaQA (unfiltered)64-shot72.361.371.2

In addition, TruthfulQA (zero-shot) rises sharply to 43.6% from Gopher's 29.5%, and on every subset of the language modeling evaluation data (The Pile), Chinchilla achieves fewer (better) bits than Gopher.

Toxicity and bias: the toxicity of unprompted generations (mean Perspective API score) is nearly the same, 0.081 for Gopher and 0.087 for Chinchilla. On Winogender, which tests which person a pronoun refers to, overall accuracy rises to 78.3% (Gopher: 71.4%), but the gain for male pronouns (3.2 points) is smaller than for female pronouns (8.3 points), so bias remains.

Practical Considerations

Keep the following points in mind when applying Chinchilla's ideas to your own training.

  • The estimates assume less than one epoch of training: none of the analyzed runs used the data even once in full. The paper does not examine whether the same relationship holds when data is scarce and the same data is reused many times.
  • Only two verifications at large scale: apart from the comparison between Chinchilla and Gopher, there is no validation at large scale.
  • The optimal size may be even smaller: the paper notes that the relationship between compute and optimal size curves slightly away from a power law (flattening at large compute), and that it may still overestimate the optimal size of large models.
  • High-quality data in large quantities is required: training on about 20 tokens per parameter requires enormous amounts of high-quality data for larger models. The paper also stresses the importance of data collection.
  • Overlap with evaluation data: since Chinchilla trains on more than four times as much data as Gopher, training and evaluation data may overlap in language modeling evaluations, making results look better.

Chinchilla's "optimal" means minimizing the final loss for a fixed training compute budget. It does not account for deployment costs. For models used repeatedly by many people, training an even smaller model than the Chinchilla standard on more tokens, as LLaMA does, lowers the overall cost.

Comparison with Other Models

Comparing large language models from the same period from the same perspective gives the following (parameter and token counts from Table 1 of the paper; MMLU is 5-shot).

ModelParametersTraining tokensTokens per parameterMMLU
GPT-3175 billion300 billionAbout 1.743.9
Gopher280 billion300 billionAbout 1.160.0
Megatron-Turing NLG530 billion270 billionAbout 0.5-
Chinchilla70 billion1.4 trillion2067.6

Chinchilla is smaller than the other models but uses far more tokens per parameter, and it outperforms them. The later PaLM paper (540 billion parameters, 780 billion tokens) also compared performance against training compute with Chinchilla and Gopher, stating that its results support Chinchilla's conclusion that Gopher was undertrained for its size. LLaMA, taking deployment costs into account, trained on even more tokens than the Chinchilla standard (1 trillion tokens for 7 billion parameters).

Rough guidelines for choosing:

  • Maximizing post-training performance for a fixed compute budget: start from the Chinchilla standard (about 20 tokens per parameter) to decide size and token count.
  • Building a model that many people will use repeatedly: inference costs become large, so consider training a smaller model for longer, as LLaMA does.
  • Not enough data: if the token count required by the Chinchilla standard cannot be collected, the same data will be reused many times, which falls outside the paper's assumptions.

PyTorch example

Show code
python
import math
import torch

"""
An example that computes the optimal parameter count N and token count D for compute C (Eq. (4))
from the Chinchilla paper's "loss formula" (Eq. (2) in Section 3.3, with the fitted values from Appendix D.2)
  L(N, D) = E + A / N^alpha + B / D^beta,   C = 6 N D
No training is done (the formula is only evaluated), so model.train() / model.eval() are irrelevant
"""

E, A, B, alpha, beta = 1.69, 406.4, 410.7, 0.34, 0.28

def loss(N, D):
  return E + A / N**alpha + B / D**beta

def compute_optimal(C):
  G = (alpha * A / (beta * B)) ** (1 / (alpha + beta))
  a, b = beta / (alpha + beta), alpha / (alpha + beta)
  N = G * (C / 6) ** a
  D = (C / 6) ** b / G
  return N, D

C = 5.76e23                                    # Gopher's training compute
N, D = compute_optimal(C)
print(f"optimal size {N / 1e9:.0f}B, tokens {D / 1e9:.0f}B")
# Because rounded constants are used, this comes out slightly smaller than Figure 4 of the paper (about 40B)
for name, n in [("Gopher", 280e9), ("Chinchilla", 70e9)]:
  d = C / (6 * n)                              # tokens trainable with the same compute
  print(name, f"tokens={d / 1e9:.0f}B", f"loss={loss(n, d):.3f}")

# IsoFLOP (approach 2): fix compute, vary size, and find the bottom of the loss valley with a parabola
logN = torch.linspace(math.log10(1e9), math.log10(1e12), 50)
Ns = 10 ** logN
Ls = torch.tensor([loss(n.item(), C / (6 * n.item())) for n in Ns])
X = torch.stack([logN**2, logN, torch.ones_like(logN)], dim=1)
coef = torch.linalg.lstsq(X, Ls.unsqueeze(1)).solution.squeeze()   # L ≈ p·x^2 + q·x + r (x = log10 N)
best_logN = -coef[1] / (2 * coef[0])
print(f"bottom of the parabola: {10 ** best_logN.item() / 1e9:.0f}B")

# Rule of thumb: about 20 tokens per parameter (Table 3 of the paper)
def tokens_for(params):
  return 20 * params

FAQ

Q. What is the Chinchilla rule (20 tokens per parameter)?
A.

It is a rule of thumb based on Table 3 of the Chinchilla paper, where the compute-optimal token count comes out to roughly 20 times the parameter count at every size. For example, a 10-billion-parameter model would be trained on about 200 billion tokens, and a 70-billion-parameter model on about 1.4 trillion tokens. The paper's actual conclusion is that "when increasing compute, size and tokens should be scaled in equal proportion"; the factor of 20 is a value read off from that.

Q. Does Chinchilla have a different architecture from Gopher?
A.

It is almost the same. Both are decoder-only Transformers with RMSNorm and relative positional encoding, trained on the same MassiveText. The only differences are size (70 billion vs. 280 billion) and training tokens (1.4 trillion vs. 300 billion), plus the switch to AdamW, the tokenizer normalization, and keeping a float32 copy of the weights. The training compute is nearly the same.

Q. Is training on more tokens than the Chinchilla standard wasteful?
A.

Considering training compute alone, training on more tokens than the standard is not optimal. However, the Chinchilla standard does not account for inference costs. For a model that will be used repeatedly, training a smaller model for longer to make inference cheaper pays off overall. LLaMA showed that even a 7-billion-parameter model keeps improving beyond 1 trillion tokens.

References

  1. Hoffmann, J., Borgeaud, S., Mensch, A., Buchatskaya, E., et al. (2022). Training Compute-Optimal Large Language Models. NeurIPS 2022.
  2. Rae, J. W., Borgeaud, S., Cai, T., Millican, K., et al. (2021). Scaling Language Models: Methods, Analysis & Insights from Training Gopher. arXiv:2112.11446.
  3. Kaplan, J., McCandlish, S., Henighan, T., Brown, T. B., et al. (2020). Scaling Laws for Neural Language Models. arXiv:2001.08361.
  4. Touvron, H., Lavril, T., Izacard, G., et al. (2023). LLaMA: Open and Efficient Foundation Language Models. arXiv:2302.13971.