Skip to content
Lesson 3 of 7AI Prompting Fundamentals

Understanding AI · Lesson 3 of 7

How Large Language Models work

An intuitive, math-free look at tokens, next-token prediction, and training vs. use, and why that explains so much about how to prompt.

9 min readBeginner
Sign in to bookmark

You're learning as a guest — everything is open. Sign in to save progress, earn XP and pick up where you left off.

The one-sentence version

A large language model (LLM) is a system that has learned, from a huge amount of text, to predict what piece of text is likely to come next. Everything an AI assistant does, from answering questions to writing poems, is built on that one ability, repeated very quickly.

That sounds too simple to explain all the impressive things these tools do. Let's unpack it.

Step 1: Text becomes tokens

Models don't read letters or whole words the way you do. They break text into tokens: chunks that are often a whole common word, part of a longer word, a punctuation mark, or a space plus a word.

For example, a sentence like "Prompting is unbelievably useful" might be split into pieces roughly like this (the exact split varies from model to model):

text
Prompt | ing | is | un | believ | ably | useful

You don't need to count tokens to write good prompts. But knowing they exist explains some odd behavior. Because the model sees chunks rather than individual letters, tasks like "How many r's are in strawberry?" or "Write a sentence of exactly 17 words" can trip it up. It isn't looking at the text the way you are.

Step 2: Predicting the next token

Here's the core trick. Given all the tokens so far, the model calculates how likely each possible next token is, picks one, adds it to the text, and then repeats the process, one token at a time, until the response is finished.

A helpful analogy is the autocomplete on your phone's keyboard, but scaled up enormously. Your phone suggests the next word based on a small amount of your typing history. An LLM makes its prediction based on patterns learned from a vast library of books, articles, websites, code, and conversations, and it considers everything in your prompt and the conversation so far.

Another analogy: imagine an extremely well-read improv performer. Give them the opening line of a scene, and they'll continue it in a way that fits, matching tone, topic, and style, because they've absorbed so many similar scenes. They aren't looking anything up. They're producing what fits.

Note: There's usually a bit of controlled randomness in which token gets picked. That's why asking the same question twice can give different wording, or occasionally a different answer.

Step 3: Training vs. using the model

There are two very different phases in a model's life:

PhaseWhat happensWhen
TrainingThe model adjusts billions of internal settings by repeatedly predicting text and correcting its mistakes. Later stages teach it to follow instructions and be helpful as an assistant.Done once (by the AI company), before you ever use it
Inference (using it)The trained model reads your prompt and generates a response. It does not permanently learn from your chat.Every time you send a message

Two important consequences follow:

  1. The model has a knowledge cutoff. It learned from text up to a certain point in time. Unless the tool is connected to web search, it doesn't know about events after that.
  2. Your conversation doesn't retrain it on the spot. Correcting the AI helps within that chat, because the correction is now part of the prompt, but the underlying model doesn't instantly "learn" it for everyone.

Why phrasing matters so much

Here's the payoff for prompting. If the model produces whatever text best fits what came before, then your prompt sets the pattern it's continuing.

  • Write casually, and you'll tend to get a casual reply.
  • Ask for "a few ideas," and you'll get an average-sized list of average ideas.
  • Describe an expert audience and a precise format, and the model draws on patterns from expert-level writing in that format.
Before

Tell me about compound interest.

After

Explain compound interest to a 16-year-old who just opened their first savings account. Use one simple example with real numbers, avoid jargon, and finish with one practical tip they can act on this month.

The first prompt fits countless kinds of text, from textbook definitions to finance blogs, so you'll get something generic. The second narrows the pattern sharply: a specific reader, a specific style, a specific shape. The model doesn't have to guess.

A real-world example

Say you're writing a product description for an online shop. If you paste in three short descriptions you've already written and say "Write one for this new item in the same style," the model will pick up the length, tone, and structure from your examples and continue the pattern. That's next-token prediction working in your favor. You'll learn more about this later as few-shot prompting.

Watch out: Because the model predicts what sounds right, it can produce a confident, well-formatted answer that's simply false. Plausible-sounding is not the same as true. The next lesson covers this in detail.

What a language model is not

  • It's not a search engine retrieving stored pages (unless a search tool is attached).
  • It's not a database of verified facts.
  • It's not a person with beliefs or memories of you.

It is a remarkably capable pattern-continuer, and the clearer the pattern you set up, the better it performs.

Quick recap

Text is split into tokens. The model predicts the next token over and over to build a response. It learned its patterns during training and doesn't learn permanently from your chat. Since it continues the pattern your prompt sets, clear and specific phrasing directly shapes the quality of what you get.

Common mistakes

  • Mistake: Expecting the model to count letters or words with perfect precision.

    Fix: Use approximate targets ('about 100 words') or check exact counts yourself or with a tool.

  • Mistake: Assuming that correcting the AI teaches it permanently.

    Fix: Know that corrections only apply within the current conversation; restate important details in new chats.

  • Mistake: Thinking the AI is looking facts up when it answers.

    Fix: Remember it generates text from learned patterns, and verify important facts unless the tool clearly cites live sources you can check.

Practice exercise

Set the pattern

Use what you know about next-token prediction to steer an answer through the pattern your prompt creates.

  1. Start with the vague starter prompt below.
  2. Rewrite it to specify who the reader is, the style or tone, and the shape of the answer (length, structure).
  3. Optionally, include a short example sentence in the style you want, so the model has a pattern to continue.
  4. If you can, run both versions and compare how differently they read.

Your draft stays in this browser tab — it isn't sent anywhere.Try your draft in the Playground

Hints

Self-check

Tick each item your prompt covers.

0 of 4 checked

You can do the whole exercise as a guest.Sign in to save progress

Knowledge check

Test your understanding

Question 1 of 4

What is a token?

Finished reading?

Guests can read every lesson.Sign in to save progress

Continue to next lesson