TExcelTAD
Home › NLP, Transformers & LLM Fine-Tuning › Scaling Laws, Compute Budgets and Pretraining Data

Scaling Laws, Compute Budgets and Pretraining Data

A pretraining run of a large model costs millions of dollars and cannot be repeated with different settings. Teams therefore decide the model size, the number of training tokens and the data mix before the run, by extrapolating from many small runs. The tools are scaling laws: empirical power laws that predict the loss from the number of parameters NN, the number of training tokens DD and the compute CC. This lesson does the arithmetic of compute budgets, fits a scaling law with SciPy, finds the compute-optimal split, weighs training against inference cost, and then turns to the other half of pretraining: where the tokens come from and how they are cleaned, deduplicated and checked for benchmark contamination. The math of power laws is in Scaling Laws and the FLOP counting in Counting Parameters and FLOPs.

Compute: C≈6NDC \approx 6ND

A forward pass through a dense transformer costs about 2N2N floating-point operations per token (one multiply and one add per weight), the backward pass about twice that. Training on DD tokens therefore costs

C≈6ND FLOPC \approx 6 N D \ \text{FLOP}

(attention adds a term proportional to the context length, small for typical sizes). The example applies it to published models and inverts it for budgets, using the rule of thumb from the Chinchilla paper (Hoffmann et al., 2022) that a compute-optimal model sees about 20 tokens per parameter: with D=20ND = 20N, C=120N2C = 120 N^2 and Nopt=C/120N_{\text{opt}} = \sqrt{C / 120}.

python · try it yourself
import math

models = [  # (name, parameters N, training tokens D), as published
    ("GPT-3", 175e9, 300e9),
    ("Gopher", 280e9, 300e9),
    ("Chinchilla", 70e9, 1.4e12),
    ("Llama 2 7B", 7e9, 2e12),
    ("Llama 3 8B", 8e9, 15e12),
]
print("model         N        D         C = 6ND     tokens per parameter")
for name, N, D in models:
    print(f"{name:11s} {N / 1e9:5.0f}B {D / 1e12:6.2f}T   {6 * N * D:9.2e} FLOP   {D / N:7.1f}")

# Compute-optimal split under the rule of thumb D = 20 N:  C = 6 N (20 N) = 120 N^2.
print("\nbudget C      N_opt      D_opt")
for C in (1e18, 1e21, 5.9e23, 1e25):
    N = math.sqrt(C / 120)
    print(f"{C:8.1e}  {N / 1e9:8.3f}B  {20 * N / 1e9:9.1f}B tokens")

# What does a budget mean in hardware time? One accelerator at 400 TFLOP/s peak, 40% utilisation.
C = 6 * 70e9 * 1.4e12
seconds = C / (400e12 * 0.4)
print(f"\nChinchilla-sized run: {seconds / 86400:,.0f} accelerator-days at 160 TFLOP/s sustained")
model         N        D         C = 6ND     tokens per parameter
GPT-3         175B   0.30T    3.15e+23 FLOP       1.7
Gopher        280B   0.30T    5.04e+23 FLOP       1.1
Chinchilla     70B   1.40T    5.88e+23 FLOP      20.0
Llama 2 7B      7B   2.00T    8.40e+22 FLOP     285.7
Llama 3 8B      8B  15.00T    7.20e+23 FLOP    1875.0

budget C      N_opt      D_opt
 1.0e+18     0.091B        1.8B tokens
 1.0e+21     2.887B       57.7B tokens
 5.9e+23    70.119B     1402.4B tokens
 1.0e+25   288.675B     5773.5B tokens

Chinchilla-sized run: 42,535 accelerator-days at 160 TFLOP/s sustained
  • GPT-3 (2020) and Gopher (2021) were trained on 300 billion tokens, 1.7 and 1.1 tokens per parameter: by the Chinchilla analysis, far too large for their data. Chinchilla used about the same compute as Gopher (5.88⋅10235.88 \cdot 10^{23} against 5.04⋅10235.04 \cdot 10^{23} FLOP) on a 4 times smaller model with 4.7 times more data, and outperformed it on most benchmarks.
  • Llama 2 7B (286 tokens per parameter) and Llama 3 8B (1875) are trained far beyond compute-optimal on purpose, for the reason in the inference section below.
  • A budget of 5.9⋅10235.9 \cdot 10^{23} FLOP gives back Chinchilla's 70B parameters and 1.4T tokens, as it should. At a sustained 160 TFLOP/s (a modern accelerator at 40% utilisation), that is 42,535 accelerator-days, for example about 1000 accelerators for 6 weeks.

