Sub topic 1
What a parameter count tells you
Prerequisites
This chapter assumes you know the following:
- What a large language model (LLM) is: a program that predicts the next piece of text from the text before it.
- How to use a command line and read a short Python script.
- The difference between RAM (fast, temporary working memory) and disk storage (slower, permanent).
- Basic arithmetic with bits, bytes and gigabytes.
You do not need to know how neural networks are trained.
What a parameter is
A parameter is one number stored inside a model. A model's behaviour comes from these numbers. Training adjusts them until the model predicts text well. After training, they stay fixed, and running the model means using them in arithmetic.
Parameters are also called weights. Strictly, "weights" are the multipliers in the model's layers, and a few other learned numbers (such as biases and normalisation scales) also count as parameters. They are a tiny fraction of the total, so in practice people use "parameters" and "weights" as near-synonyms. This tutorial does the same.
A model name usually states the count. "Llama 3.1 8B" has about 8 billion parameters. "70B" means about 70 billion. "0.5B" or "500M" means half a billion.
What the count tells you
Three things follow directly from the parameter count.
- Size on disk and in memory. Every parameter takes some number of bits. Multiply the count by the bits per parameter and you have the weight size. The next chapters cover the bits. For now, the point is that size scales in a straight line with the count. Double the parameters and you double the memory for weights.
- Work per generated token. For a dense model, producing one token uses roughly every parameter once. A 70B model does about nine times more arithmetic per token than an 8B model, and it reads about nine times more data from memory.
- A rough capability class. Larger models within the same family and training generation tend to know more and reason better. This is a tendency, not a rule.
What the count does not tell you
The count is a useful first number, but it leaves out several things you need.
- Precision. The same 8B model can be 16 GB or about 5 GB depending on how many bits each parameter uses.
- Context memory. The count says nothing about the KV cache, the memory that grows with the length of the conversation. A later chapter covers it.
- Quality. A newer 8B model can beat an older 70B model on some tasks. Training data, training length and architecture matter as much as size.
- Architecture. In a mixture-of-experts (MoE) model, only some of the parameters are used for each token. A model labelled "30B" may behave, per token, like a much smaller one, while still needing memory for all 30B. This is covered in a later chapter.
- Exact count. Names are rounded. "8B" can be 8.03B, and the extra parts of the model, such as the embedding table that maps tokens to vectors, are included in the total.
Where the count comes from
A transformer (the architecture behind most LLMs) is a stack of identical layers plus an embedding table at each end. Each layer holds attention matrices and feed-forward matrices. Their sizes follow from the model's shape: the hidden size (the width of the vector that represents each token) and the number of layers.
A rough rule for a dense transformer is:
parameters ≈ 12 × layers × hidden_size²
This ignores the embedding table and assumes standard sizes. It is only a sanity check. Modern designs change the proportions. For example, grouped-query attention shrinks the attention matrices, and feed-forward blocks are often wider than the rule assumes. Use the published count when you have it.
def rough_params_billion(layers, hidden_size):
# Rough rule for a classic dense transformer, ignoring embeddings.
return 12 * layers * hidden_size**2 / 1e9
# A 32-layer model with hidden size 4096 gives a figure near 6.4 billion.
# The real 8B model differs because of its wider feed-forward blocks
# and its embedding table.
print(f"{rough_params_billion(32, 4096):.1f} B")The estimate lands in the right region but under the real figure. That gap is the lesson: the rule gives you the order of magnitude, and the model card gives you the number.
From parameters to bytes
The conversion you will use throughout this tutorial is:
weight bytes = parameters × bits per parameter ÷ 8
A first look at what this gives for common sizes at 16 bits (2 bytes) per parameter:
| Model size | Parameters | Weights at 16 bits |
|---|---|---|
| Small | 1B | about 2 GB |
| Mid | 8B | about 16 GB |
| Large | 32B | about 64 GB |
| Very large | 70B | about 140 GB |
These sizes explain why local running is a memory problem first. A 70B model at 16 bits does not fit on any single consumer GPU. Even the 8B model at 16 bits needs most of a 16 GB card before you count anything else.
sizes_billion = [1, 8, 32, 70]
bits = 16
for b in sizes_billion:
gb = b * 1e9 * bits / 8 / 1e9
print(f"{b:>3}B at {bits} bits: {gb:.0f} GB")Note the unit. Here "GB" means 10⁹ bytes. Operating systems and tools often report GiB (2³⁰ bytes, about 7% larger than a GB). Later chapters use GiB when comparing against memory, because that is what most memory tools report.
Common errors
- Treating the count as the file size. "8B" is not 8 GB. The file size depends on bits per parameter, so an 8B file can be anywhere from about 3 GB to 16 GB.
- Assuming a bigger count always means better answers. Compare models on tasks like yours, not by count alone.
- Ignoring MoE labels. A name such as "8x7B" does not mean 56B of useful, independent parameters, and the total is not simply the product, because some layers are shared. Check the model card for the real total and the active count.
- Comparing counts across very different designs. A count says more when the architectures are alike.
- Mixing GB and GiB. A 7% error can decide whether a model fits.
How the pieces connect
The diagram shows how the parameter count feeds into the quantities you will estimate later.
Exercises
Exercise
A model card says "14B". How much memory do the weights need at 16 bits per parameter, and at 8 bits? Give answers in GB (10⁹ bytes).
Show answer
At 16 bits (2 bytes each): 14 × 10⁹ × 2 = 28 GB. At 8 bits (1 byte each): 14 × 10⁹ × 1 = 14 GB. In GiB these are about 26.1 and 13.0.
Exercise
Two models are listed as 8B and 70B. Both are dense. Roughly how many times more data must the 70B model read from memory to produce one token, assuming the same bits per parameter? Why does this matter for speed?
Show answer
About 70 ÷ 8 ≈ 8.75 times more. Generating a token reads roughly every weight once, and generation speed is usually limited by how fast memory can deliver data, so the 70B model will be roughly 8 to 9 times slower on the same hardware at the same precision.
Exercise
Give two things a parameter count does not tell you about how much memory you need to run a model.
Show answer
Any two of: the bits per parameter (precision or quantisation level), the KV cache size, which depends on context length and model shape, and the runtime overhead. For MoE models, the count also does not show how many parameters are active per token.