A photo straight from a professional camera can be 50 MB. Save it as a normal JPEG and it might be 5 MB, and on your phone screen it looks almost the same. You threw away detail most people never notice, and saved 90% of the space.
AI models can be shrunk in a similar way. A model is made of billions of numbers, and each number is stored with a certain precision. Store those numbers with less precision and the model gets much smaller and often faster, usually with only a small drop in quality. This is called quantization, and it’s the main reason you can run capable AI models on a laptop or even a phone.
What is quantization?
Quantization is a technique that shrinks an AI model by storing its numbers (its weights) with fewer bits, for example 8 or 4 bits each instead of 16 or 32.
Fewer bits per number means:
- A smaller file to download and store
- Less memory (RAM or graphics card memory) needed to run it
- Often faster answers, because less data has to move around
The cost is a small loss of precision, which can slightly reduce the quality of the model’s answers.
Why do models need shrinking?
A large language model is mostly a giant collection of learned numbers. The model’s size in memory is roughly:
number of parameters × bytes per number
| Precision | Bytes per number | An 8-billion-parameter model |
|---|---|---|
| 32-bit (FP32) | 4 | about 32 GB |
| 16-bit (FP16 / BF16) | 2 | about 16 GB |
| 8-bit | 1 | about 8 GB |
| 4-bit | 0.5 | about 4 GB, plus a little extra |
These are rough figures for the weights alone; running a model needs some extra memory on top. But the pattern is clear. At 16 bits, an 8-billion-parameter model needs a large graphics card. At 4 bits, it can run on many ordinary laptops.
How does quantization work?
Think of rounding prices. ₹149.37, ₹149.82 and ₹150.21 can all be rounded to “about ₹150”. You lose the paise, but for most purposes the rounded number is close enough, and it’s much quicker to write down.
Quantization does something similar to a model’s weights:
- Look at a group of weights and find their range, say from −1.2 to +1.4.
- Divide that range into a small number of evenly spaced steps. With 4 bits, there are only 16 possible steps.
- Replace each weight with the nearest step, stored as a small whole number.
- Keep a scale (and usually an offset) for the group, so the original values can be approximately rebuilt when the model runs.
Each individual weight becomes a little less exact. But a model has billions of them, and the small errors mostly have little effect on the output. That’s why a well-quantized model often behaves very similarly to the original.
Modern methods are smarter than simple rounding. They use small groups with their own scales, and keep the most sensitive parts of the model at higher precision.
What do Q4, Q8 and Q4_K_M mean?
If you run models locally with tools such as Ollama, you’ll see labels like these:
- FP16 or BF16: 16-bit numbers. Usually the original precision of today’s open models: full quality, but large.
- Q8 (Q8_0): about 8 bits per weight. Usually almost no visible quality loss, about half the size of FP16.
- Q4 (for example Q4_K_M): about 4 to 5 bits per weight. A popular balance of size, speed and quality.
- Q2, Q3: very small, but quality drops more noticeably.
Many models in Ollama’s library download as a 4-bit version (often Q4_K_M) by default. These files usually use a format called GGUF, which comes from the llama.cpp project and is widely used for running models locally. Our Run LLMs locally with Ollama series shows how to pick and run them.
The trade-offs
| Higher precision (16-bit) | Lower precision (4-bit) | |
|---|---|---|
| File size and memory | Large | Much smaller |
| Speed on ordinary hardware | Slower, may not fit at all | Often faster |
| Answer quality | Best | Usually a small drop |
| Good for | Servers, research, fine-tuning | Laptops, phones, cheaper serving |
Some practical rules of thumb:
- 4-bit and 8-bit quantization usually keep most of a model’s quality for everyday tasks.
- Below 4 bits, quality tends to drop faster: more mistakes, weaker reasoning.
- A bigger model at 4 bits often beats a smaller model at 16 bits that uses the same memory.
- Check it on your own task. Quantization can affect some skills (like precise maths or rare languages) more than others.
Where quantization is used
- Running models locally on laptops and desktops with tools like Ollama and llama.cpp.
- On phones and devices, where memory and battery are limited.
- In data centres, to serve more users with the same hardware and cut the cost of inference.
- In fine-tuning: methods such as QLoRA fine-tune a model while its main weights are stored in 4-bit, so it needs much less memory (see fine-tuning).
Common misconceptions
“Quantization makes the model dumber in a big way.” At 8 and 4 bits, the drop is usually small for everyday use. Very low bit levels are where quality falls more.
“Quantization removes parts of the model.” It keeps every weight; it stores each one less precisely. (Removing weights is a different technique, called pruning.)
“A 4-bit model is a different, smaller model.” It’s the same model with the same number of parameters, stored in a compressed form.
“Quantization is only for hobbyists.” Large companies use it too, to make serving models faster and cheaper.
Key takeaways
- Quantization shrinks a model by storing its weights with fewer bits.
- Size ≈ parameters × bytes per number: an 8B model is about 16 GB at 16-bit and about 4–5 GB at 4-bit.
- It works like rounding: each weight snaps to the nearest of a few allowed values, with a scale to rebuild them.
- Labels like FP16, Q8, Q4_K_M describe the precision; 4-bit is a popular default for local models.
- The trade-off is a little quality for a lot of memory and speed; quality drops faster below 4 bits.
Frequently asked questions
What is quantization in simple words?
It’s a way of making an AI model smaller by storing its numbers less precisely, a bit like rounding, so it needs less memory and runs on smaller devices.
Does quantization reduce accuracy?
Usually a little. At 8-bit, the difference is often hard to notice. At 4-bit, there’s typically a small drop. Below 4 bits, quality falls more noticeably.
What does Q4_K_M mean?
It’s a label for one popular 4-bit quantization method used in GGUF files (from the llama.cpp project). The “4” means roughly 4 bits per weight; the letters describe the specific method and quality level.
How much memory do I need to run a 7B or 8B model?
At 4-bit, the model file is roughly 4–5 GB, and you’ll want some extra memory for the conversation and the app. At 16-bit, it’s roughly 14–16 GB plus extra.
What is the difference between quantization and pruning?
Quantization keeps all the weights but stores each one with fewer bits. Pruning removes weights that matter least. Both make models smaller, in different ways.
Comments