BreakdownTechnology10 min · 16 steps
How a large language model is made and run
One sentence, followed from the text it was trained on to a reply on your screen, and then what each reply costs.
Follow one sentenceLast checked 16 sources
Pilot. The numbers here come from company filings where I could open them, and from secondary sources where I could not; each step says which. A full fact-check against original documents is still to come.
01 / 16
One sentence, 15 trillion pieces of text
Type a question into a chatbot and the answer appears a piece at a time. Before that could happen, Meta trained its biggest Llama 3.1 model on more than 15 trillion pieces of text, using over 16,000 NVIDIA H100 chips for 30.84 million hours of chip time.
So how does a pile of numbers learn to continue a sentence? And why can a company now list a million of those pieces going in at ten cents? By the end you should be able to follow one sentence from training data to a reply, and say what each reply costs.
In the pictureA question split into pieces enters a model and a reply comes out piece by piece; Llama 3.1 405B used over 15 trillion tokens, over 16,000 H100 chips and 30.84 million chip-hours.
02 / 16
The bill is growing fast
Why care? Because running these systems is now one of the biggest costs in technology. Epoch AI, a research group that tracks AI, read a filing that Anthropic made with US regulators. It reports that Anthropic’s spending on compute, meaning computing power, went from $0.94 billion in the first quarter of 2025 to $9.86 billion in the third quarter of 2026. That is more than ten times in six quarters, by my own arithmetic. I did not open the filing myself, so this is a secondary source.
Here is the puzzle I will keep coming back to. The price of one piece of text has been falling for years, and the total bill keeps rising. Both are true, and the rest of this page is about why.
In the pictureTwo grids of squares, each square $0.1 billion: Anthropic's quarterly compute spend was $0.94 billion in Q1 2025 and $9.86 billion in Q3 2026, about 10.5 times more.
- Compute
- Computing power: mostly chips running for hours, which training and serving a model use up.
Sources4
03 / 16
The whole thing in one picture
A language model has two lives. In the first, made once, a lab collects text, cuts it into pieces, trains the model on thousands of chips for weeks or months, then tunes it to behave like an assistant. That is the expensive, one-time half.
In the second, every time you press enter, the model reads your prompt, writes a reply one piece at a time, and the company sends a bill. The choke point is in the middle of that second half. Writing the reply is limited less by how fast chips can calculate than by how fast they can read their own memory. I will show why in a few steps.
In the pictureSeven stages in two groups. Made once: data, tokens, pretraining, post-training. Run for every reply: prefill, decode, bill. Decode is marked as the choke point.
04 / 16
From web pages to an exam
Training is a pipeline of five stages. A lab collects text: web crawls, books, code, and now text written by other models. It filters the pile, removing duplicates and junk. Then comes pretraining, the big run. Post-training teaches the model to act like an assistant. Last is evaluation: the model sits exams, called benchmarks, with names like MMLU and GPQA Diamond, which Epoch AI uses to compare models.
The amounts are huge. Llama 3.1 was pretrained on more than 15 trillion tokens (pieces of text, explained next), and DeepSeek-V3 on 14.8 trillion. Filtering is the stage labs say least about, so I give it no numbers. In 2022, Epoch researchers estimated that training sets would grow to match all public human-written text sometime between 2026 and 2032. We are inside that window, and I did not find a source saying whether it has happened.
In the pictureFive stages from top to bottom: collect, filter, pretrain, post-train, evaluate. Llama 3.1 used over 15 trillion tokens and 30.84 million H100-hours.
- Benchmark
- A standard set of test questions used to compare models.
05 / 16
Text becomes numbers
A model cannot read letters. It does arithmetic. So a program called a tokenizer first chops text into pieces, called tokens, and swaps each piece for a number from a fixed list. A common word is usually one piece; a rare or long word is split into several. My picture uses a made-up split and no real numbers, because every model has its own list.
That list changes your bill. Anthropic says its newer models, from version 4.7 on, use a tokenizer that makes about 30 per cent more tokens from the same text. So “price per million tokens” is not quite the same unit across companies, or even across generations of one company’s models.
In the pictureThe sentence "The model reads tokens" is split into five illustrative pieces, each given a number. Below, the same text takes 100 pieces on an older tokenizer and about 130 on a newer one.
- Token
- A piece of text, often a word or part of one, turned into a number the model can work with.
Sources3
06 / 16
Inside the model
Each number becomes a longer list of numbers, called an embedding. That list passes up through a tall stack of identical blocks. Every block has two parts. Attention lets each piece look back at the pieces before it and mix in the ones that matter. A feed-forward network then processes each piece on its own. After many blocks, the top layer scores every piece on the list.
This design comes from a 2017 paper, whose best English-to-French model trained in 3.5 days on eight GPUs. Meta calls Llama 3.1 a “standard decoder-only transformer with minor adaptations”. Models mostly differ in size, counted in parameters, the adjustable numbers inside: 175 billion for GPT-3, 405 billion for Llama 3.1, and 671 billion for DeepSeek-V3, of which only 37 billion are used for any one token.
In the pictureA stack: input pieces, an embedding, three of many identical blocks of attention and feed-forward, then output scores. Beside it, a triangle of attention weights and three circles sized by parameters: 175, 405 and 671 billion.
- Parameter
- One of the adjustable numbers inside a model, set during training.
- Attention
- The step where each piece looks back at earlier pieces and weighs which matter.
07 / 16
Guess the next piece
The scores become probabilities, and the model picks one piece, usually a likely one, with a little randomness. That piece is added to the text and the model goes round again. That loop is all there is. It is not looking answers up in a database.
In training, the same loop has a teacher. The text is real, so the true next piece is known. A loss function measures how wrong the guess was, and an optimiser nudges every parameter a tiny amount toward a better guess. Repeat over trillions of pieces and the numbers settle into something that continues sentences well. My bars are invented, to show the shape of a prediction.
In the pictureInvented probabilities for the next piece after "The capital of France is", with Paris highest at 62 percent, and a loop of guess, measure the error, nudge all parameters.
- Loss function
- A score for how wrong a prediction was; training tries to push it down.
08 / 16
Months on a cluster
Nudging at that scale takes thousands of chips working as one. Meta trained Llama 3.1 405B on over 16,000 H100 GPUs and reports 30.84 million H100 hours for that model. Spread over 16,000 chips that is about 80 days (my arithmetic, for scale only; Meta’s real run mixed cluster sizes). Its model card puts the training emissions at about 8,930 tonnes of carbon dioxide equivalent.
DeepSeek-V3 is the counter-case: 2,048 H800 chips and 2.788 million GPU-hours, about 11 times fewer hours, on a different chip and with far fewer active parameters. Its paper prices that run at $5.576 million, assuming $2 per GPU-hour. The paper says this excludes earlier research and experiments, so it is not what developing the model cost. Meta published no price. At the same $2 rate its hours would come to about $62 million, which is my illustration only.
In the pictureEach square is 100 GPUs: over 16,000 for Llama 3.1 405B and 2,048 for DeepSeek-V3. Bars show 30.84 million GPU-hours against 2.788 million, and DeepSeek's $5.576 million price tag at $2 per hour.
09 / 16
Teaching it to answer
After pretraining, the model is a text-completer. Ask it a question and it may just continue with more questions. Post-training fixes that. OpenAI’s InstructGPT paper (2022) describes the classic recipe: people write example answers and rank the model’s own answers, the rankings train a reward signal, and the model is nudged toward higher reward. This is called reinforcement learning from human feedback. The headline result was that people preferred a 1.3-billion-parameter InstructGPT to the 175-billion-parameter GPT-3.
Meta says Llama 3.1 went through several rounds mixing three methods, with most of the examples synthetic. Post-training can also be cheap: in DeepSeek-V3’s accounting it took 5,000 of 2.788 million GPU-hours, about 0.2 per cent. Pretraining was about 95.6 per cent and training it to read longer texts about 4.3, by my arithmetic. I could not find a source sizing the reinforcement learning labs now use for reasoning, so I will not guess.
In the pictureA loop: the model writes answers, people rank them, a reward signal learns the ranking, the model is nudged. Below, DeepSeek-V3's 2.788 million GPU-hours split into pretraining 95.6 percent, longer context 4.3 percent and post-training 0.2 percent.
- Post-training
- Extra training after pretraining that teaches a model to follow instructions and answer helpfully.
10 / 16
The choke point: memory
Now you press enter. A reply is made in two phases. In prefill, the model reads your whole prompt in one parallel pass and saves what it worked out about each piece in a memory called the KV cache. In decode, it writes one piece, adds it to the text, and goes round again. Every one of those passes needs the model’s active weights, the numbers it learned, read out of memory, plus the whole cache.
So decode is limited mostly by how fast memory can be read, not by arithmetic. That is why the stacked memory from my AI chip Breakdown matters. NVIDIA’s Vera Rubin GPU carries 288 gigabytes of HBM4 and reads it at 19.2 terabytes a second. What I describe here is the general mechanism, not any one lab’s system, and I did not find a primary source that lays it out.
In the picturePrefill reads all prompt pieces in one parallel pass. Decode writes one piece per pass, each pass reading the weights, while the KV cache in GPU memory grows by one slot per token. Vera Rubin has 288 GB of memory at 19.2 TB/s.
- KV cache
- Short for key-value cache: notes saved about earlier pieces so the model need not recompute them.
Sources11
11 / 16
Four ways to make a token cheaper
If memory is the limit, the tricks are about reading less of it. DeepSeek-V3 is a mixture of experts: 671 billion parameters in all, but only 37 billion switch on for each token. Quantisation stores each number in fewer bits. Meta shrank Llama 3.1 405B from 16-bit to 8-bit numbers so it runs within a single server node. By my arithmetic that halves its weights from about 810 to about 405 gigabytes.
Then there are price levers. Anthropic charges 0.1 times the normal input price to read a prompt it has already cached, and 0.05 times on its newest Sonnet and Opus models. Work that is not urgent can go through a batch service at half price. Serving many users’ requests together also spreads the cost of each memory read, but that is general knowledge, not something I sourced.
In the pictureA grid of 671 squares with 37 lit for one token; two bars halving a 405-billion-parameter model's weights from about 810 to about 405 gigabytes; and Anthropic's price multipliers 1, 0.5, 0.1 and 0.05.
- Quantisation
- Storing a model's numbers with fewer bits, so they take less memory.
12 / 16
What a token costs
Here are list prices on 1 December 2026, per million tokens, from the companies’ own pricing pages. The cheapest tier, OpenAI’s gpt-6-luna and Anthropic’s Claude Haiku 5.5, is $0.10 in and $0.50 out. The top tier, Claude Fable 5.2 and gpt-6.2-astra, is $8 in and $40 out. DeepSeek’s deepseek-flash is $0.15 in and $0.60 out at off-peak times, and double at peak. Cache hits cut input to $0.01 on gpt-6-luna and $0.003 on deepseek-flash.
Output costs more than input in all ten of these models, from 3 times to 6 times, by my arithmetic. The pages do not say why. The one-piece-at-a-time decode loop is a plausible reason, but that is my reading. And these are prices, not costs. I could not find a verified cost of production for any lab.
In the pictureTen models' input and output list prices per million tokens on 1 December 2026, from $0.10 in and $0.50 out for gpt-6-luna and Claude Haiku 5.5 up to $8 in and $40 out for gpt-6.2-astra and Claude Fable 5.2.
- Output token
- A piece of text the model writes in its reply; input tokens are the ones you send.
13 / 16
A price that fell off a cliff
Epoch AI measured the price of reaching a fixed score, not the price of a model. For GPT-4-level answers to science questions, a test called GPQA Diamond, the price fell about 40 times a year. Across tests and thresholds it ranged from 9 times to 900 times a year. One example: reaching 86.0 on the MMLU test cost $37.50 per million tokens with GPT-4 in March 2023 and $0.18 with Gemini 2.0 Flash in February 2025, about 208 times less by my arithmetic. GPT-3 was listed at $60.00 per million tokens in November 2021.
Epoch’s series ends in February 2025, and it cautions that the fastest drops may not last. The orange points are today’s cheapest list prices, for different models, so I have not joined them to the line.
In the pictureA log-scale chart of price per million tokens: GPT-3 at $60.00 in November 2021, the MMLU 86.0 level falling from $37.50 in March 2023 to $0.18 in February 2025, and the cheapest list prices in December 2026, $0.10 in and $0.50 out.
14 / 16
Where the money goes
A falling price per token and a rising bill fit together if the money mostly buys something other than answers. Epoch reports that customer inference was 38 per cent of Anthropic’s compute spend in 2025 and 26 per cent in the first nine months of 2026. The rest went to research and training. For OpenAI in 2025, media reports put compute at $16.3 billion, split $8.0 billion inference and $8.3 billion research, so about 49 per cent inference by my arithmetic. Those figures are unaudited.
For building a frontier model, Epoch’s cost model puts hardware at 47 to 67 per cent of the cost, staff at 29 to 49 and energy at 2 to 6. So a large share goes to hardware makers. Epoch also finds the cost of the largest training runs growing about 2.4 times a year, past $1 billion by 2027 if the trend holds. NVIDIA says its next platform, Rubin, will cut cost per token by up to 10 times against Blackwell. That is a vendor claim, and I have not seen it tested.
In the pictureTiles show customer inference as 38 percent of Anthropic's compute spend in 2025, 26 percent in the first nine months of 2026 and about 49 percent of OpenAI's in 2025. Range bars show hardware 47 to 67 percent of frontier model cost, staff 29 to 49 and energy 2 to 6.
- Inference
- Running a trained model to produce answers, as opposed to training it.
15 / 16
Where India fits
Here I have to be careful. The sources I could open contain no India-specific numbers for language models. The IndiaAI Mission portal returned an empty page and the government press site refused my request. So I will not print GPU counts or subsidised rates, and I will not quote the often-repeated figure from memory.
What I can say is narrower. At $0.10 in and $0.50 out per million tokens, the cheapest tier is 50 US cents for a million pieces of output; I have not applied an exchange rate. Because tokenizers differ, the same text can cost about 30 per cent more on a newer one. Many people argue that Indian languages need more tokens per sentence than English, which would raise the bill, but I could not find a measurement, so I give no number. And in Epoch’s data on AI compute sold, India is not one of the chip vendors.
In the pictureA ledger. Verified: the cheapest price of $0.10 in and $0.50 out, the tokenizer difference of about 30 percent, and that India is not a chip vendor. Not verified: tokens per Indian-language sentence, IndiaAI GPU figures, and a rupee price. Below, 30 percent more tokens means a 1.3 times bill.
16 / 16
The sentence, start to finish
A lab collects and filters text, cuts it into tokens, trains a transformer on a cluster for weeks or months to guess the next piece, then tunes it to answer. When you press enter, the model reads your prompt, writes the reply a piece at a time with memory speed setting the pace, and the company bills you by the million tokens.
What I still do not know, because I could not find it published: what a token really costs a lab to produce, how much energy one answer uses, whether training or serving will be the bigger bill in the long run, and whether the scaling that made models better keeps working at the next size. When someone publishes those, I will update this page.
In the pictureData, tokens, pretraining, post-training, prefill, decode, bill.