What AI models are and how they work
An AI model is a neural networkneural networkA machine learning model made of layers of simple calculations that adjusts its weights on examples and so learns to find patterns in data.Read more: neural network: an architecture (how numbers flow through the layers) plus weights (numbers found during training). Training fits the weights to data; inferenceinferenceRunning a trained model: on new data it makes predictions or generates text, while the weights stay unchanged.Read more: inference only reads them to produce an answer.
Architecture and weights
The architecture is the skeleton of a model: which layers it has and which operations they perform. The weights are the numbers loaded into that architecture; a set of weights is called a checkpoint. BERT is an architecture, while bert-base-cased is a checkpoint: the weights trained for the original BERT release. The word “model” can mean either, so this reference says which when it matters.
Training changes the weights so that the model’s errors on the data shrink. Fine-tuning continues training a ready-made model on a small dataset for your task, and needs less data, time and compute than training from scratch. During inference the weights do not change: the model receives an input and computes an output.
Three meanings of “parameters”
In talk about AI, “parameters” means three different things. Mixing them up is a common source of confusion.
| What | Example | Where it is set |
|---|---|---|
| Model parametersmodel 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.Read more: model parameters (weights) are its weights | 9B means 9 billion weights | Determined by training; the count is fixed by the architecture |
| Generation parameters | temperature, top_p | In the request to a ready-made model; see the “LLMs and RAG” reference, section “Generation and its parameters” |
| Training hyperparametershyperparameterA training or model setting that a person chooses in advance: unlike weights, training does not find it.Read more: hyperparameter | learning rate, LoRA rank | In the training or fine-tuning settings; see the section “Fine-tuning: full, LoRA and QLoRA” |
What depends on what
Choosing a model is a chain of dependencies. The task determines the type of model; the type and the quality you need determine the size in parameters; the size together with the number format determines memory; memory determines the hardware; and the hardware determines speed and cost. Of all these links, only the size and the number format (compression losses) affect quality, along with the data and the training and fine-tuning stages.
Five decisions in order
- Task and model type: text, images, speech, embeddings; see the section “Types of models”.
- Size: how many parameters you need and whether the model is dense or MoE; see the section “Parameters and model sizes”.
- Number format and quantisation: how many bytes each weight takes; see the sections “Number formats: FP32, BF16, FP8, FP4” and “Quantisation: methods and losses”.
- Training or fine-tuning: you either take a ready-made model or change its weights; see the sections “How a model is trained” and “Fine-tuning: full, LoRA and QLoRA”.
- Choosing a specific model: language, licence, hardware; see the section “How to choose a model”.
The main formula
Weight memory equals the number of parameters multiplied by the bytes per parameter. A 27B model (27 billion parameters) in BF16 takes about 54 GB (2 bytes per weight), and in FP4 about 13.5 GB (0.5 bytes). Here GB means 10⁹ bytes. A table for other sizes and formats is in the “Cheat sheet” section, and where the parameter count comes from is explained in “Parameters and model sizes”.
Open and closed models
Open-weight models can be downloaded and run yourself. Closed models are available only through a service’s API. This reference is about how models work, not about services, so it deals with open models, and their names serve as examples.
Related topics
- Working with a ready-made LLM (tokens, prompts, embeddings, RAG): the “LLMs and RAG” reference.
- GPUs, inference servers, memory sizing with the KV cache, distributed training: the “AI infrastructure (GPU)” reference.
- Classical models without neural networks: the “Machine learning basics” reference.