Fitting a scaling law

Loss as a function of model size, with data and training otherwise scaled sensibly, follows a power law with a floor:

L(N)=E+ANαL(N) = E + \frac{A}{N^{\alpha}}

EE is the irreducible loss, the entropy of the text itself, which no model can beat (the generator floor of the tiny GPT is the toy version). The example generates noisy loss values for 8 model sizes from a known law, fits it with curve_fit on the 6 smallest, and checks the prediction for the 2 largest: the way a real team uses small runs to predict a big one.

python · try it yourself
import numpy as np
from scipy.optimize import curve_fit

# Synthetic "final validation loss" of models of 8 sizes, generated from a known law plus noise.
rng = np.random.default_rng(0)
E_true, A_true, alpha_true = 1.8, 400.0, 0.33
N = np.array([1e6, 3e6, 1e7, 3e7, 1e8, 3e8, 1e9, 3e9])
L = E_true + A_true / N ** alpha_true + rng.normal(0, 0.01, N.size)

def law(logN, E, A, alpha):                 # fit in log N for numerical sanity
    return E + A * np.exp(-alpha * logN)

small = N <= 3e8                            # fit on the 6 small models, keep the 2 largest to test extrapolation
params, _ = curve_fit(law, np.log(N[small]), L[small], p0=[2.0, 100.0, 0.3], maxfev=20000)
E, A, alpha = params
print(f"fitted: E = {E:.3f}, A = {A:.1f}, alpha = {alpha:.3f}   (true 1.8, 400, 0.33)")
for n, l in zip(N[~small], L[~small]):
    print(f"N = {n:.0e}: predicted {law(np.log(n), *params):.3f}, observed {l:.3f}")

# Without the floor E, a pure power law is a straight line in log-log space, and it extrapolates worse.
slope, intercept = np.polyfit(np.log(N[small]), np.log(L[small]), 1)
print(f"pure power law L = {np.exp(intercept):.2f} N^{slope:.4f}: predicts {np.exp(intercept) * 3e9 ** slope:.3f} at N = 3e9")
print(f"irreducible loss E: the fitted law never goes below {E:.3f}, however large the model")
fitted: E = 1.798, A = 397.2, alpha = 0.329   (true 1.8, 400, 0.33)
N = 1e+09: predicted 2.228, observed 2.242
N = 3e+09: predicted 2.097, observed 2.108
pure power law L = 49.87 N^-0.1575: predicts 1.605 at N = 3e9
irreducible loss E: the fitted law never goes below 1.798, however large the model

The fit recovers E=1.798E = 1.798, A=397.2A = 397.2, α=0.329\alpha = 0.329 (true values 1.8, 400, 0.33), and predicts 2.228 and 2.097 for the two held-out sizes against observed 2.242 and 2.108: off by about 0.01, the size of the noise. A pure power law without the floor, a straight line in log-log space, predicts 1.605 at 3⋅1093 \cdot 10^9 parameters, far too optimistic: near the floor the curve bends and straight-line extrapolation fails. In real studies the exponents are small (Kaplan et al., 2020, reported α≈0.076\alpha \approx 0.076 for NN when data is not a constraint), which is why each constant improvement in loss needs a multiplicative increase in size.

The compute-optimal split

For a fixed budget C=6NDC = 6ND a bigger model sees fewer tokens. The Chinchilla paper fitted a law in both variables,

L(N,D)=E+ANα+BDβL(N, D) = E + \frac{A}{N^{\alpha}} + \frac{B}{D^{\beta}}

