Module 2Episode 213 min
The whole of module 2 as one video. Jump to any chapter, or read the lesson it comes from.
What it teaches, what that builds on, and what it opens up next.
For a long time, there was a famous way to trip up an AI model. You asked it, how many letter r's are in the word strawberry? Models that could write essays and fix code would often answer, two. There are three. Today, how a model really reads text, how it writes, how it thinks, and what all of it costs.
Leila is surprised. Counting letters is the easiest thing in the world. A child can do it. Omid says, a child can, because a child sees the letters. What if you couldn't? The model never sees s, t, r, a, w, b, e, r, r, y. It sees three pieces. S T, raw, and berry. And each piece is just a number to it. So to count the r's, it would have to remember how each piece is spelled. But why cut text up like that? Why not give it the letters? Every piece a model reads or writes costs it one step of work. A sentence has about seventy letters. That is seventy steps, for every sentence. Then why not whole words? Because there are millions of words, in every language, plus names, typos and code. And there is always a new one. So the answer is in between. Common words are one piece. Rare words are built from a few common pieces.
These pieces are called tokens. Before a model reads anything, a program called a tokenizer cuts the text into tokens. Hello, how are you today? That is seven tokens. Most words are one token. Even the comma and the question mark. Then each token becomes a number. The model reads numbers, and writes numbers back. The tokenizer has a fixed list of every piece it knows. Its vocabulary. About one hundred thousand to two hundred thousand pieces. Common words are one token. The, how, today. Long, rare words split. Unbelievably becomes un, bel, and ievably. Numbers split into chunks. One two three, four five six, seven. That is one reason models used to slip on arithmetic with long numbers. How long is a token? For English, a useful rule. One token is about four characters. Or about three quarters of a word. So a thousand tokens is roughly seven hundred and fifty words. A page and a half of a book. Other languages often need more tokens. Tokenizers are built mostly from English text. The same short paragraph took forty tokens in English. In Persian, it took sixty two. And with an older tokenizer, one hundred and twenty seven. So working in another language fills a model's limits sooner, and costs more. Tokens are the unit of everything about an agent. Speed. A model writes one token at a time. Limits. A model can only see so many tokens at once. Price. AI companies charge per token, in and out. And an agent reads a lot. Files, web pages, results. All of it becomes tokens.
Three habits from this part. One. Don't trust a model with exact letter jobs, like counting letters. Ask it to run a small program, or check yourself. Two. Estimate in tokens. About seven hundred and fifty English words per thousand tokens. Three. Expect other languages to take more tokens, and to cost more.
When you ask a chat assistant something, the answer doesn't appear all at once. It flows onto the screen, a few words at a time. Leila always thought the answer was ready, and the app shows it slowly to feel friendly. But the model really does make it piece by piece. Remember what a model learned to do in training? Guess what comes next. You give it some text, and it gives you its guess for the next token. Just one. That token is added to the end. The whole text goes back in. And it guesses again. Again and again, hundreds of times. Until it writes a special token that means, I'm finished. And it's not exactly a single guess. The model gives every token in its vocabulary a chance of coming next. After, the cat sat on the. Mat gets forty one percent. Floor, seventeen. Sofa, nine. Bed, six. And thousands of others get almost nothing. Then one token is picked, from these chances. This is called sampling. Usually one of the likely ones. But not always the top one. Always picking the top token makes dull, repetitive text. A dial called temperature sets how adventurous the pick is. Low sticks to the top tokens. High gives the others a real chance. Put together, writing is a loop. Give every token a chance. Pick one. Add it to the text, and go round again. This is next token prediction. It is the only thing a language model does. A poem, or a plan to fix a bug, is built from these single steps.
This explains a few things you've seen. Answers stream in, because each token is a full step of work. Ask for a name for a bakery, in two new chats. You get two different answers. A different pick early on sends the rest of the answer down a different path. And Leila has noticed something. Once it starts on a wrong idea, it often keeps going with it. Because a token, once written, is never taken back. Every next step continues the text as it now stands. Mistake included. And what usually comes after a confident wrong claim? More confident claims backing it up.
Three habits. One. If an answer heads the wrong way early, start it again, rather than arguing with it. Two. For an important question, ask again in a new chat, for a second opinion. Three. For anything that must be exact, ask for something you can check. The working, the source, or the command it ran.
Some AI apps show a little note before the answer. Thought for twelve seconds. Agents do it too, often for much longer. What is the model doing, and why does it help? Leila asks Omid. What is seventeen times twenty four? Don't work it out. Just say the first number. Something like, four hundred? He would be guessing. And if he can write it down? Seventeen times twenty is three hundred and forty. Seventeen times four is sixty eight. Together, four hundred and eight. He needed the steps. A model does about the same amount of work for every token. Whether it's the word, the, or the answer to a hard sum. Ask for only the number, and it gets one token of work on the problem. Like blurting out, four hundred. Ask it to work it out step by step, and every step is more tokens. More work. And it can read its own steps back, because they are part of the text now. The text is its paper. Today's models do this on their own. Before the answer, they write thinking tokens. Also called reasoning. They plan, try an approach, notice a mistake, and try again. Then they write the answer you see. Apps usually hide the thinking. But it is real text. Thinking tokens are output tokens. You wait for them, and you pay for them. More thinking helps most on hard problems. Code, plans, maths, puzzles. For the capital of France, it adds time and cost for nothing.
So many models let you choose how much to think. In Claude, this is called effort. From low to max. Low effort means fewer thinking tokens. Faster and cheaper. Good for quick, simple jobs. High effort means many thinking tokens. Slower and costlier, but better on hard problems. A tricky bug, or a plan for a big change. One word of care. The visible thinking is not guaranteed to be an exact record of how the model got its answer. Researchers have found cases where the reasoning left out something that clearly mattered. Read it as a helpful sketch, not as proof.
Three habits. One. Match the effort to the task. Up for hard problems. Down for quick, routine work. Two. For hard tasks, ask for the plan first. You can catch a wrong path early. Three. Don't treat the thinking as a guarantee. Check the answer itself.
Leila's company gives her an API account. She pays for the AI she uses by the amount. After a week, she looks at the bill. One long conversation cost more than all her short ones put together. Where did the tokens go? AI companies charge for two kinds of tokens. Input tokens. Everything sent to the model in a request. Output tokens. Everything the model writes back. Including its thinking, even the parts you never see. Output costs more. About five times as much for Claude's models. Reading is quick work. Every output token needs its own full step. To give a sense of scale. In late twenty twenty six, Claude's largest everyday model cost about four dollars per million input tokens, and twenty dollars per million output tokens. Its smallest model cost about forty times less. So one question and answer costs a fraction of a cent. The interesting question is, how does a bill get big?
Leila's long chat had twenty messages. Each message and its reply came to about five hundred tokens. So, ten thousand tokens in all. But the model keeps nothing between requests. To let it remember, the app sends the whole conversation so far, with every new message. The first request is five hundred tokens. The second, one thousand. The third, one thousand five hundred. Up to ten thousand, for the twentieth. Add them up, and it's one hundred and five thousand tokens. More than ten times what the conversation looks like. You pay for the whole staircase. Not just the top step. Now think of an agent. Every time it uses a tool, the result goes into the conversation, and the whole thing is sent again. One task can take a hundred steps. That can add up to millions of input tokens, for one job. Time is tokens too. Reading input is fast. But output is written one token at a time. From tens to a couple of hundred tokens a second. A model that thinks for five thousand tokens makes you wait for every one. And on a subscription, the same long sessions are what use up your limits.
Four habits. One. Start a new conversation for a new task. Two. Use a smaller model for simple jobs. It can cost dozens of times less. Three. Keep big pastes out of long chats. A document pasted early is sent again with every message after it. Four. Lower the effort when the job is easy. Thinking tokens are the expensive kind.
Let's put it together. A model reads and writes tokens, common pieces of text. And it writes them one at a time. Thinking is more tokens, and better answers on hard problems. And you pay for every token in and out. The whole staircase. Next time, the context window. Everything a model can see at one moment, and what happens when it fills up. The lessons and quizzes for this course are free on knaph dot com. See you in the next episode.