Bonus Module · Foundations Primer
Generative AI
Foundations

What an LLM is, where it came from, and what happens inside when it answers — no code, just the mental model. Learners who skip it end up copying prompts that work without knowing why; this saves weeks of confused debugging.

Bonus ⏱ ~25 min read · 8 concepts Bonus module
Concept 1 of 8

Two kinds of model, two different jobs

The most useful distinction in modern AI is between discriminative and generative models. A discriminative model learns the boundary between categories and answers “which one?” — spam or not, fraud or not. It can’t create anything new.

A generative model learns what the data itself looks like, well enough to produce new examples that fit. A Large Language Model is simply a generative model, large in parameter count, trained on language.

If you remember one sentence from this module, make it this one: an LLM is a function that, given some text, predicts what text comes next. Answering questions, writing code, summarizing and holding a conversation are all built from that one move, repeated.

Concept 1 of 8

Two interns in an art gallery

BEFORE: One intern learns to look at any painting and say whether it’s a Van Gogh, a Monet or a Picasso. The other studies thousands of Van Goghs and then paints a brand-new picture in his style.

PAIN: Both studied the same paintings, but their skills don’t swap. Ask the first to paint and they freeze; ask the second to authenticate a canvas and you get a vague guess. Calling both “the art intern” sets them up to fail.

MAPPING: The first intern is discriminative: it draws boundaries between categories. The second is generative: it learned the patterns deeply enough to make new examples. Spam filters are the first kind; Claude is the second.

Concept 1 of 8

What each one learns

  1. DiscriminativeTrained on input–label pairs. Learns how likely each label is, given an input. Outputs one answer.
  2. GenerativeTrained on the data itself. Learns what normal text (or images, or music) looks like.
  3. SamplingTo create, a generative model samples from what it learned — the output is a fresh sequence that didn’t exist before.
  4. An LLMA generative model specialized to text, repeating “predict what comes next”.
Concept 1 of 8

Which kind of model is this?

IF the output is one of a fixed set:
     spam | not spam
     fraud | legitimate
     tumour | clear
  IT IS discriminative

IF the output is new content:
     an answer, an essay, code,
     an image, a summary
  IT IS generative

# LLMs, Claude, image generators: generative

Almost everything written about machine learning before 2020 was about the discriminative kind; almost everything in this course is about the generative kind.

Concept 1 of 8

Misconceptions

“An LLM looks up the answer to my question.”
✅ It predicts what text should come next. Answering is what that prediction looks like when the input is a question.
“Generative AI started with ChatGPT in 2022.”
✅ ChatGPT was when the world noticed. The technology is the product of a seventy-year journey across two research tracks.

An LLM is a generative model: given text, it predicts what text comes next. Every capability you’ll use in this course is built from that one move.

Concept 2 of 8

Seventy years, two lineages, one convergence

Most timelines start in 2017. The fuller story is two long lineages — one teaching machines to write, the other to see and draw — plus the deep-learning revival that made both possible.

For about fifty years the field was a backwater: two “AI winters” (1974–80 and 1987–93) dismissed neural networks as a dead end. Then in 2012 AlexNet won the ImageNet competition by a huge margin, built on big datasets and cheap GPUs. Every modern generative advance descends from that moment.

By 2023 the tracks merged: multimodal models read images and text, and the transformer invented for language now powers most image and video models too.

Concept 2 of 8

Two rivers meeting

BEFORE: Two rivers run in parallel for hundreds of miles, each carving its own valley, each fed by its own streams.

PAIN: If you only ever map one river, you’re baffled when the water suddenly doubles downstream — you never saw the second one coming.

MAPPING: Vision and language were the two rivers, and they kept swapping tricks before merging around 2023. Knowing both lets you read product launches without being blindsided: advances in one track tend to land in the other.

Concept 2 of 8