with published constants E=1.69E = 1.69, A=406.4A = 406.4, B=410.7B = 410.7, α=0.34\alpha = 0.34, β=0.28\beta = 0.28, and minimised it under the budget constraint. Setting the derivative to zero gives Nopt∝Cβ/(α+β)N_{\text{opt}} \propto C^{\beta/(\alpha+\beta)} and Dopt∝Cα/(α+β)D_{\text{opt}} \propto C^{\alpha/(\alpha+\beta)}, both close to C0.5C^{0.5}: scale parameters and tokens equally. The example does the minimisation numerically and also asks the question that matters for deployment.

python · try it yourself
import numpy as np

# Parametric loss fitted in the Chinchilla paper (Hoffmann et al., 2022, "approach 3").
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

# 1. Compute-optimal split: for a budget C = 6ND, scan N and pick the lowest loss.
Ns = np.logspace(8, 12, 4001)
for C in (1e21, 5.9e23, 1e25):
    D = C / (6 * Ns)
    i = int(np.argmin(loss(Ns, D)))
    print(f"C = {C:.1e}: best N = {Ns[i] / 1e9:6.1f}B, D = {D[i] / 1e9:7.0f}B tokens, "
          f"D/N = {D[i] / Ns[i]:4.1f}, loss {loss(Ns[i], D[i]):.3f}")

# 2. Training + inference. Same target loss as a 70B model trained on 1.4T tokens:
target = loss(70e9, 1.4e12)
print(f"\ntarget loss {target:.3f}")
for N in (70e9, 35e9, 20e9):
    # tokens needed to reach the target with N parameters: solve B / D^beta = target - E - A / N^alpha
    D = (B / (target - E - A / N ** alpha)) ** (1 / beta)
    train = 6 * N * D
    for served in (1e12, 1e14):
        total = train + 2 * N * served             # inference: about 2N FLOP per generated token
        print(f"N = {N / 1e9:3.0f}B: D = {D / 1e12:5.2f}T, train {train:.2e}, "
              f"serve {served:.0e} tokens -> total {total:.2e} FLOP")
C = 1.0e+21: best N =    1.8B, D =      91B tokens, D/N = 50.1, loss 2.329
C = 5.9e+23: best N =   32.5B, D =    3025B tokens, D/N = 93.0, loss 1.930
C = 1.0e+25: best N =  116.9B, D =   14251B tokens, D/N = 121.9, loss 1.845

target loss 1.937
N =  70B: D =  1.40T, train 5.88e+23, serve 1e+12 tokens -> total 7.28e+23 FLOP
N =  70B: D =  1.40T, train 5.88e+23, serve 1e+14 tokens -> total 1.46e+25 FLOP
N =  35B: D =  2.36T, train 4.96e+23, serve 1e+12 tokens -> total 5.66e+23 FLOP
N =  35B: D =  2.36T, train 4.96e+23, serve 1e+14 tokens -> total 7.50e+24 FLOP
N =  20B: D =  4.34T, train 5.21e+23, serve 1e+12 tokens -> total 5.61e+23 FLOP
N =  20B: D =  4.34T, train 5.21e+23, serve 1e+14 tokens -> total 4.52e+24 FLOP

Two lessons, one about the method and one about the economics.

  • The method. This parametric fit puts the optimum at 50 to 122 tokens per parameter, not 20, and at Chinchilla's budget it prefers a 32.5B model on 3T tokens to the 70B model actually trained. The paper's three estimation approaches did not agree perfectly; the 20-tokens-per-parameter rule comes from the other two, and a 2024 replication (Besiroglu et al., arXiv 2404.10102) argued that the published parametric constants were poorly estimated and that a refit of approach 3 agrees with the other two. Treat "about 20 tokens per parameter" as a rule of thumb with a wide band, and fit your own law on your own data and architecture before betting a budget on it.
  • The economics. Compute-optimal means optimal for training only. Serving costs about 2N2N FLOP per generated token. To reach the same loss as the 70B model, a 20B model needs 4.34T tokens instead of 1.4T, so its training costs about the same (5.21⋅10235.21 \cdot 10^{23} against 5.88⋅10235.88 \cdot 10^{23} FLOP), but every served token is 3.5 times cheaper. If the model will generate 101410^{14} tokens in its life, the total is 4.52⋅10244.52 \cdot 10^{24} for the 20B model against 1.46⋅10251.46 \cdot 10^{25} for the 70B one. That is why widely deployed models like Llama 3 8B are trained on far more tokens than "optimal": the extra training is paid once, the smaller model saves on every request. The limit is data: high-quality text is finite, and repeating it more than a few epochs gives diminishing returns.

