How it works · 30 of 37 Advanced
What is quantization in AI models?
Shrinking a model to fit
Quantization: Store each parameter with fewer bits, so the model needs far less memory with a small loss of quality.
Loading the animation…
Say it like this Quantization stores each of a model's numbers with fewer bits, so it needs far less memory and runs on ordinary hardware, for a small loss of accuracy.
Under the hood — for builders
- How much smaller
- Going from 16 bits to 4 bits per number makes every Gemma 3 model about a quarter of the size.
- What it costs in accuracy
- In a large test of Llama 3.1, the 4-bit versions scored within one point of the full 16-bit models.
- How the rounding works
- Each small group of numbers shares one scale; every number is then rounded to one of 16 steps, so 4 bits are enough to store it.
- Words to know
- Bits: the computer's digits; 16-bit (BF16) is the usual training format, int8 and int4 are 8- and 4-bit whole-number steps.
- Trained for it
- Quantization-aware training rounds during training too: Google says it cut Gemma 3's 4-bit quality drop (perplexity) by 54%.
- Typical loss
- In that Llama test, 8-bit versions kept 99.3–100.3% of the full score and 4-bit versions 98.7–100%.
- Watch out
- Averages hide single tasks; test the quantized model on your own job, and remember memory for the conversation.
- Sources
- Google Developers Blog, Gemma 3 QAT Models, 18 Apr 2025 (developers.googleblog.com) · Kurtić et al., Give Me BF16 or Give Me Death? Accuracy-Performance Trade-Offs in LLM Quantization, arXiv 2411.02355.
What happens in the quantization animation, step by step?
- This model, Gemma 3 27B, needs 54 GB of memory. A gaming PC's graphics card holds 24 GB. It doesn't fit.
- The model is 27 billion numbers, each stored with 16 bits: the computer's digits.
- Keep 8 bits per number instead: each one is rounded a little, and the model halves to 27 GB. Still just too big.
- Your turn: pull the lever down to 4 bits and see if it fits.
- At 4 bits the model is 14.1 GB, a quarter of the size, and it runs on the gaming PC.
- The price: a little accuracy. In published tests, 4-bit models kept about 99% of their quiz score.
What everyday example explains quantization?
Saving a photo as a smaller JPEG; looks almost the same, takes a quarter of the space.
Why should a team care about quantization?
Why "runs on a laptop" is now possible.