The two tracks

  1. The revival (2012)AlexNet ends the symbolic-AI era: deep learning is back.
  2. VisionGANs (2014), StyleGAN faces (2018), DALL-E (2021), then diffusion: Stable Diffusion and Midjourney (2022).
  3. LanguageWord2Vec (2013), LSTMs, the transformer (2017), GPT-3 (2020), ChatGPT and Claude.
  4. Convergence (2023+)Multimodal models that see and talk — and, given tools, the agent era.
Concept 2 of 8

Reading a milestone

FOR any launch or paper, ASK:
  which track is it from?
    vision   # GANs, diffusion, image/video
    language # embeddings, transformers
  what wall did it get past?
  will it cross to the other track?
    # usually yes -- e.g. transformers
    # now power image models too

REMEMBER: every modern advance traces
  back to the 2012 revival

Diffusion models learn to reverse a noising process: start from noise and denoise step by step into an image. They overtook GANs around 2021.

Concept 2 of 8

Misconceptions

“Generative AI is just language models.”
✅ The vision track — GANs, diffusion, latent spaces — is half the field, and keeps showing up in tools you’ll use.
“Neural networks were always the obvious approach.”
✅ For decades they were considered a dead end. The comeback needed data, cheap compute and better training all at once.

Generative AI is two tracks — vision and language — that converged. Knowing both explains why ideas keep jumping between them.

Concept 3 of 8

Seven acts, each ending at a wall

Modern LLMs feel like they appeared overnight in late 2022. They didn’t: they’re the seventh act in a long play, and each earlier act ended because researchers hit a wall the next breakthrough climbed.

The wall that mattered most fell in 2017. The transformer, from the paper “Attention Is All You Need”, replaced word-by-word reading with attention: every word looks at every other word in parallel. Training that took weeks took days, and everything you call an LLM today is a transformer.

Each era’s wall still shapes today’s models — which is why the history is a debugging aid, not trivia.

Concept 3 of 8

Climbing a staircase of walls

BEFORE: A climbing party reaches a cliff it can’t scale with the gear it has.

PAIN: Trying harder with the same gear gets nowhere. Hand-writing more grammar rules, or counting longer word sequences, just hits the same wall more expensively.

MAPPING: Each era of language AI brought new gear: counting, then meaning vectors, then memory, then attention. Knowing which wall each tool was built for tells you which of today’s limits are easy to fix and which are foundational.

Concept 3 of 8

The walls

  1. Rules (1950s–80s)Hand-written grammar, like ELIZA. Wall: language has effectively infinite rules.
  2. Statistics (1980s–2000s)N-gram counts. Wall: counts can’t capture meaning.
  3. Embeddings (2013)Word2Vec gives words meaning vectors. Wall: one vector per word, so “bank” is ambiguous.
  4. RNNs & LSTMs (2014–16)Read word by word with memory. Wall: slow, and forgets after a few sentences.
  5. Transformer (2017) onwardAttention in parallel, then GPT and BERT, then multimodal models and agents.
Concept 3 of 8

Where today’s quirks come from

IF a model favours common phrasings
  TRACE TO the counting era
  # frequent patterns dominate

IF search struggles with ambiguous terms
  TRACE TO one-vector-per-word embeddings

IF older models had tiny context
  TRACE TO the RNN era

IF training at scale became possible
  TRACE TO attention (2017)

GPT-3 (2020) was the first model big enough to do useful tasks from a plain-English description, with no retraining.

Concept 3 of 8

Misconceptions

“ChatGPT was the breakthrough.”
✅ ChatGPT (2022) was a product. The architectural unlock was the transformer, five years earlier.
“Old approaches are irrelevant now.”
✅ Their walls explain behaviours you’ll still meet, from favouring common phrasings to ambiguity in search.

The transformer (2017) was the unlock: attention let every token compare with every other in parallel, which made large-scale training feasible.

Concept 4 of 8

Four steps, repeated for every token

When you send “The cat sat on the” to Claude, four things happen: tokenize the text, embed each token as a vector of meaning, attend so each token’s vector absorbs its context, and predict a probability for every possible next token.

