Lesson 1.1 · 7 min read · about 50 min to master at a very slow pace

What an LLM Actually Does

A large language model predicts the next token, one at a time. What tokens are, what temperature changes, what the context window is, and why the same design that makes LLMs fluent also makes them hallucinate.

Not startedJump to quiz

One job: predict the next token

An LLM reads a sequence of tokens and outputs a probability for every token in its vocabulary being the next one. The application picks one, appends it, and asks again. A whole answer is this loop run a few hundred times.

A token is a chunk of text, usually a word or part of a word. In English, a useful rule of thumb is 1 token ≈ ¾ of a word, so 1,000 words is about 1,300 tokens. Other languages, code and numbers often need more tokens per word.

Temperature: how the next token is picked

The model gives scores; temperature reshapes them before sampling. At the most likely token is (almost) always chosen, so answers are repeatable. Higher flattens the distribution and gives more varied, more creative, and more error-prone text.

TaskTypical temperature
Extraction, classification, structured output0 to 0.2
Question answering over documents (RAG)0 to 0.3
Drafting, brainstorming, marketing copy0.7 to 1.0

The context window

The context window is the maximum number of tokens the model can see at once: your instructions, any documents, the conversation so far and the answer it is writing. Anything outside it does not exist for the model. The model has no memory between calls: a chatbot "remembers" only because the application resends the conversation each time.

Why LLMs hallucinate

The model is trained to produce plausible text, not true text. When it does not know, the most plausible continuation is often a confident, well-formed, wrong answer: an invented citation, a made-up product code, a policy that sounds right. Its knowledge also stops at its training cut-off and never includes your client's private documents.

Why this course exists

Almost everything in applied LLM work is a response to these limits. RAG and semantic search give the model the facts it lacks. Tools and agents let it act and look things up. Evals measure how often it is still wrong. Deployment practice keeps all of it affordable, safe and observable.

Stuck? Common doubts

Questions real learners asked while studying this lesson. They stay closed so they don't spoil your own thinking: open only the ones you need.

First passIf temperature is 0, is the output guaranteed to be identical every time?

Nearly, but not guaranteed. Hosted models run on batched GPU hardware where tiny numerical differences can flip a near-tie between two tokens, and providers update models behind the same name. Treat temperature 0 as "as consistent as possible", and pin a specific model version for anything you evaluate.

First passDoes a bigger context window mean I don't need search or RAG?

Not usually. Long contexts cost more per call, are slower, and models attend less reliably to facts buried in the middle of a very long input. A client's document store also grows far beyond any window. Retrieval picks the few passages that matter; a large window is useful for fitting more of them.

Going deeperCan I make the model stop hallucinating by telling it not to?

Instructions such as "only answer from the context; say you don't know otherwise" reduce hallucination a lot, especially combined with retrieved evidence and citations. They do not eliminate it. That is why you measure it with evals (Section 5) rather than trusting the prompt.

Cheatsheet

What an LLM does

Predicts a probability for each possible next token; the app samples one, appends it and repeats.

Tokens and words

English: 1 token ≈ ¾ word, so 1,000 words ≈ 1,300 tokens. Code and other languages use more.

The model has no memory

Each API call is stateless. Chat history exists only because the app resends it inside the context window.

See every cheatsheet by category →

Check your understanding

Score 75% or more to master this lesson and earn XP. Answer first, then check.

Q1conceptWhat does an LLM compute at each step of generating an answer?
Q2calculateUsing the rule of thumb for English, about how many tokens is a 3,000-word contract?
Q3applyYou are extracting invoice fields into JSON for an accounting system. Which temperature should you use?
Q4diagnoseA user says your chatbot "forgot" what they said 40 messages ago. What is the most likely cause?
Q5conceptWhy does an LLM sometimes give a confident but invented answer?