You are reading immutable version 3. The current guide may be newer.

Study the paper

Scaling Laws for Neural Language Models

Lessons, visuals, quizzes, flashcards, and resources—organized in teaching order.

All activities

Transformer Parameter and Compute Scaling

Unified Loss Equation L(N,D)

Unified Loss Equation L(N,D)

Source equation

L(N,D)=[(NcN)αNαD+DcD]αDL(N,D)=\left[\left(\frac{N_{c}}{N}\right)^{\frac{\alpha_{N}}{\alpha_{D}}}+\frac{D_{c}}{D}\right]^{\alpha_{D}}

The unified loss equation L(N,D)L(N,D) models the joint dependence of the cross-entropy loss on both the number of non-embedding parameters NN and the dataset size DD (measured in tokens). It captures how overfitting occurs when either resource is constrained relative to the other.

Sources

S1.E5

L​(N,D)=[(NcN)αNαD+DcD]αD𝐿𝑁𝐷superscriptdelimited-[]superscriptsubscript𝑁𝑐𝑁subscript𝛼𝑁subscript𝛼𝐷subscript𝐷𝑐𝐷subscript𝛼𝐷L(N,D)=\left[\left(\frac{N_{c}}{N}\right)^{\frac{\alpha_{N}}{\alpha_{D}}}+\frac{D_{c}}{D}\right]^{\alpha_{D}} (1.5)
L(N,D)=\left[\left(\frac{N_{c}}{N}\right)^{\frac{\alpha_{N}}{\alpha_{D}}}+\frac{D_{c}}{D}\right]^{\alpha_{D}}

L(N,D)=[(NcN)αNαD+DcD]αDL(N,D)=\left[\left(\frac{N_{c}}{N}\right)^{\frac{\alpha_{N}}{\alpha_{D}}}+\frac{D_{c}}{D}\right]^{\alpha_{D}}

Sources

S1.E5

L​(N,D)=[(NcN)αNαD+DcD]αD𝐿𝑁𝐷superscriptdelimited-[]superscriptsubscript𝑁𝑐𝑁subscript𝛼𝑁subscript𝛼𝐷subscript𝐷𝑐𝐷subscript𝛼𝐷L(N,D)=\left[\left(\frac{N_{c}}{N}\right)^{\frac{\alpha_{N}}{\alpha_{D}}}+\frac{D_{c}}{D}\right]^{\alpha_{D}} (1.5)
L(N,D)=\left[\left(\frac{N_{c}}{N}\right)^{\frac{\alpha_{N}}{\alpha_{D}}}+\frac{D_{c}}{D}\right]^{\alpha_{D}}

Where the symbols are defined as follows:

  • L(N,D)L(N,D): The predicted cross-entropy loss.
  • NN: The number of model parameters (excluding embeddings).
  • DD: The dataset size in tokens.
  • NcN_c: The critical model size parameter.
  • DcD_c: The critical dataset size parameter.
  • αN\alpha_N: The power-law scaling exponent for model size.
  • αD\alpha_D: The power-law scaling exponent for dataset size.
Sources

S1.E5

L​(N,D)=[(NcN)αNαD+DcD]αD𝐿𝑁𝐷superscriptdelimited-[]superscriptsubscript𝑁𝑐𝑁subscript𝛼𝑁subscript𝛼𝐷subscript𝐷𝑐𝐷subscript𝛼𝐷L(N,D)=\left[\left(\frac{N_{c}}{N}\right)^{\frac{\alpha_{N}}{\alpha_{D}}}+\frac{D_{c}}{D}\right]^{\alpha_{D}} (1.5)
L(N,D)=\left[\left(\frac{N_{c}}{N}\right)^{\frac{\alpha_{N}}{\alpha_{D}}}+\frac{D_{c}}{D}\right]^{\alpha_{D}}
Implementation detail

Illustrative Calculation

Let us compute the loss L(N,D)L(N,D) using a set of simplified parameters:

  • Nc=109N_c = 10^9, Dc=109D_c = 10^9
  • αN=0.08\alpha_N = 0.08, αD=0.08\alpha_D = 0.08 (so that αNαD=1.0\frac{\alpha_N}{\alpha_D} = 1.0)
  • N=1010N = 10^{10} (a model 10 times larger than NcN_c)
  • D=109D = 10^9 (a dataset equal to DcD_c)

Step-by-step evaluation:

  1. Calculate the model term: (NcN)αNαD=(1091010)1.0=0.1\left(\frac{N_c}{N}\right)^{\frac{\alpha_N}{\alpha_D}} = \left(\frac{10^9}{10^{10}}\right)^{1.0} = 0.1
  2. Calculate the dataset term: DcD=109109=1.0\frac{D_c}{D} = \frac{10^9}{10^9} = 1.0
  3. Sum the terms inside the brackets: 0.1+1.0=1.10.1 + 1.0 = 1.1
  4. Apply the outer exponent αD=0.08\alpha_D = 0.08: L(N,D)=(1.1)0.081.00765L(N,D) = (1.1)^{0.08} \approx 1.00765
Sources

S1.E5

L​(N,D)=[(NcN)αNαD+DcD]αD𝐿𝑁𝐷superscriptdelimited-[]superscriptsubscript𝑁𝑐𝑁subscript𝛼𝑁subscript𝛼𝐷subscript𝐷𝑐𝐷subscript𝛼𝐷L(N,D)=\left[\left(\frac{N_{c}}{N}\right)^{\frac{\alpha_{N}}{\alpha_{D}}}+\frac{D_{c}}{D}\right]^{\alpha_{D}} (1.5)
L(N,D)=\left[\left(\frac{N_{c}}{N}\right)^{\frac{\alpha_{N}}{\alpha_{D}}}+\frac{D_{c}}{D}\right]^{\alpha_{D}}
L(N,D)L(N,D)
Cross-entropy loss as a function of model size and dataset size · scalar
NN
Number of non-embedding model parameters · scalar
DD
Dataset size in tokens · scalar
NcN_c
Critical model size constant · scalar
DcD_c
Critical dataset size constant · scalar
αN\alpha_N
Power-law scaling exponent for model size · scalar
αD\alpha_D
Power-law scaling exponent for dataset size · scalar