Please enable JavaScript to use CodeHS

AI Engineer

What makes large models different

Big models are not just small models with more memory. This deep dive explains scaling laws, data quality, compute, and why size changes behavior.

AI ~15 min Programmer
Vocabulary

Key terms for this tutorial

Here are the words that matter most in this tutorial. Come back here if a term feels fuzzy.

gradient
A vector of partial derivatives showing how much each parameter affects the loss.
gradient descent
An optimization algorithm that updates weights by moving them in the direction that lowers the loss.
loss
A number that measures how wrong the model is. Training tries to minimize loss.
model
A function with learnable parameters that maps inputs to outputs.
parameter
A learnable number inside a model. Modern models have millions or billions of them.
parameters
The collection of learnable numbers inside a model.
Dataset
A PyTorch interface: given an index, return one training example.
FLOPs
Floating-point operations, a measure of how much computation a model or training run needs.

Scaling

Scaling laws: parameters, data, and compute

Language-model loss roughly follows a power law: as you increase model parameters N, dataset size D, or compute C, test loss falls predictably. If you double parameters but keep data fixed, gains saturate. If you scale all three together, performance improves smoothly.

The rule of thumb: parameters and tokens should grow together. A 1B-parameter model wants roughly 20B tokens. A 100B-parameter model wants 2T tokens. Violating this ratio wastes compute.

scaling_estimate.py
# Estimate training FLOPs: ~6 * params * tokens
params = 1_000_000_000
tokens = 20_000_000_000
flops = 6 * params * tokens
print('FLOPs:', flops / 1e21, 'zettaFLOPs')

# A100 does ~300 TFLOPS; assume 30% utilisation
gpu_flops = 300e12 * 0.30
seconds = flops / gpu_flops
print('Seconds on one A100:', seconds / 3600 / 24, 'days')
Output
FLOPs: 0.12 zettaFLOPs
Seconds on one A100: 4.62962962962963 days

Line-by-line: scaling_estimate.py

Read this slowly. Each line does one small, concrete thing.

  1. print('FLOPs:', flops / 1e21, 'zettaFLOPs') — Print a result so we can see what the model learned.
  2. print('Seconds on one A100:', seconds / 3600 / 24, 'days') — Print a result so we can see what the model learned.

Pop-in: Read the code one block at a time

Industry code imports many libraries. Focus on the sequence: prepare data, define the model, run the training loop, and evaluate. The rest is setup.

Power laws are empirical, not laws of physics. They break down when data is exhausted, architecture changes, or evaluation measures shift.

Stuck or curious? Explain this to me on ChatGPT

Prompt: I am a beginner AI engineer working through the CodeHS tutorial 'AI Engineer: The Big Picture — Deep Dive'. Explain the section 'Scaling laws: parameters, data, and compute' in plain English. Include simple analogies, vocabulary definitions, and a short example. Also walk through the code example in this section step by step.


Data

Data quality beats quantity

A model trained on repeated, noisy web text often learns toxic or low-quality patterns. Data pipelines filter duplicates, remove PII, deduplicate near-identical documents, and mix in high-quality sources like books, code, and scientific papers.

  • Deduplication: exact- and near-duplicate removal saves tokens and reduces memorisation.
  • Quality filtering: classifiers or heuristics keep well-formed, informative text.
  • Tokenisation: subword vocabularies shrink sequence length and handle rare words.
data_mix.py
# A tiny data-mix budget: percentages of tokens
mix = {
    'web_crawl': 0.60,
    'books': 0.15,
    'code': 0.15,
    'science': 0.10,
}
total_tokens = 50_000_000_000
for source, p in mix.items():
    print(f'{source}: {p * total_tokens:,.0f} tokens')
Output
web_crawl: 30,000,000,000 tokens
books: 7,500,000,000 tokens
code: 7,500,000,000 tokens
science: 5,000,000,000 tokens

Line-by-line: data_mix.py

Read this slowly. Each line does one small, concrete thing.

  1. for source, p in mix.items(): — Loop over the data one batch at a time.
  2. print(f'{source}: {p * total_tokens:,.0f} tokens') — Print a result so we can see what the model learned.

