Sub topic 1
What a parameter count tells you
Prerequisites
This chapter assumes you know what a large language model is, can use a command line, know that RAM is working memory and disk is storage, and can do simple arithmetic with bytes, bits and GB.
What a parameter is
A parameter is one learned number inside a model. Training adjusts these numbers until the model predicts text well. A model described as "8B" has about 8 billion of them. The model file is mostly a long list of these numbers, called the weights.
The count is the first figure to check when you pick a model. It sets the size of the weights, and the size of the weights sets the memory you need.
From parameters to bytes
Every parameter is stored with some number of bits. The file size follows from one formula:
size in bytes = parameters × bits per weight ÷ 8
At 16 bits (2 bytes) per weight, an 8B model takes about 16 GB. At 4 bits it takes about 4 GB. This chapter only covers the count. The next chapters cover the number formats and how quantisation reduces the bits.
def rough_size_gb(params_billion, bits_per_weight):
# billions of parameters x bytes per parameter = GB
return params_billion * bits_per_weight / 8
for params in (1, 3, 8, 14, 70):
print(f"{params:>3}B at 16 bits: {rough_size_gb(params, 16):6.1f} GB")The script prints 2, 6, 16, 28 and 140 GB. The size grows in a straight line with the parameter count.
What the count does not tell you
The parameter count is a useful guide, but it leaves several things out.
- Quality. A newer 8B model can beat an older 13B model. Training data and method matter as much as size. Within one model family, more parameters usually means more capability.
- Speed. A larger model is slower, because more data must be read for each generated token. A later chapter covers this.
- Total memory use. The weights are only part of it. The KV cache (the memory that holds the conversation so far) and runtime overhead come on top.
- Exact size. Names are rounded. "8B" may mean 8.03 billion, and real files include extra data such as the vocabulary.
Common errors
- Reading B as bytes. B means billions of parameters, not gigabytes. An 8B model is not 8 GB.
- Using the 16-bit size for a quantised file. Most local users run 4-bit to 8-bit files, which are much smaller than the 16-bit size.
- Ignoring decimal and binary units. 1 GB is 10^9 bytes, and 1 GiB is 2^30 bytes. The two differ by about 7%, which matters when a model barely fits.
- Treating the count as a fit test. A 7B model at 4 bits is about 4 GB, but it still needs room for context and overhead.
Exercise
A model has 14 billion parameters. Roughly how large are its weights at 16 bits per weight, and at 4 bits per weight?
Show answer
At 16 bits (2 bytes), 14 × 2 = 28 GB. At 4 bits (0.5 bytes), 14 × 0.5 = 7 GB. Real files are a little larger, because quantised formats store extra scaling data and some tensors stay at higher precision.
Exercise
Why is a parameter count alone not enough to decide whether a model fits on your machine?
Show answer
The weights are only part of the memory use. You also need space for the KV cache, which grows with context length, and for runtime overhead. The bits per weight must also be known to turn the count into bytes.