Bookmarks

Model parameters (weights)

The numbers inside a neural network that training fits to data and that are stored in the model file; their count determines size and memory use.

Also: neural network parameters, model weights, parameter count

checked 18 Nov

All terms

Parameters, or weights, are all the trainable numbers in a model: the matrices and vectors that make up its layers. A “9B” model contains about 9 billion such numbers. Training fits them; after training they do not change and are stored in the model files.

How much memory is needed

Memory for the weights equals the number of parameters multiplied by the size of one number in bytes. For a model with 9 billion parameters it works out as follows:

Number formatBytes per parameterWeights of a 9B model
FP324about 36 GB
BF16 or FP162about 18 GB
INT8 or FP81about 9 GB
INT4 or FP40.5about 4.5 GB

That is the weights only. On top of them you need memory for the KV cache, which grows with context length, and for working buffers, so in practice you leave a margin. Training adds gradients and optimiser state, usually several times larger than the weights themselves.

Not to be confused with settings

  • model parameters are the numbers inside the model, found by training;
  • hyperparameters are training settings, such as the learning rate and batch size; a person sets them before training;
  • generation parameters are temperature, top_p and max_new_tokens; they are set with each request and do not change the weights.

How to see the parameter count

pythonThe `num_parameters` method is available on models in the Transformers library.
n = model.num_parameters()print(f"{n / 1e9:.1f} billion parameters")

In a model name, the number usually means the total parameter count: 27B is 27 billion. For mixture-of-experts models the active count is also given, for example 30B-A3B: 30 billion are stored, and about 3 billion work on each token.

Sources

the term is written from these pages

Verified 18 Nov

Not to be confused with

what it is mixed up with and how it differs

  • hyperparameter

    A person sets hyperparameters before training, whereas training itself finds the model parameters.

  • language model token

    A token is a unit of text at the input and output, whereas parameters are the numbers inside the model.

In depth in the references

where the topic is covered in detail

Appears in the references