cCarebun Reading‹ All reading
Carebun Interactive/How an LLM works LabCheat sheet Study view

Part IV · Ninja

Chapter 13

How big is a model?

A model is a file. Account for every byte of a real one, climb the ladder from 30,829 weights to a reported, unconfirmed 10 trillion, set it against the brain, and work out what will run on your laptop.

11 min read · interactive

On this page
  1. A model is a file
  2. The ladder of sizes
  3. Bits per weight
  4. Will it fit?
  5. Why graphics cards?
  6. How fast does it write?
  7. Open and closed, small and large
  8. Try it yourself
  9. Common questions
  10. Carry this
  11. Check yourself

In this chapter, we will learn what the size of a model means in practice. We will account for every byte of a real model file. We will climb the ladder of sizes from our toy to the largest models of 2026 and compare them with the human brain. Then we will work out how much memory a model needs, why it runs on graphics cards, and how fast it writes.

A model is a file

A trained model is a file that holds its weights, one number after the other. We opened the file of GPT-2 small and accounted for every byte.

(a) The model is a file of numbers
  weights           124,439,808
  bytes per weight  4 (a float32)
  weights x 4       497,759,232 bytes
  also in the file  12 fixed tables of 1,024 x 1,024 (not learned)   50,331,648 bytes
                    a header that names every tensor                14,291 bytes
  sum               497,759,232 + 50,331,648 + 14,291 = 548,105,171 bytes
  file on disk      model.safetensors   548,105,171 bytes

A float32 is a common way for a computer to store a number with decimals. It takes 32 bits. A bit is the smallest unit of storage, a single 0 or 1, and 8 bits make a byte, so a float32 is 4 bytes. The twelve fixed tables are a detail of this particular file: they tell each token that it may not look to its right, and they were stored along with the weights. The header is a list of contents.

weights        497,759,232 / 548,105,171   =  90.8 % of the file
fixed tables    50,331,648 / 548,105,171   =   9.2 %
header              14,291 / 548,105,171   =   0.003 %

There is no program code in the file and no text. The "knowledge" of the model is 124,439,808 numbers, and you could print them on paper. At 5,000 numbers to a page it would be a book of about 25,000 pages.

The ladder of sizes

The size of a model is its number of weights. Chapter 3 showed how it grew. Here is the whole ladder, with the human brain at the top. Each bar says how we know the number. Pick two rungs to compare, and read how many times larger one is than the other.

RungWeightsHow we know
Our toy model of Chapter 830,829measured
GPT-1, 2018117 millionpublished
GPT-2 small, 2019124,439,808measured
GPT-2 XL, 20191,557,611,200derived with the formula of Chapter 3; OpenAI says 1.5 billion
GPT-3, 2020175 billionpublished
GPT-6 Astra, 202610 trillionreported, not confirmed
Human brain, connections200 trillionestimated; the range is 100 to 1,000 trillion
from GPT-2 small to GPT-6 Astra      10,000,000,000,000 / 124,439,808         =  about 80,000 times
from GPT-6 Astra to the brain       200,000,000,000,000 / 10,000,000,000,000  =  20 times

the same, with the ends of the ranges
smallest gap    100 trillion / 10 trillion     =  10 times
largest gap   1,000 trillion / 4.8 trillion    =  about 208 times

The 10 trillion is reported and not confirmed, and the 200 trillion is an estimate. If both are right, the largest model of 2026 is eighty thousand times GPT-2 small, and the brain is twenty times larger still. That sounds as if the machines had nearly arrived. Four cautions:

  • The top two numbers are soft. OpenAI has not published the size of GPT-6 Astra. Ten trillion is the figure most often repeated, and another report says 4.8 trillion. The estimates for the brain differ by a factor of ten.
  • A weight is not a connection. A weight is one number that never changes after training. A connection in the brain is a living structure that changes every day. One connection may be worth many weights, and nobody knows how many.
  • Size is room, and says little about what is in it. A model of 2026 with a given number of weights is far more capable than a model of 2020 with the same number, because training improved.

The fourth caution needs a new term. Some large models are no longer one solid block. They are built as a mixture of experts. Inside each layer the feed-forward step exists in many copies with different weights, called experts. A small switch chooses a few of them for each token. Such a model holds far more weights than it uses on one trip. Several open models are built in this way. Whether GPT-6 Astra is one of them has not been published, so we cannot say how many of its reported weights work on each token.