One token is sampled, appended, and the whole pipeline runs again, until a stop token or a length limit. There’s no database lookup and no reasoning engine beside a knowledge base. Everything you experience falls out of doing this prediction at enormous scale.

Concept 4 of 8

Not a search engine — a jazz musician

BEFORE: Most people picture an LLM as a search engine that memorized facts and looks them up.

PAIN: That picture misleads constantly: you’re surprised when it “hallucinates”, can’t see why temperature changes answers, and can’t explain why it contradicts itself mid-paragraph.

MAPPING: Picture instead a well-read jazz musician improvising. You play an opening phrase; they’ve absorbed the patterns of millions of pieces, and each next note is whatever sounds most plausible given all that and your phrase. They improvise the next note, then the next — one token at a time.

Concept 4 of 8

“The cat sat on the ___”

  1. TokenizeText becomes token IDs, roughly 4 characters each. It’s why pricing is per token.
  2. EmbedEach ID becomes a vector of meaning; “cat” lands near “dog”.
  3. AttendAcross many layers, each token weighs every other token, so “sat” knows the cat did it.
  4. PredictA probability for every candidate token; one is sampled, and it repeats.
Concept 4 of 8

The whole show

tokens = TOKENIZE(prompt)

REPEAT:
  vectors = EMBED(tokens)
  FOR each layer:
    vectors = ATTEND(vectors)  # mix in context
  probs = PREDICT(vectors[last])
  next  = SAMPLE(probs, temperature)
  APPEND next to tokens
UNTIL next is STOP OR length limit

RETURN the generated tokens

Temperature 0 always picks the most likely token; higher values flatten the distribution and let less likely tokens through, for variety.

Concept 4 of 8

Misconceptions

“It retrieves stored answers.”
✅ It samples plausible next tokens. If a plausible falsehood outscores the truth, you get the falsehood — that’s a hallucination.
“The same prompt should always give the same answer.”
✅ At non-zero temperature, sampling is deliberately random. Different answers are expected.

Tokenize, embed, attend, predict, sample, repeat. Once this picture clicks, most “surprising” LLM behaviour stops being surprising.

Concept 5 of 8

Knowledge, then instructions, then behaviour

The Claude you talk to is the product of three training stages. Pretraining shows the model an enormous amount of text and trains one task: predict the next token. It costs millions and gives the model its raw knowledge — and its knowledge cutoff.

Supervised fine-tuning trains on curated question–answer pairs so the model answers instead of just continuing text. Alignment — RLHF, plus Anthropic’s Constitutional AI — nudges it toward helpful, honest, safe responses, and gives it much of its character.

Concept 5 of 8

Reading the library, then learning the job

BEFORE: A new assistant spends years reading an entire library: they know an astonishing amount about everything.

PAIN: Ask them “What’s the capital of France?” and they might reply “is a question students often ask” — they learned to continue text, not to answer. And they don’t yet know which answers are helpful or safe.

MAPPING: Pretraining is the library. Fine-tuning is job training on worked examples (“a question gets an answer”). Alignment is the performance review that shapes judgement and tone. Skip a stage and you get the cheap copies that disappoint.

Concept 5 of 8

The pipeline

  1. PretrainingTrillions of predict-the-next-token steps over books, websites and code. Weeks on thousands of GPUs.
  2. Fine-tuningThousands of human-written input–output pairs teach it to follow instructions.
  3. AlignmentHumans rank pairs of outputs; a reward model learns those preferences; the LLM is optimized to score well.
  4. Constitutional AIAnthropic also trains the model to critique its own outputs against a written set of principles.
Concept 5 of 8

Three stages, three jobs

# Stage 1 -- pretraining
FOR trillions of steps over web-scale text:
  PREDICT next token; ADJUST weights

# Stage 2 -- supervised fine-tuning
TRAIN ON curated (question, good answer) pairs

# Stage 3 -- alignment
humans RANK pairs of outputs
reward_model = LEARN those preferences
OPTIMIZE LLM toward high reward
THEN FREEZE the weights

