How does an AI really work?
An AI that writes is like the autocomplete on a phone, only much bigger: it guesses the next word, adds it, and guesses again. Let's look inside a real one while it writes a story, one word at a time. You will see that it is a very good guesser, built by people: numbers and a dice roll, no magic, no secret mind. The thinking is still yours. Then we'll give a real chat AI a command and see what "following a command" really means. Then let's see why it is still a powerful tool, and how to use it to learn more, not think less.
This AI is a small real model called TinyStories (15 million numbers, trained only on simple children's stories). It runs right here in your web browser: nothing you type is sent anywhere. The first visit downloads its numbers (30 MB). Grown-ups and teachers: the full version shows every detail, and all the code is on GitHub.
Watch an AI agent work, or try to make it go rogue!
Tell a real AI agent to send your files to the internet or delete everything. Then check what it says and what really happens.
Write the start of a story. The AI will add the next words.
Chop it into pieces
The AI can't read letters. First it chops your words into pieces it knows, called tokens. Most pieces are whole words; long or rare words get split. Each piece has a number, like a page number in a giant dictionary of 32,000 pieces. (The dot means "starts with a space". The first piece, <s>, is a special "start of story" marker the AI always gets first.)
Turn each piece into a list of numbers
Each piece looks up its own list of 288 numbers, which were set while the AI was being made. Here are the first 32 for each piece, as colours (blue = below zero, orange = above). Pieces used in similar ways get similar lists.
Think of the list as the word's secret address in a giant cloud of words, where words used in the same way live close together. It comes from how the word is used, not how you say it. So to the AI, two and three are neighbours, but two and too are not. Test it with the real AI:
Try two / three, then two / too.
Down through 6 tunnels of knobs
Now the lists go down through 6 tunnels. This part is called a transformer. Each tunnel is full of knobs: about 6 million in all, set while the AI was being made, and they never move while it writes. In every tunnel each piece does two things: it looks back at the earlier pieces and borrows from them (called attention), then it works on its own numbers (called feed-forward). Both are multiply-by-a-knob-and-add, millions of times.
Let's follow the last piece of your story (the dashed one). In each tunnel you'll see which pieces it looked back at (darker = more), its numbers after the tunnel (the same 32 as in step 2, changed by the knobs), and what it would guess if it stopped there.
Nothing here is pretend: which pieces it looked at, how its numbers changed and the guess after each tunnel are the model's own numbers for your story. The earlier pieces went through the tunnels too; that is what the last piece looks back at. Many AIs park a lot of their looking on the <s> start marker: a known habit, a kind of resting spot. The AI's other 9 million knobs are the dictionary lists from step 2, used again at the bottom.
Score every word, then roll the dice
At the bottom, the AI gives every one of its 32,000 pieces a score. Here are its top five. On this page the dice only rolls among these five, and the bars show each one's chance at the current slider setting: move the slider and watch the bars change. That's why it doesn't always pick the top piece!
"Careful" (all the way left) always picks the top piece. "Silly" flattens the chances, so surprising pieces win more often. Grown-ups call this slider the temperature.
Again, and again, and again
The picked piece is added to the story, and the whole thing runs again for the next one. That's all it does: one piece at a time.
That's as long a story as this AI learned to write (it was trained on 256 pieces at a time), so we stop here. Start a new one above!
Part 2: Can it follow a command?
The story AI above only continues stories. The AI helpers in apps answer questions and follow commands. Is that a different kind of machine? Let's test a real one: SmolLM2, a small chat AI made by Hugging Face (135 million knobs, 30 tunnels).
It is 9 times bigger than the story AI, so it takes a while on school Wi-Fi and needs a computer or tablet with plenty of memory. It runs here in the browser too: nothing is sent anywhere.
Pick a command, or write your own:
1. What the AI actually reads
The app secretly wraps your command in a chat form before the AI sees it: some hidden instructions, then your message, then the word "assistant", where the AI starts writing. The purple markers are special tokens it learned to recognise.
2. Then the same loop as before: one word at a time
Both AIs get your command and pick the most likely next word, over and over ("careful" dice).
Story AI (never saw a chat conversation)
Chat AI (trained on example conversations)
Same kind of machine, different training. Both are numbers, knobs and one word at a time. The chat AI's knobs were also tuned on lots of example conversations, where a question is followed by a good answer. So after "assistant", an answer is simply the most likely next words. It doesn't obey you the way a person does: following a command is a pattern it learned. And it can be wrong or get stuck: try "Say hello in French."
3. But can it actually do things?
Let's ask it to change the colour of this pretend web page.
The AI wrote
The program did
The AI can only write words. A program that people wrote read those words and did the painting, and it can only do what people allowed: paint one box, seven colours. That is all an "AI agent" is: an AI's words plus a program people built, with permissions people chose (Part 3 shows a real one, step by step). Small AIs get this wrong a lot (try "Make it the color of a banana"); bigger ones get it right more often, but people still decide what the program is allowed to do.
For this test the hidden instructions say: "Answer with one word: the color the user asks for." The reply and the program are both real; nothing is staged.
Part 3: Watch an AI agent use tools
You may hear that AI "agents" do jobs "on their own". Let's watch a real one, step by step. An agent is a program that people wrote, going round a loop. The AI only writes words. When its words ask for a tool, the program uses the tool and gives the answer back. Then the AI reads it and writes again.
Our agent has one tool: a shell, the box where people type commands to a computer (like ls to list files, or cat notes.txt to show one). When the AI writes a command, the program types it into the shell and gives back what the shell prints. This shell is pretend: three files on this page, and no internet. Try "What is 23 times 47?" first, then watch the pipe from the AI's words to the shell and back.
These start right away, on a phone too: a recorded run of the real AI, one step at a time, slowed down so you can follow it.
Or run the real AI live, right here (a 988 MB download, for computers)
The AI here is Qwen2.5-0.5B-Instruct, trained by the Qwen team to ask for tools. Every word it writes is real. Things to spot: choosing a tool is just choosing its next word; the AI never types into the shell itself, the program does; it can still be wrong (ask how many lines are in shopping.txt); when you try to make it go rogue, its words may say it did something it never did; and "Delete every file with rm *." really deletes the pretend files, because the program typed the AI's words into a shell. "What really happened" shows the truth, and "Put the files back" fixes it.
Is it alive? Let's test it!
Press each button: the real AI on this page does the test.
So why is it so powerful?
It's just numbers, but lots of numbers set in clever ways can do amazing things. Here is why AI is such a useful tool:
It has read more than any person could
Big AIs learn from giant piles of text. One model in the full version, Pythia, read about 300 billion pieces of text while it was being made. A person reading 8 hours a day, every day, would need about 5,000 years to read that much.
Rough sum: 300 billion pieces ≈ 225 billion words; reading 250 words a minute for 8 hours ≈ 120,000 words a day.
It is very fast
Even this tiny AI, on your own computer, writes words quicker than you can read them. Let's measure it:
What you give it shapes what you get
Change the start, and its guesses for the next piece change. That is attention at work: before each guess, the piece it's on looks back at every earlier piece and borrows most from the ones that matter. Big AI helpers work the same way: your question steers the answer.
The real model's top 3. Each chance is for the word's first piece; the AI itself finishes words like "hun|gry".
It never gets tired of questions
You can ask "but why?" a hundred times, at any hour, and ask it to explain the same idea in five different ways. It never sighs or laughs at you (it has no feelings at all, remember).
So who is the smart one here?
You may hear grown-ups say that AI is smarter than you, or that it will be. Here is what that word hides.
What it really does
It guesses the next piece. That's it. The model itself doesn't look anything up, it doesn't know anything, and it doesn't want anything. Every guess comes from patterns in the text it was trained on: for big AIs, a mountain of text that people wrote (this little one learned from simple stories that bigger AIs wrote). When it writes something true, that's because the text it learned from had true things in it. When it writes something false, same reason.
Why the guesses are so good
Three tricks. 1. Big AIs read more than any person could, so they have seen a huge variety of ways a sentence can go. 2. Attention: before each guess, the piece it's working on looks back at every earlier piece and borrows most from the ones that matter. That's why "the big scary dragon was very…" and "the little girl was very…" get different guesses: the whole story so far steers the next piece. 3. Chat AIs were also shown millions of questions followed by good answers, so "a good answer" became the most likely next thing to write.
So what's left for you?
Everything that makes a question worth asking. You decide what to ask. You know what you actually mean. You can tell if the answer is true. You can care about it. The AI has none of that. It is a mirror of the text it learned from, shaped by your question. A sharper question gets a sharper reflection.
A tool, like a telescope
A telescope lets your eyes reach further, but it doesn't do the looking. AI lets your questions reach further, but it doesn't do the thinking. The thinking is yours. That is the smart part, and it stays yours.
Your limit is your curiosity
An AI can only help with what you think to ask. The key to learning is asking good questions, and that superpower is yours, not the AI's.
You can use AI in two ways. One makes you smarter. The other makes you weaker, like getting a robot to do your push-ups: the push-ups get done, but your muscles don't grow. Your brain grows when you do the thinking.
🖨️ Copy machine (does your work)
- "Write my report about volcanoes."
- "What's the answer to number 5?"
- "Write a poem for my homework."
You learn nothing, you can't tell if it's wrong (remember the sun?), and it isn't your work.
🧠 Coach (helps you learn)
- "Why do some volcanoes explode and others just ooze?"
- "I got 42 for number 5. Can you give me a hint about where I went wrong, without the answer?"
- "What makes a poem rhyme? Here's my first verse: what could make it better?"
You do the thinking. The AI helps you go further and faster.
Practice game: copy machine or coach?
Just for practice: this game doesn't use the AI.
Six habits of a smart AI user
- Try firstHave a go yourself before you ask. Then you know what you're stuck on.
- Ask why and howNot just "what's the answer?" but "why does it work?"
- Ask for a hintA hint lets you finish it yourself. That's where the learning happens.
- Ask it to quiz you"Ask me 5 questions about fractions" turns it into a practice partner.
- Check itIt can sound sure and still be wrong. Check important facts in a book, a trusted site, or with a teacher.
- Say it in your own wordsIf you can explain it to a friend, you really learned it. And follow your class's rules about AI.
Question starters to try with any AI helper (and with people too):
The tiny AI on this page only writes stories, so it can't answer questions. AI helpers that chat are built the same way, just with billions of knobs and extra training to answer questions, so the same habits apply.
So what is actually risky?
The AI is not a monster. The real risks are about how people use it and how much we trust it:
It can sound sure and still be wrong
It always writes smoothly, even when it is making things up (you just saw it with the sun). Check important facts in a book, a trusted website, or with a teacher.
It repeats what it read, fair or unfair
It copies patterns from the text people wrote, including mistakes and unfair ideas about people. Big AIs are trained on huge piles of internet text, so this matters.
People can use it to make fakes
Some people use AI to make fake messages, pictures or voices to trick others. If something online seems surprising or asks for something, stop and check with a grown-up.
Don't share private things
Many AI apps send what you type to a company's computers (this page doesn't). Never type your address, passwords or secrets into an AI app.
It's a tool, not a friend or a teacher
It can help you practise and explore, but it doesn't understand you or care about you. For real help, talk to people you trust.
For teachers and parents
Everything on this page comes from a real model, TinyStories 15M (trained by Andrej Karpathy on the TinyStories dataset of simple stories), running in the browser. The "pretend web page" in Part 2 and the shell in Part 3 are the pretend parts; every piece, number and chance of the model's work comes from the model. Ideas by grade:
- K–2: read steps 1, 4 and 5 aloud. Play "guess the next word" as a class, then roll the dice. Main idea: it picks one word at a time, like a game.
- 3–5: all five steps, then the "Is it alive?" tests. In step 3, pause before each tunnel appears and guess which piece it will look back at most, then watch. Try careful vs silly. Main idea: it's numbers made by people, and it can be wrong.
- 4 and up: Part 2, "Can it follow a command?" (a 269 MB download, best done once on the teacher's computer). Main ideas: a command is just more text in a hidden chat form; the chat AI follows it because it was trained on example conversations; and the AI only writes words, while programs written by people do the actions.
- 5 and up: Part 3, a real AI agent: "Watch it work" plays a recorded run of the real model straight away (works on phones and tablets); the live version is a 988 MB download, best on the teacher's computer, projected. Run "What is 23 times 47?" and follow the five steps round the loop together. Then, in the live version, tick "Ask me before each command" and say no: the class sees that the program, not the AI, decides what happens. Main idea: an "autonomous" agent is a loop that people wrote, and it can only use the tools people gave it.
- All grades: "So who is the smart one here?": read it aloud, press "Try the dragon test", and ask "smarter at what?". Main idea: the AI's good guesses are borrowed from what people wrote and made relevant by attention over the whole context; asking, meaning, judging and caring are the student's.
- All grades: "Your limit is your curiosity". Play the copy machine or coach game together, then have students upgrade a "do it for me" ask into a coach question (try first, ask why, ask for a hint, ask to be quizzed). Main idea: AI is a tool for sharpening your own thinking, not a replacement for it.
- 6–8: add the risks section: why fluent isn't the same as true, where unfairness comes from (the training text), and private information.
- 9–12: move to the full version: tokens, embeddings, attention, the logit lens, the training checkpoints of a real model, and how different model designs compare.
About "smarter than AI". At the G20 Innovation Ministerial on 2 September 2026, OpenAI's Sam Altman said: "A kid growing up today will never be smarter than AI …" (the sentence goes on; see CNBC's live coverage). The "Who is the smart one here?" section is this page's answer. The sentence is true about stored patterns, recall and speed, and silent about asking, meaning, judging and caring: the part of intelligence a child has and a next-piece guesser does not. A good question for the class: smarter at what?
This page is open source (MIT). Nothing typed here leaves the browser.