Bits per weight

Quantization means storing each weight with fewer bits. The file shrinks in proportion, and the weights become a little less exact.

Bits per weightBytesDifferent values a weight can takeUsed for
324about 4 billiontraining
16265,536serving in data centres
81256smaller servers
40.516laptops and phones

It is surprising that 16 values can be enough for a weight. It works because no single weight matters much. The answer of the model is the sum of millions of small contributions, and small errors in them largely cancel.

Will it fit?

To run at a useful speed, a model must sit in memory completely, because nearly every weight is needed for every token. In a mixture of experts each token uses only some of the weights, but the next token may need others, so all of them must be at hand. Memory here means the working memory of the machine, called RAM, and not its disk. The memory of a graphics card is called VRAM.

a model with 8 billion weights, at 16 bits
file               8,000,000,000 x 2 bytes     =  16,000,000,000 bytes  =  16 GB
working room       about 20 % on top           =  3.2 GB
memory needed      16 GB x 1.2                 =  19.2 GB

a laptop with 16 GB of memory                     does not fit
a graphics card with 24 GB                        fits

the same model at 4 bits
file               8,000,000,000 x 0.5 bytes   =  4 GB
memory needed      4 GB x 1.2                  =  4.8 GB        fits a laptop, and many phones

We count 1 GB as 1,000,000,000 bytes. The working room is for the numbers the model holds while it reads: 768 or more numbers for every token of the prompt, in every layer. Twenty percent is our rule of thumb and not a measurement. With a very long prompt it is more.

Choose a size and a number of bits. Guess first: how many data-centre cards of 80 GB would a model of 10 trillion weights need at 16 bits? That is the size reported, and not confirmed, for GPT-6 Astra.

10 trillion weights at 16 bits
file               10,000,000,000,000 x 2 bytes   =  20,000 GB  =  20 TB
memory needed      20,000 GB x 1.2                =  24,000 GB
cards of 80 GB     24,000 / 80                    =  300 cards

This is why the largest models exist only in data centres, and why you reach them through the API of Chapter 9.

Why graphics cards?

A graphics card, or GPU, does a very large number of small calculations at the same moment. It was built for pictures, where millions of points must be worked out for every frame of a game.

The work of a model has the same nature. Look at one weight matrix of GPT-2, a table of 768 by 3,072 weights. It turns the 768 numbers of a token into 3,072 weighted sums, and no sum needs the result of another. They can all be done at once.

one matrix of GPT-2 small       768 x 3,072                =    2,359,296 multiplications
all the matrices, one token                                =  123,532,032 multiplications
(m) Speed on this laptop (CPU only, no graphics card)
  one pass over the 9-token prompt       14.2 ms
  100 new tokens                          0.81 s  = 123 tokens per second
  weights inside multiplication tables    123,532,032
  each is used about once per new token, so one token costs roughly that many multiplications
multiplications for one token          123,532,032
tokens per second, measured                    123
multiplications per second     123,532,032 x 123     =  about 15 billion

Our laptop did about 15 billion multiplications a second with its ordinary processor, which is called the CPU. That was enough for a model of 124 million weights. Now take a model with 8 billion weights.

multiplications for one token    8,000,000,000 / 123,532,032   =  about 65 times as many
tokens per second, same speed    123 / 65                      =  about 2

This is an estimate from our one measurement, and it assumes that the processor keeps its pace. Two tokens a second are 2 x 0.75 = 1.5 words a second, slower than anyone reads. A graphics card is built to do this kind of work many times faster.

How fast does it write?

Two numbers describe the speed of a model: the time to the first token, and the tokens per second after that.

Model, on our laptopWeightsFirst token afterTokens per second
GPT-2 small, processor only124,439,80814 ms123
Qwen2.5 1.5B, 4-bit, with the laptop's graphics chip1,543,714,304217 ms18

Both rows are our own measurements. For GPT-2 the time to the first token is one pass over its prompt of 9 tokens.

an answer of 300 tokens at 18 tokens per second
writing         300 / 18              =  16.7 s
in all          0.217 s + 16.7 s      =  16.9 s

you read        300 x 0.75 words      =  225 words
at 4 words per second   225 / 4       =  56.3 s

Four words a second is a common estimate for silent reading. The time to the first token is mostly the reading of the prompt. With a provider, the way over the internet comes on top. The tokens per second are the trips of the loop. Set the length of the answer and the speed below, and watch which is faster, the model or the reader.

