Q4_K_M is the default choice and Q5_K_M is the step up for coding and tool calling, where instruction-following matters more. The comparison is small and concrete: Q5_K_M costs about 0.7 GiB more on an 8B model and cuts the measured perplexity rise by about two thirds. Whether that is worth it depends on your task, not on the numbers alone.
Prerequisites
- The llama.cpp figures for both levels: bits per weight, file size and perplexity rise.
- Your task type: general chat, coding, or tool calling.
- Your memory budget.
Steps
Step 1: List both levels
Write both levels side by side with their bits per weight: Q4_K_M at 4.89 and Q5_K_M at 5.70, measured on Llama 3.1 8B. The difference is less than one bit per weight.
Step 2: Compare the sizes
On an 8B model, Q4_K_M is 4.58 GiB and Q5_K_M is about 5.3 GiB. The step up costs about 0.7 GiB, which is small on a machine with room, and decisive on a machine without it.
Step 3: Compare the quality loss
On Llama 3 8B against the Wikitext-2 test set, llama.cpp measures the perplexity rise at +0.1754 for Q4_K_M and +0.0569 for Q5_K_M, against +0.0026 for Q8_0. Perplexity is how surprised a model is by real text; a smaller rise means less quality lost.
Worked example: 8B model: Q4_K_M against Q5_K_M
The table below compares the two levels on an 8B model, using llama.cpp’s published figures.
| Level | Bits per weight | File size (8B) | Perplexity rise |
|---|---|---|---|
| Q4_K_M | 4.89 | 4.58 GiB | +0.1754 |
| Q5_K_M | 5.70 | About 5.3 GiB | +0.0569 |
| Q8_0 (for reference) | 8.50 | 7.95 GiB | +0.0026 |
Q5_K_M costs about 0.7 GiB more than Q4_K_M and cuts the perplexity rise from +0.1754 to +0.0569, so it is worth it for coding and tool calling when the memory fits.
Expected result. You can state the size cost and the quality gain of stepping from Q4_K_M to Q5_K_M, and say which of your tasks justifies it. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.
Limits
- Perplexity is one measure; it does not capture every kind of quality loss.
- These figures are measured on Llama 3 8B; another model gives different numbers.
- This guide does not run the comparison; it reads the published figures.