Pop-in: Read the code one block at a time

Industry code imports many libraries. Focus on the sequence: prepare data, define the model, run the training loop, and evaluate. The rest is setup.

Stuck or curious? Explain this to me on ChatGPT

Prompt: I am a beginner AI engineer working through the CodeHS tutorial 'AI Engineer: The Big Picture — Deep Dive'. Explain the section 'Data quality beats quantity' in plain English. Include simple analogies, vocabulary definitions, and a short example. Also walk through the code example in this section step by step.


Emergence

Emergence and double descent

Some abilities—chain-of-thought reasoning, in-context learning, instruction following—appear suddenly as scale crosses a threshold. This does not mean magic; it means the model finally has enough capacity and data to represent the pattern reliably.

Double descent is another scaling surprise: as you keep increasing model size past the point where it can perfectly memorise the training set, test error can decrease again. Overparameterisation, paired with implicit regularisation like gradient descent, often generalises better than a perfectly sized model.

?

Why does data quality matter more than raw size?

A 1B-token clean dataset vs a 10B-token noisy dataset—why might the smaller one win?

Clean data contains more signal per token. Noisy or duplicated data wastes capacity and teaches spurious patterns.

Stuck or curious? Explain this to me on ChatGPT

Prompt: I am a beginner AI engineer studying 'AI Engineer: The Big Picture — Deep Dive'. The practice question 'Why does data quality matter more than raw size?' asks: A 1B-token clean dataset vs a 10B-token noisy dataset—why might the smaller one win? The answer is: Clean data contains more signal per token. Noisy or duplicated data wastes capacity and teaches spurious patterns.. Explain the concept behind this in simple terms.

Stuck or curious? Explain this to me on ChatGPT

Prompt: I am a beginner AI engineer working through the CodeHS tutorial 'AI Engineer: The Big Picture — Deep Dive'. Explain the section 'Emergence and double descent' in plain English. Include simple analogies, vocabulary definitions, and a short example.


Check yourself

Check yourself

?

Which resource should scale together with parameters?

If you 10x model size but keep data fixed, what happens?

Training saturates. The model has more capacity than data to shape it, leading to overfitting or wasted compute.

Stuck or curious? Explain this to me on ChatGPT

Prompt: I am a beginner AI engineer studying 'AI Engineer: The Big Picture — Deep Dive'. The practice question 'Which resource should scale together with parameters?' asks: If you 10x model size but keep data fixed, what happens? The answer is: Training saturates. The model has more capacity than data to shape it, leading to overfitting or wasted compute.. Explain the concept behind this in simple terms.

Stuck or curious? Explain this to me on ChatGPT

Prompt: I am a beginner AI engineer working through the CodeHS tutorial 'AI Engineer: The Big Picture — Deep Dive'. Explain the section 'Check yourself' in plain English. Include simple analogies, vocabulary definitions, and a short example.


Quick quiz

Three questions

1. What does the 'scaling law' roughly predict?

Stuck or curious? Explain this question to me on ChatGPT

Prompt: I am a beginner AI engineer studying 'AI Engineer: The Big Picture — Deep Dive'. The quiz asks: What does the 'scaling law' roughly predict? The correct answer is: Loss follows a power law in parameters, data, and compute. Explain why that answer is right and why the other choices are wrong, using a simple example.

2. Why is data quality so important?

Stuck or curious? Explain this question to me on ChatGPT

Prompt: I am a beginner AI engineer studying 'AI Engineer: The Big Picture — Deep Dive'. The quiz asks: Why is data quality so important? The correct answer is: Clean signal per token teaches better patterns than noisy bulk data. Explain why that answer is right and why the other choices are wrong, using a simple example.

3. What is 'emergence' in large models?

Stuck or curious? Explain this question to me on ChatGPT

Prompt: I am a beginner AI engineer studying 'AI Engineer: The Big Picture — Deep Dive'. The quiz asks: What is 'emergence' in large models? The correct answer is: A sudden appearance of a capability once scale crosses a threshold. Explain why that answer is right and why the other choices are wrong, using a simple example.

Keep learning

Now let's go deeper into the data structure that everything is made of: tensors.

Part of the CodeHS tutorial library.