At 18 tokens a second the model writes 18 x 0.75 = 13.5 words a second, faster than a person reads, so with streaming nobody waits. For a program that needs the whole answer before it can go on, 16.9 seconds is a long time. This is the reason why speed matters most in agents, where one task takes many requests.

Open and closed, small and large

A model has open weights when its maker publishes the file, and it is closed when the file stays with the maker.

Open weightsClosed
The filecan be downloadedstays with its maker
Where it runson your machine, or at any host you chooseon the maker's servers, through the API
Your dataneed not leave your machinetravels to the provider
Can we look inside?yes, as we did in this bookno
ExamplesGPT-2, Qwen, Llama, Gemmathe GPT-6 models, Claude, Gemini

Providers sell their models in sizes, as we saw on the price list of Chapter 10: a small, fast and cheap one, a middle one, and a large one that costs a hundred times as much as the small. A good habit is to start with the smallest model that does the task well, and to move up only where the answers are not good enough.

Try it yourself

Find out what your own computer can hold. Look up how much memory it has. Then work backwards.

memory of my machine                        ______ GB
room for the model      memory / 1.2      =  ______ GB
weights at 4 bits       room x 2          =  ______ billion     (0.5 bytes per weight)
weights at 16 bits      room / 2          =  ______ billion     (2 bytes per weight)

For a laptop with 16 GB the answers are 13.3 GB of room, about 26.7 billion weights at 4 bits and about 6.7 billion at 16 bits. In practice leave a few gigabytes for the rest of the system.

The program 03_gpt2_inside.py prints the accounting of the file in part (a) and the speed in part (m). Run it and compare your speed with ours.

Common questions

Is a bigger model always better?

For difficult tasks, a larger model of the same generation is usually better. It is also slower and dearer. For many tasks, such as sorting messages or pulling out a date, a small model gives the same result at a hundredth of the price. And a small model of today often beats a large one from three years ago.

How much worse is a model at 4 bits?

A little, and it depends on the model and the task. The common experience is that 8 bits can hardly be told from the original, that 4 bits lose a small amount of quality, and that below 4 bits the loss grows quickly. We did not measure it for this book, so we give no number.

Why can the file not stay on the disk, and be read as needed?

Because every token needs nearly every weight, and reading from a disk is far slower than reading from memory. A program can be told to fetch the weights from the disk as they are needed, and the model then runs, but far too slowly to be of use.

What is a parameter count such as "8B" in the name of a model?

The number of weights, rounded: 8B is 8 billion. "1.5B" in the name of our Qwen model stands for its 1,543,714,304 weights.

Can a phone run a language model?

Yes, a small one. A model of 1.5 billion weights at 4 bits is a file of 0.87 GB, as we weighed. Many phones of today have 8 GB of memory. The answers are those of a small model, and Chapter 11 showed how often such a model is wrong.

Does the brain also need 24,000 GB?

The comparison breaks down here. The brain is estimated to run on about 20 watts, the power of a dim light bulb. One data-centre graphics card draws several hundred watts, and our calculation needed 300 of them. It is one more sign that a connection and a weight are different things.

Carry this

  • A model is a file of weights. GPT-2 small: 124,439,808 weights x 4 bytes, plus fixed tables and a header, is 548,105,171 bytes.
  • File size = weights x bits / 8. Memory needed is about the file plus 20%.
  • Quantization stores each weight in fewer bits. Our "4-bit" file weighed 4.5 bits per weight.
  • The ladder: 124 million in 2019 (measured), 10 trillion in 2026 (reported, not confirmed), and 200 trillion connections in the brain (estimated; the range is 100 to 1,000 trillion).
  • Speed has two numbers: the time to the first token, and tokens per second.

Check yourself

1. A model has 70 billion weights. How large is its file at 16 bits, and at 4 bits?

Answer
16 bits     70,000,000,000 x 2 bytes     =  140 GB
 4 bits     70,000,000,000 x 0.5 bytes   =   35 GB

2. How many graphics cards of 80 GB does the model of question 1 need at 16 bits, with 20% working room?

Answer
memory     140 GB x 1.2   =  168 GB
cards      168 / 80       =  2.1, so 3 cards

3. A model writes 40 tokens a second and the first token arrives after 0.5 seconds. How long does an answer of 600 tokens take?

Answer
writing     600 / 40        =  15 s
in all      0.5 s + 15 s    =  15.5 s