Knaph

What an Agent Is1 of 375 min read

Text In, Text Out

You type a question into a chat assistant, and a few seconds later a clear, confident answer appears, in good sentences, sometimes with a table or a piece of code. It feels like talking to someone who knows a lot. What is actually on the other side?

This course answers that question, and then a bigger one: how the same thing can become an agent that reads your files, runs programs and works on a task for an hour. Along the way you'll meet two people. Leila works in marketing at a small company; she has used AI chat for a year and started using an agent a month ago. Her friend Omid builds agents for a living.


Leila I use it every day, and I still don't really know what it is. When I ask it something, does it look the answer up somewhere?

Omid What do you think happens when you ask it something it has never seen, like a poem about your own cat?

Leila It writes one. So it can't just be looking things up. It must understand what I'm asking.

Omid It certainly does something that looks like understanding. Let's be exact about what goes in and what comes out, though. What do you give it?

Leila My message. Text.

Omid And what does it give back?

Leila Text. Sometimes code or a table, but that's text too, really.

Omid That's the whole interface. At the centre of every chat assistant and every agent is a language model: a program that takes text in and gives text out. Nothing else. It can't click, it can't open your files, it can't go on the internet. It reads text and writes text.

Leila But it knows things. It knew the capital of Uruguay and how to fix my spreadsheet formula.

Omid It does. The question is where that knowledge is kept. Let me tell you how it was made, and you tell me.


How a language model is made

A language model starts as a huge set of numbers, all random. It is then shown a vast amount of text: books, websites, articles, code, billions of pages. Again and again, it is given the start of a piece of text and asked to guess what comes next. Each time it guesses wrong, its numbers are nudged a tiny bit so that next time the right continuation is a little more likely. This is called training, and for a large model it takes months on thousands of computers.

A language model reads a mountain of pages during training, and what it learns is stored as billions of numbers inside it, not as a copy of the pages.

Something remarkable happens along the way. To guess the next words of a chemistry book well, it helps to have picked up some chemistry. To continue a story, it helps to keep track of who is who. To finish a line of code, it helps to know how the language works. So the model ends up with a great deal of what we would call knowledge and skill, all packed into those numbers, which can run into the hundreds of billions.

Then it is trained further on examples of a helpful assistant answering people, so that it continues your message with a helpful reply rather than with, say, more questions.


Leila So the knowledge is in the numbers. There's no library inside it.

Omid Right. Nothing it read is kept as a page it can go back to. Which means?

Leila It can't check. If it remembers something slightly wrong, it will just say the wrong thing.

Omid And say it in the same confident tone as everything else, because a fluent, confident sentence is what usually comes next. That's one reason AI answers are sometimes wrong in ways that sound completely right.

Leila But my chat assistant does search the web sometimes. I've seen it show links.

Omid It does, and here's the interesting part: the model isn't the one searching. The app around it is. The model writes, in effect, "please search for this", the app does the search and pastes the results back in as more text, and the model reads them and writes its answer.

Leila So the model is still only reading and writing text. The app does everything else.

Omid Exactly. Keep hold of that, because it's the key to the whole course.


Text in, text out

Here is the picture to keep in your head. Whatever you see an AI system do, the model at its centre did one thing: it read some text and wrote some text.

Text goes into the language model and text comes out. Everything else, like searching or running code, is done by the app around it.

The text you give a model is called the prompt. In a chat, the prompt is more than your latest message: the app quietly includes the earlier messages too, and some instructions of its own. Later lessons look at exactly what goes in.

When the app around the model does something, like searching the web or running a calculation, that's the app acting on text the model wrote. In the next lesson you'll see how far that idea goes: give a model the right app around it, and it can rename your photos, fix a bug or fill in a report. That's an agent.

Try it

Open a brand-new chat with any AI assistant and ask: "What did I ask you yesterday?" Most will tell you they can't know (some apps have a memory feature, which you'll meet later). The model only knows what is in the text it's given right now.

Using it well

  1. Treat facts from the model as a good first guess, not a source. Its knowledge is stored as patterns in numbers, and it can't look anything up unless the app gives it a search tool.
  2. Give it the text it needs. If an answer depends on your document, your numbers or your situation, paste them in. It can only work with what's in front of it.
  3. When it does something, ask who did it. "It searched the web" means the app searched and the model read the results. Knowing which part did what helps you understand both its mistakes and its powers.

Words to know

  • language model - a program trained on a vast amount of text that takes text in and gives text out; often just called "the model"
  • training - the long process in which a model reads text, guesses what comes next, and has its numbers adjusted to guess better
  • prompt - the text given to a model, which it continues

Big idea

A language model only reads text and writes text. It learned a great deal by predicting text, and keeps it as numbers, not pages. Everything else an AI system does is done by the program around it.

Test your understanding

Sign in to test your understanding of this lesson and track your progress.