Skip to main content
Tokenline

Line 1 · Station 5 of 6

Generative AI & Large Language Models

Look inside chatbots: how text becomes tokens, how models predict the next token, and why fluent doesn't mean correct.

  • 8 min
  • +50 XP
  • 2 knowledge checks

By the end of this station, you can:

  • Explain what tokens are and why models use them
  • Describe text generation as repeated next-token prediction
  • Explain why a fluent, confident answer can still be wrong

From recognizing to creating

Most of the AI we've covered makes predictions about existing things: Is this spam? Is this a cat? Generative AI uses what it learned to produce new content — essays, images, music, code.

A large language model (LLM) is a generative AI model trained on an enormous amount of text. Chatbots and writing assistants are built on top of LLMs.

Key terms

Large language model (LLM)
A very large neural network trained on huge amounts of text to predict likely next tokens, which lets it generate language.
Token
A chunk of text — a whole word, part of a word, or punctuation — that a language model reads and writes.
Next-token prediction
The core task of an LLM: given the text so far, estimate which token is most likely to come next.
Prompt
The input text you give a generative AI model to tell it what you want.

Step 1: Chop text into tokens

LLMs don't read letters the way you do. They split text into tokens. Common words are often a single token, while rare or long words get broken into pieces.

Each token is turned into numbers, since neural networks can only work with numbers.

Interactive lab

Token Vision

Type anything in the box. Each colored chip is one token — the chunk a language model actually reads. A “·” marks a space that belongs to the token.

Characters
66
Words
7
Tokens
16

Tokens

  1. Token
  2. ization
  3. ·is
  4. ·un
  5. believ
  6. ably
  7. ·important
  8. ·for
  9. ·un
  10. ders
  11. tand
  12. ing
  13. ·chat
  14. bot
  15. s
  16. !

Real models use tokenizers learned from huge amounts of text; this is a simplified imitation. The token IDs here are made up too, but the idea is real: to a model, your sentence is a list of numbers.

What to notice: Language models don't read letters or whole words — they read tokens, and each token is really a number. Common words are usually one token; long or unusual words get split into pieces.

Step 2: Predict the next token — again and again

Given “The team scored in the final,” a model estimates how likely every possible next token is: maybe “minute” is very likely, “seconds” is fairly likely, and “banana” is not.

It picks a token, adds it to the text, and repeats — one token at a time — until the response is done. A full paragraph is built from many small predictions.

Interactive lab

Next-Word Predictor

The model sees the prompt and scores possible next words. Click a word to add it, or let the model auto-pick. Try “high temperature” to see less likely choices.

Text so far

The best way to study for a test is to

Next-word candidates (illustrative probabilities)

Low temperature: the model always takes its top-scoring word — predictable, sometimes bland.

What to notice: An LLM writes by repeatedly choosing a likely next token — it doesn't check facts along the way. That's why answers can sound smooth and confident but still be wrong, and why the same prompt can give different answers.

Knowledge check 1

+10 XP on first try
Why might a chatbot give a slightly different answer when you ask the exact same question twice?
Learn moreWhat is “the model,” really?

After training, a model is essentially a giant file of numbers — the learned weights. It isn't a database of saved web pages that it looks things up in.

Most modern LLMs are based on the transformer, a neural network design introduced in a 2017 research paper. Transformers are good at tracking how words in a long passage relate to each other.

Knowledge check 2

+10 XP on first try
An LLM writes a smooth, confident paragraph about a local historical event, including a specific date. What should you conclude?

Key takeaways

  • Generative AI creates new content; LLMs are generative models for text.
  • LLMs split text into tokens and predict the next token, one at a time.
  • The trained model is a huge set of learned numbers, not a fact database.
  • Smooth writing can still contain errors — always verify important facts.

Sources for this lesson

  • Ashish Vaswani et al.. Attention Is All You Need, 2017. Full citation
  • University of Helsinki and MinnaLearn. Elements of AI. Full citation

Finish this station

Answer every knowledge check (right or wrong) to unlock completion.

  • Knowledge check 1 — not answered yet
  • Knowledge check 2 — not answered yet

0/2 checks answered