The prompt
7 tokens“We reply within five business …”
The start of a sentence from Larkspur’s guides.
Module 7 · Transformers
A language model writes one token at a time. Each time, every token of the prompt becomes a list of numbers (a vector), attention lets each one weigh the tokens before it, and the last one ends up as a score for every token the model knows. Here you open a tiny one up and watch.
The whole idea in one example
“We reply within five business …”
The start of a sentence from Larkspur’s guides.
Larkspur mini’s five likeliest, of all 768.
Pick one, add it to the prompt, run again, and a reply grows one token at a time. Larkspur mini is tiny: 51,072 numbers, trained only on Larkspur’s own documents. It runs for real in your browser. It shows how the machinery works; it is no provider’s model. For scale: Meta’s Llama 3 report (2024): its largest model has 405 billion learned numbers, 126 layers of 128 heads, vectors of 16,384 numbers, a vocabulary of 128,000 tokens and a window of up to 128K tokens.
How it works
The model reads the prompt’s tokens and scores the next one
Vaswani and colleagues introduced the Transformer in 2017, a network built on attention alone, dropping the building blocks earlier language networks relied on (recurrence and convolutions).
Source, checked 30 October 2026
Each token weighs the tokens before it
Vaswani and colleagues (2017) compute attention in three moves: each token’s query is scored against every key, the scores become weights that add up to 1, and the weights mix the values.
Source, checked 30 October 2026
Token 4 looks only back, never ahead
Vaswani and colleagues (2017) mask attention in the part of the Transformer that writes, so a position cannot look at the positions after it and each prediction depends only on what came before.
Source, checked 30 October 2026
2 layers of 2 heads, each looking its own way
Multi-head attention runs several heads side by side, so the model can attend to different kinds of information at once.
Source, checked 21 October 2026
The story
Larkspur Supply Co.’s team opens up “Larkspur mini”, a tiny model trained only on Larkspur’s own documents, and watches it work in the browser. You’re on the team that wants to know why it says what it says, and what a long prompt costs.
Played Tokens? Larkspur mini reads the same tokens as this site’s tokenizer there. RAG chapter 2 showed why you can’t send everything; chapter 6 here shows what a long prompt costs inside.
Your path


Chapter 2 · done
How does a token id become numbers, and how does the model know where it sits?




Chapter 6 · done
Why does the work grow faster than the prompt, and what does the KV cache save?

Engineers, product managers and analysts who use language models and want to see what happens inside one. It builds on Tokens & embeddings; any maths is optional.