After training, the weights are frozen. That’s why memory and retrieval are whole topics in this course: they simulate learning without retraining.

Concept 5 of 8

Misconceptions

“The model learned that during our conversation.”
✅ The weights are frozen. What you tell it lives only in the context window and is gone in the next conversation.
“Fine-tuning is how you give a model new facts.”
✅ Knowledge mostly comes from pretraining. Fine-tuning shapes behaviour; for current facts, use retrieval or tools.

Pretraining gives knowledge, fine-tuning gives instruction-following, alignment gives helpful and safe behaviour. After that, nothing changes until the next model.

Concept 6 of 8

Same recipe, much bigger

The architecture inside GPT-4 isn’t fundamentally different from GPT-2’s: same kind of transformer, same objective, broadly the same data. What changed was scale — more parameters, data and compute — and the capability gap is enormous. GPT-2 wrote a passable paragraph; GPT-4 a passable legal brief.

Some abilities appear suddenly past a size threshold rather than improving gradually: arithmetic, multi-step reasoning, following unfamiliar formats. These emergent capabilities weren’t fully predicted, and nobody is certain what the next size jump brings.

Concept 6 of 8

Water at 99° and 100°

BEFORE: Heat water from 20° to 99° and it just gets hotter — same liquid, gradual change.

PAIN: Judge it by that trend and 100° is a shock: it suddenly boils. The change wasn’t in the recipe, only the amount of heat.

MAPPING: Scaling a model can work like that. Below a threshold, an ability is near zero; past it, it appears. Researchers debate whether it’s truly sudden or under-measured at small sizes — but the practical effect is real.

Concept 6 of 8

What scale bought

  1. Same objectivePredict the next token, from GPT-1 to today.
  2. More of everythingParameters grew from 117 million (GPT-1) to an estimated trillion-plus.
  3. EmergenceCoherent sentences, then essays, few-shot learning, multi-step reasoning, tool use and coding.
  4. The Bitter LessonRich Sutton (2019): simple methods that scale with compute beat clever hand-built ones, again and again.
Concept 6 of 8

What scale does and doesn’t give you

SCALE GIVES:
  broader knowledge
  emergent abilities past size thresholds
  a model worth wrapping in tools

SCALE DOES NOT GIVE:
  reliable action in the world
  current facts or a truth signal
  memory across conversations

SO: the course adds tools, retrieval,
    memory and loops around it

The lesson is “bitter” because it implies a lot of elegant research was, in the long run, the wrong path.

Concept 6 of 8

Misconceptions

“New algorithms made GPT-4 so much better than GPT-2.”
✅ Mostly the same architecture and objective. Scale — plus better training and alignment — drove the gap.
“Scale alone will produce capable agents.”
✅ Even the largest model can’t reliably act in the world without tools, memory and loops around it.

Scale was the engineering unlock; emergent abilities were its surprise. It gave us a model worth wrapping — the wrapping is still our job.

Concept 7 of 8

Know the limits you’ll engineer around

Understanding what an LLM can’t do matters more than what it can, because the rest of the course is about engineering around those limits.

The model has patterns, not facts. When it’s right, a fact appeared often enough in training to dominate the prediction. When it’s wrong — a hallucination — it’s doing exactly the same operation with the same confidence: there’s no internal truth signal. Math outside memorized patterns is unreliable, “reasoning” is pattern continuation, and nothing is learned between conversations.

Concept 7 of 8

The confident, well-read stranger

BEFORE: You meet someone who has read nearly everything and answers any question fluently, instantly, and in the same assured tone.

PAIN: Their right answers and wrong answers sound identical. They never say “I’m not sure”, can’t reliably do long arithmetic in their head, and won’t remember you tomorrow.

MAPPING: That’s an LLM. You wouldn’t fire them — you’d hand them a reference library, a calculator and a notebook. In this course those are retrieval, tools and memory.

Concept 7 of 8

