Ben asks his chat assistant to help with a school fair, then his sister asks whether it can watch the cake stall.
Ben and these scenes are fictional. We are looking at language-model assistants here, rather than every kind of AI.
Watch the answer grow one token at a time
Ben starts with an invitation ending in "Please bring the" and wonders how the assistant chooses the next bit.
A language model estimates what could follow from the context you give it.
The pieces it works with are tokens, which can be words or parts of words. Google's language model introduction explains the idea.
You can imagine a toy vocabulary where each whole word is a token. Our made-up next-token choices are cake at 60%, plates at 25% and parrot at 15%.
The probabilities add up to 100%. These are invented teaching numbers, not measurements from a model.
Your software can pick the top choice or sample from possible choices, as Hugging Face's generation guide explains.
Your app adds the chosen token and continues from the updated context.
You can get an invitation through repeated prediction. You still need to read it before anyone arrives carrying a parrot.
Follow the numbers behind the friendly sentence
Ben writes that the phone needs a charge, then asks what the school should charge for cake. You can see why the surrounding words matter.
The model turns tokens into lists of numbers called vectors, then processes them using learned values called weights.
Matrices are rows and columns of numbers. Linear algebra gives us ways to combine these numbers through operations such as multiplication.
In a transformer, attention lets information from relevant parts of the available context influence the calculation.
The original Transformer paper also describes nonlinear functions. These help the network learn relationships more complex than multiplying inputs by weights and adding the results.
You do not need to solve the equations to understand the basic process. These maths steps turn your context into scores for possible next tokens.
Your model can turn those scores into probabilities.
You can give Ben's assistant the actual cake price and ask it to write the sign.
Send errors backward while the model is learning
Ben's sister tastes his practice cake and suggests changing the recipe. He would prefer applause, but the cake does need help.
Training also uses feedback to change a system, though a model has no spoon and nobody feeds it cake.
In language-model pretraining, predictions are compared with target tokens from the training data. A loss measures the prediction error.
Derivatives tell us how changing a weight would affect the loss. Backpropagation calculates these derivatives backward through the network.
The derivatives together form a gradient, which guides an optimizer as it adjusts the weights.
Google's backpropagation lesson covers this training process.
This is differential calculus used to adjust the model during training. The PyTorch training guide shows how a program uses these gradients.
When you use a trained model to generate a reply, ordinary inference runs the learned network forward without updating its weights.
You can correct the cake count in your chat and get a new answer. The new context can change that answer without retraining the model.
Let the model write code before giving it a terminal
Ben asks for a script to total the cake orders. A program appears, and his sister checks whether the assistant has secretly opened their laptop.
A model trained on code can write code as text, using learned patterns and the task you describe.
You can get code without giving the model access to your terminal. Running that code is a separate action.
Google's PaLM research includes code-generation tasks, showing that producing code is a language-model capability.
You might receive a useful new function, or a convincing function with a mistake. Getting code that looks right does not show that it ran well.
If an assistant runs it for you, software must provide an execution environment and whatever access the program needs.
Ben tries a reviewed script on a copy of his order sheet. You should check the totals before allowing a program to change the original.
The cake stall can survive an awkward variable name. Selling cakes based on a wrong total is a harder conversation.
Pass the request to a tool that can do the job
Ben has 18 cakes on a tray and seven in a box. He asks the assistant for the total, preferably before someone starts sampling.
Your assistant can produce a structured request that software knows how to handle if the system supports tools.
For our toy addition tool, the request uses this JSON format. It is an illustrative format, not a provider's API protocol.
{"tool":"add","arguments":{"a":18,"b":7}}
The surrounding program checks the tool name and inputs, then calls an addition function that returns 25. The result goes back to the model, which can turn it into a reply for you.
Anthropic's tool guide separates the model's request from execution by your application or the provider.
The function does not need a special instruction for every sentence Ben might use. The model helps translate the request into the tool's expected inputs.
Give the assistant access before expecting it to act
Ben likes the cake count so much that he asks the assistant to send invitations. The assistant replies "Done", while his outbox remains empty.
Writing an email and sending it require different access. You need an app connection or another tool that can perform the send action.
Other tools can read files or run terminal commands within the permissions they receive. For screen-based work, a system can give the model screenshots and let it request mouse or keyboard actions through software.
Anthropic's computer-use documentation explains the environment needed and the limits you can encounter.
You may see an agent repeat a loop, choosing an action and reading the result before choosing another. The model's requests are part of a larger program.
Ben connects a test mailbox and reviews the recipient list before sending anything.
You should check the actual sent message. A friendly sentence in the chat tells you little about whether the app action worked.
Read the result before accepting the victory speech
The assistant announces that the school hall is open all afternoon. Ben checks the source and finds an old notice with a booking time that nobody has confirmed still applies.
Next-token probability tells you how a continuation fits the model's context. It does not measure whether the hall booking is true.
Tools can supply fresh evidence, but they can also return old pages or fail. The assistant still needs to interpret what came back.
You can ask for the source and compare its date with the actual booking record.
We would trust the confirmed record over a fluent summary. Ben calls the caretaker, who is less chatty but has the keys.
An agent also needs a stopping rule when actions fail repeatedly. Otherwise, you can get a busy loop with no useful result.
Anthropic's agent guidance discusses feedback from the environment and limits on repeated work.
Our Python tool-calling walkthrough shows a checked request-and-result loop. You can inspect what happened instead of judging the final speech alone.
Keep your curiosity and check what actually happened
Ben's sister asks the assistant to shorten signs while she guards the cakes.
You can understand how the assistant generates text without knowing exactly why it chooses each word. Anthropic's interpretability research studies how learned features produce behavior, while describing limits in what the methods reveal.
For a task you care about, keep a few questions beside the chat.
- Which facts did you supply, and which need an outside source?
- Did the assistant generate a suggestion or request a real action?
- What tool access did you give it?
- What result shows the action succeeded?
- What will you check before using the output?
We would keep the cake sign short and confirm the opening time ourselves.
Try one small task and follow its draft, tool activity where available and final result before accepting the assistant's claim that it is done.