Pretraining data

The tokens are the other half of a scaling law: the constants EE, AA, BB are properties of the data, and better data shifts the whole curve down. A pretraining corpus is built by a pipeline in which each stage removes part of what came in:

sources web, code, books, papers extract HTML to text, boilerplate out language ID keep target languages quality heuristics + classifier dedup exact hash, MinHash LSH decontam. drop benchmark n-gram overlap PII, licence remove or mask, opt-outs mix + tokens weights per source every stage removes data; what survives is a small share of the raw crawl
  • Sources. Web crawls (Common Crawl, filtered into corpora such as C4, RefinedWeb or FineWeb), code (GitHub-derived sets such as The Stack, with licence filtering), books, scientific papers, Wikipedia, forums. The mix (how many tokens from each source, how many epochs) is a tuned hyperparameter; code and maths are often up-weighted because they help reasoning.
  • Extraction and language ID. HTML to text without menus and boilerplate; a fastText-style classifier keeps the target languages.
  • Quality filtering. Heuristics (length, share of letters, stop words, repeated lines, symbol ratios) remove spam and junk; a classifier trained to recognise "reference-like" text (for example Wikipedia-cited pages against random web pages) ranks the rest.
  • Deduplication. Exact duplicates by hashing normalised text, near-duplicates (the same article with a different footer, templated pages) by MinHash. Duplicates waste compute and increase memorisation of the repeated text.
  • Decontamination. Remove training documents that contain benchmark questions, or flag the benchmark items that appear in training data.
  • Privacy and licensing. Remove or mask personal data (emails, phone numbers), respect robots.txt and opt-out requests, and track licences. Whether training on copyrighted text without permission is lawful is contested and under litigation in several countries; consent and attribution are ethical questions as well as legal ones.

Quality heuristics

Rule-based filters are cheap and transparent. The example scores six pages on five signals and keeps a page only if all of them pass; English stop words come from scikit-learn's built-in list.

python · try it yourself
import re
from sklearn.feature_extraction.text import ENGLISH_STOP_WORDS

pages = [
    "The ferry to the island leaves twice a day. In winter the evening crossing is cancelled when the wind is strong.",
    "BUY NOW!!! best price $$ click here click here click here >>> www.example.test <<<",
    "Home | About | Contact | Home | About | Contact | Login | Register",
    "ferry ferry ferry ferry ferry ferry ferry ferry ferry ferry ferry ferry",
    "Our bakery uses flour from the mill in the valley and opens at seven every morning except Monday.",
    "x9#k2 @@ 0x3f;; ~~ ## 77 :: ||",
]

def quality(t):
    words = re.findall(r"[A-Za-z']+", t)
    n = max(len(words), 1)
    return {
        "words": len(words),
        "alpha": sum(c.isalpha() for c in t) / max(len(t), 1),            # share of letters
        "stop": sum(w.lower() in ENGLISH_STOP_WORDS for w in words) / n,  # real prose has many stop words
        "unique": len({w.lower() for w in words}) / n,                    # low = repetitive
        "symbols": sum(not (c.isalnum() or c.isspace() or c in ".,'") for c in t) / n,  # |, $, #, ! per word
    }

def keep(q):
    return (q["words"] >= 8 and q["alpha"] >= 0.6 and q["stop"] >= 0.2
            and q["unique"] >= 0.5 and q["symbols"] <= 0.1)

for t in pages:
    q = quality(t)
    print(f"{'KEEP' if keep(q) else 'drop'}  words {q['words']:2d}  alpha {q['alpha']:.2f}  stop {q['stop']:.2f}  "
          f"unique {q['unique']:.2f}  symbols {q['symbols']:.2f}  | {t[:30]}")

