Home / Learn / Data & AI / ML foundations / Lesson 10.7
All lessons

Module 10: From words to an LLM · Lesson 10.7 · about 20 min

What an LLM is, and what it is not

An LLM is a very large next-token predictor: a fixed set of numbers that turns text into probabilities. Ask a made-up model the same question 20 times, see why fluent answers can be wrong, and learn how real systems guard against it.

Key points, meanings and formulas on one page: choose "Save as PDF" in the print box.

Module 10 · about 20 minutes · read first: 10.3, 10.6. You’ll be able to describe an LLM in one accurate sentence, explain context windows, hallucinations and knowledge cut-offs, and say how retrieval and tools make answers more reliable.

An LLM is a huge, fixed set of numbers that turns text into odds for the next token. It writes by drawing from those odds, so it is fluent by design and right only most of the time.

1. Why this matters

LLMs are now part of most office work, and the people who use them well are the ones who know what they are. A clear picture stops two opposite mistakes: trusting every confident answer, and dismissing a tool that is truly useful for drafting, summarising, coding and explaining.

2. What it is

An LLM is a function with billions of fixed numbers (weights) that turns a piece of text into probabilities for the next token. Everything else is a loop around that function:

  1. The app builds a prompt: hidden instructions (the system prompt), the conversation so far, any documents, and your message.
  2. The model gives probabilities for the next token (Lesson 10.3). One is drawn (with a temperature) and added to the text.
  3. Repeat until an end token. A 500-word answer is around 700 runs of the network.

Watch the loop answer “The capital of Australia is”:

Build the prompt. System prompt + chat so far + "The capital of Australia is". This whole text is all the model can see.

Get the odds. The network outputs, say: Canberra 0.55, Sydney 0.30, Melbourne 0.08, others 0.07.

Draw one. Like spinning a wheel with those slice sizes. This time it lands on "Canberra", but 38 times in 100 it would land on a wrong city.

Add it and repeat. "Canberra" joins the text, and the model guesses the next token after it (".", then the end). Each token is one more spin.

Give it the facts. Put "Canberra is the capital of Australia" from an atlas into the prompt, and Canberra's odds rise close to 1. That is what retrieval does.

The context window is how many tokens the model can see at once, prompt and answer together: from a few thousand to over a million. Anything outside it does not exist for the model.

3. What it is not

  • Not a database. Facts are stored only as patterns in the weights. Common facts come out reliably; rare ones (a small company’s founding year, a minor court case) may come out wrong but fluent. This is called hallucination.
  • Not up to date. It knows nothing after its training text was collected (its knowledge cut-off), unless the app searches the web or your files and puts the results in the prompt.
  • Not learning from your chat. The weights do not change while you talk. “Memory” features save notes and paste them into later prompts.
  • Not a calculator or a source. It can do sums and cite papers in the style of doing so; check numbers with a tool and look citations up.
Try it: ask the same question 20 times

Prompt: The capital of Australia is …

Canberra (right)–
Sydney or Melbourne (wrong, but sounds right)–

Made-up probabilities for teaching. The model has no list of facts to look up: it has probabilities for the next token, shaped by how often things were written together. "Sydney" appears next to "Australia" far more often than "Canberra" does, so a wrong answer gets real probability, and when drawn it comes out just as fluently as the right one. Low temperature almost always gives the top answer; high temperature spreads the draws. Checking facts against a source (a search, a database, your own documents) is how real systems reduce such errors.

The usual fixes add facts from outside: retrieval-augmented generation (RAG: find relevant passages with embeddings, Lesson 10.2, and put them in the prompt), tools (a calculator, a search, a database query) and asking for sources you can check.

Maths and principle

Principle: an answer is a chain of draws, and every draw can go wrong.

Generating: with pθ the network,

wt+1∼pθ(⋅|w1,…,wt),t=1,2,…

Small error rates add up. If each stated fact is wrong with probability e, independently, an answer with n facts contains at least one error with probability

1−(1−e)n

Analogy: a very well-read friend speaking from memory, without notes. Usually right on common things, sometimes confidently wrong on details, and much better when you hand them the document.

Try it: each fact is right 99 % of the time; a report states 50 facts. Chance of at least one error? (1−0.9950=0.39: about 2 reports in 5.)

e
the chance that any one stated fact is wrong
n
how many facts the answer states
(1 − e)n
the chance that every one of them is right
1 − (1 − e)n
the chance that at least one is wrong
Physical meaning
A model that is right 99 % of the time per fact still slips somewhere in about 2 of every 5 fifty-fact reports. Long answers need checking, especially the numbers, names and dates that a decision depends on.

4. Worked example

The made-up probabilities in the simulation for the word after “The capital of Australia is”: Canberra 0.55, Sydney 0.30, Melbourne 0.08, others 0.07.

  • At temperature 1, a wrong city comes out 38 % of the time: about 8 answers in 20.
  • At temperature 0.5 the probabilities become p2, rescaled to add up to 1: Canberra 0.75, Sydney 0.22. Still wrong almost one time in four.
  • At 0.2, Canberra 0.95. Lower temperature helps here only because the top answer happens to be right. If the training text had made “Sydney” the top word, low temperature would give the wrong answer every time.

Putting a sentence from an atlas into the prompt (“Canberra is the capital of Australia”) raises the right answer’s probability close to 1. That is what RAG does.

“It sounds so sure, so it must be right.” The model’s tone comes from the same next-token process whether the content is right or wrong. Confidence in the wording is not a measure of truth. Ask for the source passage, or give it the document, and check what matters.

5. Practice

  1. In the simulation, set the temperature to 2.5 and ask 20 times. Why do “a” and “the” start to appear?
  2. A colleague says “the model checked its database and found the figure”. What is a more accurate description?
  3. Name two ways to make an LLM’s answer about your company’s own policies reliable.
Answers
  1. High temperature flattens the probabilities, so unlikely tokens such as “a” (as in “a city …”) are drawn more often.
  2. It generated likely text from patterns in its weights; unless a search or database tool was connected, nothing was looked up.
  3. Put the policy text in the prompt (or use RAG over the policy documents), and ask it to quote the passage it used so a person can check.

Try it on your own data: the free Offline AI course shows you how to run an LLM on your own computer, with nothing sent anywhere, and the prompt pruner prepares your documents for it.

New words: large language model, prompt, system prompt, context window, hallucination, knowledge cut-off, retrieval-augmented generation, tool use.

  • An LLM is a fixed function that turns text into next-token probabilities; an answer is a long chain of draws.
  • The context window is everything it can see; its weights don’t change while you chat.
  • It is not a database, a calculator or up to date, so fluent answers can still be wrong (hallucination).
  • Small error rates add up: 1 − (1 − e)n for n facts.
  • Retrieval (RAG), tools and checkable sources put real facts in the prompt and make answers reliable.

Check yourself

1An LLM answering a question:
2Why can an LLM give a wrong answer that sounds completely sure?
3Between two separate chats, a plain LLM remembers:

Sources

Your ticks stay in this browser. Save them as a file on the course home.

Updated 2026-11-22. Numbers in the examples are made up to show the idea unless a source is given. Simulations run in your browser; nothing you type is sent anywhere.