Five myths and their fixes

  1. “It knows things”It has patterns. Ground it with retrieval and tools (M05, M09).
  2. “It can do math”Only familiar patterns. Give it a calculator tool.
  3. “It’s reasoning”It produces text that resembles reasoning. Chain-of-thought helps, but it’s still pattern continuation (M03).
  4. “It learns from us”Weights are frozen; persistence must be engineered (M08, M11).
  5. “Bigger is always better”For production, smaller specialized models often win on cost and latency (M14, M22).
Concept 7 of 8

Match the limit to the fix

IF it needs current or private facts:
  ADD retrieval or a lookup tool
IF it needs exact arithmetic:
  ADD a calculator tool
IF it must remember past sessions:
  STORE history, FEED it back as context
IF an answer must be right:
  VERIFY it -- fluency is not a truth signal
IF the step is routine:
  USE a smaller, cheaper model

The context window is the limit of what the model can consider at once — 200,000+ tokens for modern Claude. Anything outside it is invisible.

Concept 7 of 8

Misconceptions

“Hallucination is a bug that will be fixed.”
✅ It’s structural: the model always samples plausible tokens and has no truth signal. Grounding reduces it; it doesn’t disappear.
“Chain-of-thought means the model reasons like we do.”
✅ It gives the model room to lay out plausible steps, which often helps — but underneath it’s still next-token prediction.

An LLM is fluent, not factual. Retrieval, tools, memory and verification exist because of these limits — they’re the rest of the course.

Concept 8 of 8

Wrap the predictor in layers

An LLM by itself just produces text. A useful product wraps that prediction engine in layers. The raw LLM predicts text from text: stateless, factless, toolless.

Add a system prompt and conversation memory and you have an assistant: it follows instructions and holds a thread. Add tools and a loop — the model picks a tool, reads the result, picks the next — and you have an agent that can act in the world.

Every module in the course adds one of these layers around the same predict-the-next-token core.

Concept 8 of 8

An engine, a car, a driver

BEFORE: An engine on a test stand is powerful: it spins, it roars, it produces enormous force.

PAIN: It goes nowhere. It can’t steer, can’t carry anything, and can’t decide where to go.

MAPPING: The raw LLM is the engine. The assistant is the car around it — controls and a seat (system prompt, memory). The agent is the car with a driver who reads the road and chooses each turn (tools plus a loop). The engine never changed.

Concept 8 of 8

The three layers

  1. Layer 1: raw LLMCompletion, summarization, classification — “here’s input, continue”.
  2. Layer 2: assistantSystem prompt for role and rules, plus memory of the conversation (M03, M08).
  3. Layer 3: agentTools you wrote — search, code, email, databases — inside a loop the model drives (M05–M07, M12).
  4. Around themRetrieval, evaluation, guardrails and monitoring — more layers on the same core.
Concept 8 of 8

The agent layer

messages = [system_prompt, user_goal]

LOOP:
  reply = ASK LLM(messages, tools)
  IF reply calls a tool:
    result = RUN that tool
    APPEND result to messages
  ELSE:
    RETURN reply  # answered, or gave up

# same LLM underneath -- the loop and
# the tools are what make it an agent

You’re ready for M00, which shows a working agent end to end and the lifecycle the rest of the course follows.

Concept 8 of 8

Misconceptions

“An agent is a bigger or special model.”
✅ It’s the same kind of LLM. Agency comes from the architecture — tools plus a loop — not the model.
“A chatbot with a nice UI is an agent.”
✅ Without tools and a loop it can only talk. An agent takes actions.

Agent = LLM + tools + loop. The rest of the course teaches you to build that wrapping responsibly.

Test the core insight

5 questions on the module’s sharpest insights. Tap to reveal the answer.

Open the full module on desktop

The desktop version has the full timelines with interactive animations, the step-through of tokenize → embed → attend → predict, the scaling chart, a glossary of every term, and a knowledge check. No code — it’s the same mental model at full depth.

Open Generative AI Foundations on Desktop → Full primer · timelines, glossary, quiz · ~45 min

Bonus module · Foundations Primer