# Contamination: does a benchmark item appear (in n-grams) in the training data?
train_text = " ".join(pages).lower()
benchmark = [
    "In winter the evening crossing is cancelled when the wind is strong. True or false?",
    "Which flour does the bakery use, and when does it open on Mondays?",
    "What is the boiling point of water at sea level in degrees Celsius?",
]
def ngrams(t, n=8):
    w = re.findall(r"[a-z']+", t.lower())
    return {" ".join(w[i:i + n]) for i in range(len(w) - n + 1)}
train_grams = ngrams(train_text)
for b in benchmark:
    g = ngrams(b)
    hit = len(g & train_grams) / max(len(g), 1)
    print(f"{hit:.2f} of its 8-grams in training data: {'CONTAMINATED' if hit > 0 else 'clean'} | {b[:45]}")
KEEP  words 21  alpha 0.80  stop 0.48  unique 0.81  symbols 0.00  | The ferry to the island leaves
drop  words 13  alpha 0.67  stop 0.31  unique 0.69  symbols 0.92  | BUY NOW!!! best price $$ clic
drop  words  8  alpha 0.68  stop 0.25  unique 0.62  symbols 0.88  | Home | About | Contact | Home
drop  words 12  alpha 0.85  stop 0.00  unique 0.08  symbols 0.00  | ferry ferry ferry ferry ferry
KEEP  words 18  alpha 0.81  stop 0.56  unique 0.94  symbols 0.00  | Our bakery uses flour from the
drop  words  4  alpha 0.13  stop 0.00  unique 0.75  symbols 3.25  | x9#k2 @@ 0x3f;; ~~ ## 77 :: ||
0.62 of its 8-grams in training data: CONTAMINATED | In winter the evening crossing is cancelled w
0.00 of its 8-grams in training data: clean | Which flour does the bakery use, and when doe
0.00 of its 8-grams in training data: clean | What is the boiling point of water at sea lev

The two prose pages pass. The spam page and the navigation menu fail on symbols per word (0.92 and 0.88: !, $, >, |), the repeated "ferry" page on stop words (0.00) and unique words (0.08), and the line noise on everything. Each threshold is a choice that silently removes some legitimate text too (poetry, code, tables, lists, dialects with different stop words), so real pipelines measure what each filter removes and check the downstream effect on small models.

Contamination. The last lines check benchmark items against the training text by 8-gram overlap: 62% of the first question's 8-grams appear verbatim in the ferry page, so a model that scores well on it may be remembering rather than reasoning. GPT-3's analysis used 13-gram overlap; short n-grams flag more false positives, long ones miss paraphrases. A contaminated benchmark is not a fair test, and the honest options are to remove the overlapping training documents before training, or to report results on the clean subset.

Near-duplicates with MinHash

Exact hashing only catches identical text. Near-duplicates are measured by the Jaccard similarity of the documents' sets of word nn-grams ("shingles"), J(S1,S2)=∣S1∩S2∣/∣S1∪S2∣J(S_1, S_2) = \lvert S_1 \cap S_2 \rvert / \lvert S_1 \cup S_2 \rvert. Comparing all pairs of a billion documents is impossible, so each document is summarised by a MinHash signature: for each of KK random hash functions hkh_k, keep the minimum hash over the document's shingles. For one random hash function, the probability that two documents share the minimum equals their Jaccard similarity:

P[min⁡h(S1)=min⁡h(S2)]=J(S1,S2)P\big[\min h(S_1) = \min h(S_2)\big] = J(S_1, S_2)

so the fraction of agreeing positions in two signatures estimates JJ. Locality-sensitive hashing then splits each signature into bb bands of rr rows and only compares documents that agree on all rows of at least one band; a pair with similarity ss becomes a candidate with probability 1−(1−sr)b1 - (1 - s^r)^b, a steep S-curve.

python · try it yourself
import hashlib
import re
import numpy as np

docs = {
    "a": "The night ferry leaves the harbour at ten and reaches the island before dawn. Tickets are sold on board.",
    "b": "The night ferry leaves the harbour at ten and reaches the island before dawn. Tickets are sold at the pier.",
    "c": "the night ferry leaves the harbour at ten and reaches the island before dawn.  Tickets are sold on board!",
    "d": "Fresh bread is baked every morning in the village and sold until noon at the square.",
    "e": "Fresh bread is baked every morning in the village and sold until noon in the square. Closed on Sundays.",
    "f": "The museum opens at nine. Entry is free for children and students on the first Sunday of the month.",
}

