We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
AI Engineering · How Models Generate
Free preview: the first 2 parts of this 19-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
Generative AI and Agentic AI Engineering
Unlock this lesson and the 208 other paid lessons
$35 once, by PayPal
See the Generative AI and Agentic AI courseread the rest of this lesson in
Generative AI and Agentic AI Engineering
Unlock this lesson and the 208 other paid lessons
$35 once, by PayPal
See the Generative AI and Agentic AI coursein How Models Generate
This lesson is part of the AI Engineering course. Unlock the full course, a separate one-time payment, for lifetime access.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime AccessFoundation lessons of this course are free, no payment needed. Try them now
Each lesson in this chapter took one part of a language model apart and measured it: the odds for the next token, sampling, reading and writing, attention, the cost of a long prompt, reusing a start, the window, the chat template, , stopping, and comparing models. Each part was studied on its own, often with an artificial test built to show just that one effect.
A real request does all of it at once. This lesson sends one realistic request, a support assistant answering a customer's question from a written policy, and reads every number Ollama returns about it. Each number belongs to one lesson of the chapter, and together they explain where every second of the wait went and why.

Think of the front desk in the picture. Every question goes through the same steps: someone writes it on a card, the clerk checks it fits the form, the expert reads the policy, thinks, writes an answer and hands it back. The first question of the day takes longest, because the expert has to read the whole policy. After that, the policy is already in their head.
By the end of this lesson you should be able to look at the numbers any model call returns and say which part of the call they describe, what is normal, and which lesson to reread when something looks wrong.

Every word this lesson needs is one you have already met in this chapter. As a reminder:
Token. The unit a model reads and writes, a word or part of a word (lesson 1).
Odds. The probability the model gives to every possible next token, of which the sampler picks one (lessons 1 and 2).
Template. The text a chat becomes before the model reads it, with its markers and roles (lesson 8).
Window. The number of tokens a model makes room for in one request, set by num_ctx (lessons 5 and 7).
done_reason. Ollama's note of how a reply ended: stop, or length when it was cut (lesson 10).
Two more ideas return: reading, which handles the whole prompt at once and is fast per token, and writing, which produces one token at a time and is slow per token (lesson 3). And a start that was already read can be reused (lesson 6).