Skip to content
Course contents · How AI agents actually work

Lesson 1 of 13

What is an LLM?

What a large language model really does, why it can seem so clever, and what it can't do on its own.

If I say "who ya gonna call?", your brain probably says "Ghostbusters". You didn't look it up. You recognised a pattern and the answer arrived. A large language model does something similar, at an enormous scale.

It predicts the next token

At its core, an LLM (large language model) does one thing: it predicts the next token, based on the tokens that came before it.

A token is a small piece of text. It might be a whole word, part of a word, a punctuation mark or a few characters. The model picks one token, adds it to the text so far, then uses the longer text to pick the next one. Over and over again.

Finishing a sentence, one token at a time5 steps
  1. "Houston, we have a"
  2. The model scores every possible next token
  3. "problem" scores highly, so it is picked and added
  4. "Houston, we have a problem"
  5. Repeat until the answer is finished

Under the hood that scoring is a huge amount of matrix maths. You don't need to follow the maths to use AI well. You do need to remember that every answer is built this way: one likely piece at a time. The model doesn't always take the top score. Most apps let it pick among the likely ones, which is why the same question can get different answers.

Why that looks like intelligence

Predicting the next token sounds simple. But to get good at it across a vast amount of text, a model has to learn a mind-boggling number of patterns: grammar, facts, code, structure, style, and how ideas fit together.

That is why next-token prediction can produce answers that look a lot like thinking. Human pattern recognition and an LLM are not the same thing, of course. But both can produce a sensible-looking response from a learned pattern.

It also explains the famous failure: when the pattern is strong but the facts are missing, the model still produces something fluent and confident. It is completing a pattern, not checking a record.

What a model doesn't have on its own

On its own, an LLM has no goals, no tools, no memory between conversations and no way to check whether its answer is right. Text goes in, text comes out. Everything else is the system built around it, and the rest of this course covers each part:

Prompts
tell it what job it is doing
Context
gives it the information to work with
Tools
let it look things up and take actions
Memory
lets it carry facts from one conversation to the next
Loops
let it check its work and try again
Evals
tell you whether it actually worked

Open and closed models

One more distinction you will hear a lot. Open-weight models can generally be downloaded, run on your own computers and adapted, subject to their licence. Closed-weight models are only available through someone else's product or API.

Neither is simply better. The choice affects control, privacy, cost and where the model can run.

Running example

The running job

Chasing last month's unpaid invoices, one lesson at a time.

Through this course we follow one real job: Priya runs a design studio with eight people, and on the first working day of each month someone has to chase every overdue invoice.

Ask a bare model to "chase our overdue invoices" and it will happily write you a polite reminder email. What it can't do is know which invoices are overdue, who the clients are, or whether anyone paid yesterday. It has never seen Priya's accounts. Writing the email is the easy part. Everything else needs the system around the model, and that is what the next twelve lessons build up.

Practice

Try it yourself

About five minutes, in any AI chat app

See the model, not the magic

  1. Open any AI chat app you like. In a new chat, ask it to write a one-line slogan for a lemonade stand. Then ask exactly the same thing in a second new chat.

  2. Start another new chat and ask: "What did I ask you in my last chat?"

  3. Ask it to finish this sentence with a single word: "Who ya gonna..."

What to look for

The two slogans are probably different, because each answer is predicted afresh. The new chat probably can't tell you what you asked before, unless the app has a memory feature switched on. And the sentence gets finished instantly, because the pattern is so strong. Each of these is the bare model showing through.

Common mistakes

  • Treating the model as a database of facts.

    Give it the source material instead, and ask it to answer from that. You'll see how in the context and RAG lessons.

  • Expecting the same answer every time.

    The same question can produce different answers. If consistency matters, test it many times. That's what evals are for.

  • Assuming a bigger model will fix a bad result.

    Most problems come from the system around the model: a vague brief, missing information, the wrong tools. Check those first.

Quick check

3 questions to see what stuck. Nothing is scored or saved.

  1. 1. At its core, what does an LLM do?

  2. 2. Why can an LLM sound confident when it's wrong?

  3. 3. Which of these does a bare model have on its own?

Remember

An LLM predicts the next piece of text. Goals, tools, memory and checking all come from the system you build around it.

Sources and further reading

  1. 1.The LinkedIn post this lesson grew out of: What is an LLM?
  2. 2.LLM visualisation by Brendan Bycroft

Optional

Try it in LaunchLemonade

In LaunchLemonade you choose the model for each assistant. In a chat, Second opinion asks another model the same question, so you can compare. Everything above works in any AI tool.

Pick a model

Finished this lesson?

0 of 13 done in this course. Progress stays in this browser, no account needed.