# 1. Exact dedup: hash of the normalised text (lower case, letters and digits only, single spaces).
norm = lambda t: " ".join(re.findall(r"[a-z0-9]+", t.lower()))
exact = {}
for k, t in docs.items():
    exact.setdefault(hashlib.sha1(norm(t).encode()).hexdigest(), []).append(k)
print("exact duplicate groups after normalising:", [g for g in exact.values() if len(g) > 1])

# 2. Near-duplicates: Jaccard similarity of word 3-gram shingles, estimated with MinHash.
def shingles(t, n=3):
    w = norm(t).split()
    return {" ".join(w[i:i + n]) for i in range(len(w) - n + 1)}

P = 2_147_483_647                                  # a large prime; hash functions h(x) = (a x + b) mod P
K = 128
rng = np.random.default_rng(0)
a, b = rng.integers(1, P, K), rng.integers(0, P, K)

def minhash(sh):
    x = np.array([int(hashlib.md5(s.encode()).hexdigest()[:8], 16) % P for s in sh], dtype=np.int64)   # < 2^31: no overflow
    return ((a[:, None] * x[None, :] + b[:, None]) % P).min(axis=1)     # K minimums = the signature

S = {k: shingles(t) for k, t in docs.items()}
sig = {k: minhash(s) for k, s in S.items()}
print("pair  true Jaccard  MinHash estimate")
for p, q in [("a", "b"), ("a", "c"), ("d", "e"), ("a", "d"), ("a", "f")]:
    true = len(S[p] & S[q]) / len(S[p] | S[q])
    est = float((sig[p] == sig[q]).mean())
    print(f"{p}-{q}   {true:10.3f}  {est:10.3f}")

# 3. LSH banding: 32 bands of 4 rows; documents sharing any band become candidate pairs.
bands, rows = 32, 4
buckets = {}
for k, s in sig.items():
    for i in range(bands):
        buckets.setdefault((i, tuple(s[i * rows:(i + 1) * rows].tolist())), set()).add(k)
cands = sorted({tuple(sorted(v)) for v in buckets.values() if len(v) > 1})
print("candidate groups from LSH:", cands)
print(f"P(candidate) at Jaccard 0.5: {1 - (1 - 0.5 ** rows) ** bands:.3f}, at 0.2: {1 - (1 - 0.2 ** rows) ** bands:.3f}")
exact duplicate groups after normalising: [['a', 'c']]
pair  true Jaccard  MinHash estimate
a-b        0.750       0.781
a-c        1.000       1.000
d-e        0.550       0.539
a-d        0.000       0.000
a-f        0.000       0.000
candidate groups from LSH: [('a', 'b', 'c'), ('a', 'c'), ('d', 'e')]
P(candidate) at Jaccard 0.5: 0.873, at 0.2: 0.050
  • Normalising (lower case, letters and digits only) makes a and c identical: they differed only in case, spacing and "!" versus ".". One hash catches them.
  • a and b (a different last sentence) have Jaccard 0.750, estimated as 0.781 from 128 hashes; d and e 0.550, estimated 0.539. The estimate's standard error is about J(1−J)/K\sqrt{J(1-J)/K}, 0.04 here.
  • With 32 bands of 4 rows, LSH puts a, b, c in one bucket and d, e in another, and never compares the unrelated pages. Pairs with J=0.5J = 0.5 become candidates with probability 0.873, pairs with J=0.2J = 0.2 with 0.050; candidates are then verified with the full signature, and one document per cluster is kept.

