trendingzones
← Back to the Introduction level

AI & ML — INTERMEDIATE

Quantization Levels Explained: What Q4_K_M Actually Means

The Introduction level showed that quantization shrinks a model. It didn’t explain how “how much quality is lost” actually gets measured, or what all those quantization level names — Q8_0, Q4_K_M, Q2_K — are actually telling you.

The Quick Answer

Quality loss from quantization is typically measured with perplexity — the same metric covered in How LLMs Work Advanced— comparing how well the model predicts text before and after quantization. There are two ways to get there: post-training quantization (quantize a model after it’s already trained — fast and simple) or quantization-aware training (simulate quantization during training itself — slower, but usually preserves more quality). And a name like Q4_K_Misn’t arbitrary — every part of it describes a real design decision about how that specific quantized file was built.

Measuring Quality Loss: Perplexity

Perplexity measures how “surprised” a model is by real text — lower is better, meaning the model predicted the actual next words more confidently. Quantizing a model almost always raises its perplexity at least slightly, since some precision is genuinely lost. The goal of a good quantization method isn’t to avoid that increase entirely — it’s to keep it small enough that the difference is barely noticeable in practice, while still shrinking the file dramatically.

Post-Training Quantization vs. Quantization-Aware Training

The practical difference: PTQ is why you can quantize any model you download in minutes. QAT is why some providers release a dedicated “quantized” variant of a model trained specifically to hold up well at low precision, rather than just quantizing the standard release after the fact.

Decoding the Name: Q4_K_M

Every quantized GGUF file (the format Ollama uses) has a name that encodes real information:

Source: llama.cpp, GitHub Discussion #2094 and llama.cpp’s quantization documentation.

Real benchmark figures for a single model, across five common quantization levels — pick one to compare:

Fun Fact

“K-quants” aren’t named after a person or a company — the K refers to the method itself. According to llama.cpp’s own maintainers, k-quantizations are designed to be strictly better than the older, uniform quantization methods at the same file size, which is why nearly every quantized model published today uses a K-quant name rather than the older naming scheme.

Test Yourself

What is commonly used to measure how much quality a model loses from quantization?

What is the key difference between post-training quantization (PTQ) and quantization-aware training (QAT)?

In the name Q4_K_M, what does the "K" refer to?

Ready for the actual quantization math, mixed-precision layer decisions, and why quantized models run faster on the same hardware? Continue to the Advanced level →