# What a model is

> [!NOTE]
>
> **In one minute**
>
> - A **model** is a program whose behaviour was learned from examples instead of written by hand.
> - What it learned is stored as **parameters**: billions of numbers. For infrastructure, a model is mostly a very large file that must sit in fast memory while it works.
> - **Training** computes those numbers once, at great cost. **Inference** uses them, again and again, to answer.

**Before you start.** Nothing. This page is background ([Conventions](<https://ai.ozarland.com/start/conventions/index.md#background>)).

## A program that was not written

A classic program is a list of rules written by a person: "if the disk is 90 % full, raise an alert". A model is built the other way round. You show it many examples, with the answer you expect, and an algorithm adjusts the model until its answers match.

What changes during that adjustment is not code. The code of a model is small and fixed. What changes is a set of numbers, the **parameters**, also called **weights**.

|  | Classic program | Model |
| --- | --- | --- |
| Written by | A person | An algorithm, from examples |
| Stored as | Code | Small code plus a large set of numbers |
| Size | Kilobytes to megabytes | Gigabytes to hundreds of gigabytes |
| Changing its behaviour | Edit the code | Train it again, or give it different input |

## Parameters: the numbers that hold what was learned

Picture a mixing desk with billions of knobs. Each input (a sentence, an image) flows through the desk; every knob slightly changes the signal; the output is the answer. Training is the long process of turning every knob until the answers are good. Once training stops, the knob positions are frozen. Those positions are the parameters.

Modern language models have from about one billion to several hundred billion parameters. The number is usually in the name of a model: "8B" means about 8 billion parameters, "70B" about 70 billion.

Each parameter is stored as a number of a given precision:

| Precision | Bytes per parameter | Typical use |
| --- | --- | --- |
| FP32 (32-bit floating point) | 4 | Training state, rarely for serving |
| BF16 or FP16 (16-bit) | 2 | The usual format for publishing and serving a model |
| FP8 or INT8 (8-bit) | 1 | Serving on recent GPUs, with a small loss of quality |
| INT4 or FP4 (4-bit) | 0.5 | Serving large models on less memory, with more loss |

## Worked example: the size of a model

The size of a model's weights is simply:

```text
size = number of parameters × bytes per parameter
```

| Model | Precision | Calculation | Weights |
| --- | --- | --- | --- |
| 8 billion parameters | BF16 | 8 × 10⁹ × 2 bytes | 16 GB |
| 70 billion parameters | BF16 | 70 × 10⁹ × 2 bytes | 140 GB |
| 70 billion parameters | 4-bit | 70 × 10⁹ × 0.5 bytes | 35 GB |

This is the first number to check before hosting a model: the weights must fit in the memory of the GPUs that will run it, with room to spare ([How much memory a model needs](<https://ai.ozarland.com/hardware/memory-a-model-needs/index.md>)).

## Training and inference

|  | Training | Inference |
| --- | --- | --- |
| What it does | Computes the parameters from data | Uses the parameters to answer a request |
| How often | Once per model, or once per version | Every request, all day |
| Duration | Days to months | Milliseconds to seconds per request |
| What limits it | Raw compute, and the links between many GPUs | GPU memory, and how fast that memory can be read |
| Who does it | A few large organisations, for big models | Anyone who serves a model, including a private cloud |

Most private clouds will **serve** models (inference), sometimes **adapt** them (fine-tuning), and rarely train a large model from scratch ([Four uses, four infrastructures](<https://ai.ozarland.com/understand/four-uses/index.md>)).

## Common mistakes

- **"A bigger model is always better."** A bigger model needs more GPU memory, answers more slowly and costs more. A smaller model adapted to the task often serves users better.
- **"The model learns from every question it receives."** No. Serving a model does not change its parameters. It only changes if someone trains it again.
- **"A model is like a database of answers."** It stores patterns, not records. That is why it can answer questions it never saw, and why it can be confidently wrong.

## Check yourself

> [!NOTE]
>
> **A model is called \\"13B\\" and is published in BF16. How much memory do its weights need?**
>
> 13 × 10⁹ parameters × 2 bytes = 26 GB, before anything else the GPU needs while it runs.

> [!NOTE]
>
> **What changes inside a model when it answers a question?**
>
> Nothing. Its parameters are fixed during inference. Only training changes them.

> [!NOTE]
>
> **Which of training and inference will a private OpenStack cloud mostly run?**
>
> Inference: serving trained models to users, all day. Training a large model from scratch is rare outside a few large organisations.

## Go further

- Next page: [How a large language model answers](<https://ai.ozarland.com/understand/how-an-llm-answers/index.md>).
- The words of this page: [Glossary](<https://ai.ozarland.com/reference/glossary/index.md#models>).