Pitfalls

  • Extrapolating a straight line in log-log space. Without the floor EE, predictions for large models are far too optimistic (1.605 against about 2.1 in the example).
  • Treating "20 tokens per parameter" as a law. It depends on the data, the architecture and the fitting method, and it ignores inference cost.
  • Comparing losses across tokenizers or datasets in a scaling study. Scaling laws are fitted per tokenizer and data mix; changing either changes the constants.
  • Deduplicating only exactly. Templated pages, mirrors and boilerplate variations survive exact hashing; use near-duplicate detection, and deduplicate across the training and evaluation sets too.
  • Filtering without measuring what is removed. Heuristics and quality classifiers encode a notion of "good text" that can remove dialects, minority languages and specialist content; audit samples of what each filter drops.
  • Ignoring licences, consent and personal data. Record the source and licence of every component; respect opt-outs; remove personal data. Problems found after training are very expensive to fix.

Practice

  1. Using C=120N2C = 120 N^2, what model size and token count are compute-optimal for C=1022C = 10^{22} FLOP? How long would it take at 160 TFLOP/s sustained on 64 accelerators?
Answer

N=1022/120≈9.1⋅109N = \sqrt{10^{22} / 120} \approx 9.1 \cdot 10^9 (9.1B parameters), D=20N≈183D = 20N \approx 183B tokens. Time: 1022/(64⋅1.6⋅1014)≈9.8⋅10510^{22} / (64 \cdot 1.6 \cdot 10^{14}) \approx 9.8 \cdot 10^5 s, about 11 days.

  1. In sl2.py, raise the noise from 0.01 to 0.05 (rng.normal(0, 0.05, N.size)). Do the fitted constants and the predictions for the two largest models still hold?
Answer

The constants barely move (E=1.788E = 1.788, A=386.5A = 386.5, α=0.327\alpha = 0.327), and the predictions are 2.226 and 2.094 against observed 2.294 and 2.146: errors of 0.05 to 0.07, about the size of the noise in the observed points themselves. The fit is robust here because the data were generated from exactly the fitted form. Real loss curves are only approximately power laws, which is why real studies use many sizes over several orders of magnitude and still report uncertainty bands.

  1. With b=32b = 32 bands of r=4r = 4 rows, what is the probability that a pair with Jaccard 0.8 becomes a candidate? How would you change bb and rr to make pairs below 0.5 rarer?
Answer

1−(1−0.84)32=1−0.590432≈1.01 - (1 - 0.8^4)^{32} = 1 - 0.5904^{32} \approx 1.0 (about 1−5⋅10−81 - 5 \cdot 10^{-8}). Increasing rr (more rows per band) moves the S-curve's threshold up and makes it steeper; for example b=16b = 16, r=8r = 8 puts the threshold near (1/16)1/8≈0.71(1/16)^{1/8} \approx 0.71.

  1. A benchmark question has 20 words. How many 13-grams does it have, and what is the weakness of declaring it clean when none of them occur in the training data?
Answer

20−13+1=820 - 13 + 1 = 8 13-grams. Clean by this test only means no 13 consecutive words match: a paraphrased, translated or reformatted copy of the question and answer would pass undetected.

Test yourself

About how many FLOP does training a 7B-parameter model on 2T tokens take?

  1. 1.4⋅10221.4 \cdot 10^{22}
  2. 8.4⋅10228.4 \cdot 10^{22}
  3. 8.4⋅10248.4 \cdot 10^{24}
  4. 1.4⋅10191.4 \cdot 10^{19}

What does the term EE in L(N)=E+A/NαL(N) = E + A / N^{\alpha} represent?

  1. The learning rate
  2. The irreducible loss, the entropy of the data that no model can beat
  3. The number of epochs
  4. The loss of a model with one parameter

Why are widely deployed models such as Llama 3 8B trained on far more than 20 tokens per parameter?

  1. Because compute-optimal training is impossible
  2. A smaller model trained longer reaches the same loss and is cheaper for every token served
  3. Because more tokens reduce the model size
  4. Because of the KV cache

A MinHash signature of 128 hashes agrees with another in 100 positions. What is the estimated Jaccard similarity?

  1. 0.128
  2. 0.781
  3. 1.0
  4. 0.5

A benchmark item's 8-grams appear verbatim in the training data. What is the right response?

  1. Report the score as usual
  2. Treat it as contaminated: remove the overlapping documents before training or report results on the clean subset
  3. Retrain with a larger model
  4. Shorten the n-grams to 3