AI Training
Level 1 · Generative AI Literacy
Lesson 1.2Beginner 12 min

LLM Mechanics

Tokens, next-token prediction, temperature, pre/post-training, and why scale matters.

What you’ll be able to do
  • Explain what a token is and how an LLM turns text into tokens.
  • Describe next-token prediction and why temperature changes answers.
  • Explain pre-training vs post-training (including RLHF) in plain terms.
  • Say what billions of parameters means and why scale matters.

Your phone’s keyboard guesses your next word. An LLM is that same idea - scaled to most of the internet and billions of tiny dials.

The simple idea

Type “I’m running late, I’ll be there in ___” and your keyboard offers “5”, “10”, “a”. It’s predicting what usually comes next. An LLM does this for whole paragraphs, emails, and code - and the rest of this lesson is just unpacking how.

Five ideas, each builds on the last

1. Tokens - what the model actually reads

Models don’t see letters or whole words; they see tokens - chunks of roughly 4 characters (~0.75 of a word). Everything - cost, speed, and length limits - is counted in tokens, not words.

How does the split happen? The tokenizer learns the most common chunks of text and reuses them. A very common whole word like “the” or “running” is usually a single token, while a rarer or longer word gets chopped into smaller sub-word pieces it has seen before - so “unbelievable” becomes “un / believ / able.” Spaces and punctuation ride along as part of tokens too, and numbers often split digit-by-digit. (If you want the name for it: this is byte-pair, or sub-word, splitting.)

  • Where you’ve seen it: ever notice ChatGPT has a length limit, or that pasting a long PDF gets it “cut off” or costs more on the API? That’s tokens. Think of a taxi meter ticking up per chunk of text - the longer the ride, the higher the count.
unbelievable= 1 word, 3 tokens
Visual. A rare word gets chopped into sub-word pieces it already knows - 1 word, 3 tokens.
Interactive

Split it into tokens

Tap to see how the model chops text into tokens - and why the count rarely matches the word count.

I'll grab coffee later

Common words are often one token, but longer or unusual words get chopped into pieces - and spaces and punctuation count too. That’s why a long document is measured in tokens, not words, and why it can cost more or get cut off.

2. Next-token prediction - how it generates

At each step the model assigns a probability to thousands of possible next tokens, samples one, then repeats with the new text. After “The capital of France is”, the token “Paris” gets a huge probability and “banana” gets almost none.

  • Where you’ve seen it: Gmail’s Smart Compose. Start typing “Let me know if you have any” and a grey “questions” appears ahead of your cursor - you hit Tab and it’s right. It’s ranking the likeliest next chunk from everything it’s read. ChatGPT is that same trick, scaled up and never stopping until the thought is finished.
Visual. Predict one token, append it, predict again - the loop that writes everything.
Interactive

Predict the next token

Guess what the model thinks comes next, then see how it actually ranks the options.

The capital of France is ___

Tap the token you’d bet on

Prompt 1 of 3

3. Temperature - the randomness dial

Temperature controls how adventurous the sampling is. Low = pick the most likely token (focused, consistent). High = take more chances (creative, but riskier).

  • Where you’ve seen it: hit “Regenerate” on a ChatGPT answer and you get a freshly-worded reply every time - same prompt, different wording. That reshuffle is temperature: the model re-rolls which likely tokens it picks instead of repeating the exact same sentence.

Low temp

“Great coffee, every day.”

High temp

“Sip the sunrise.”

Visual. Same prompt, two temperatures - focused versus creative.

Same prompt - “a tagline for a coffee shop” - the dial just decides how safe or surprising the wording gets.

Interactive

Be the model

Set the temperature, then sample the next token - just like an LLM.

The weather today is ___
sunny
60%
cloudy
19%
rainy
11%
warm
6%
cold
3%
unpredictable
1%
banana
0%
Temperature0.70
Focused (consistent)Creative (riskier)

Low temperature makes the bars peaky - it almost always picks “sunny.” Crank it up and the bars flatten, so even “banana” gets a turn.

4. How it learned - two phases

Before it could chat, the model went through two very different schools.

  • Where you’ve seen it: picture a brilliant know-it-all who read the entire internet but has no manners - blurts facts, ignores your actual question. Then they go to finishing school, where coaches teach them to actually be helpful, honest, and polite. That second school is what turns raw knowledge into a useful assistant.
Visual. From internet-scale text to a helpful assistant.
  • Pre-training: read trillions of words, just predicting the next token. No labels needed - this is where raw knowledge and fluency come from.
  • Post-training (fine-tuning + RLHF): coach it with good examples and human preferences so it becomes helpful, honest, and safe.

Pre-training

In one line
Reads the internet and learns to predict the next token.
Trained on
Trillions of words of raw text, no labels.
Everyday effect
Fluent and knowledgeable - but a know-it-all with no manners.

Post-training

In one line
Finishing school: coached to be helpful, honest, and safe.
Trained on
Good question and answer examples + human rankings (RLHF).
Everyday effect
Actually answers your question politely and usefully.
Interactive

Order the training pipeline

Tap the stages in the order a chatbot is actually built, from raw text to helpful assistant.

Tap to add in order

Your order will build here.

0/6 placed

5. Scale and parameters

Parameters are the model’s adjustable dials, set during training - modern models have billions. More parameters + more data + more compute → more capability. That is the “scaling” story behind the leaps you’ve seen.

What does a single dial actually encode? Each one tweaks a tiny piece of a pattern, and together they store things like: how strongly “Paris” should follow “the capital of France,” that “cat” and “pet” are closely linked, that a plural noun tends to follow “three,” or that an angry email and a thank-you note carry very different tone. No single dial “knows” any of this - but billions of them nudging together add up to grammar, facts, and style.

  • Where you’ve seen it: it’s the difference between someone who’s read a handful of books and someone who’s read millions. More parameters means more practice and experience baked in - more dials to fine-tune means more skill and nuance.

Raised on the internet, then sent to finishing school

The model first “read the whole internet,” one token at a time, until it could finish any sentence.
That made it fluent and full of facts - but blunt, like a know-it-all with no manners.
Then humans coached it - good examples, then ranking its answers - until it was actually helpful.
Temperature is just the dial for how predictable or adventurous it gets when it replies.

Recap
  • Models read in tokens (chunks, not words) and write by predicting the next token over and over - your phone keyboard, scaled up.
  • Temperature is the randomness dial: low for consistent, high for creative.
  • It was raised on the internet (pre-training), then sent to finishing school (post-training: fine-tuning + RLHF) to become genuinely helpful.
  • Scale - more parameters, data, and compute - is why each generation feels smarter.

Finished the lesson?

Mark it complete to track your progress.