# Chapter 9: Number formats and quantization

Part of the course “AI from Zero to Autonomous Agents” (https://llm.yoga/en). Page for humans: https://llm.yoga/en/09-quantisierung

*From FP32 to 4 bits: what Q4_K_M, MXFP4 and NVFP4 mean, what they cost and how much memory a model really needs.*

About 25 min to read · about 30 min hands-on exercise

**Start with the missions**

This chapter also comes as 3 short missions with a case, a decision and feedback, about 10 minutes each:

- [9.1 The customer wants the 70B model on his 48 GB Mac](https://llm.yoga/en/einsatz-9-1.md)
- [9.2 Q4 or Q8?](https://llm.yoga/en/einsatz-9-2.md)
- [9.3 Which model for the team laptop with 16 GB?](https://llm.yoga/en/einsatz-9-3.md)

For agents, this page is split into 4 parts so that each part can be fetched in full. Read the parts the question needs.

## Parts

### Part 1: https://llm.yoga/en/09-quantisierung-1.md

- **Getting started**: When someone asks you the time, you say “twenty past ten”, not “ten o’clock, twenty-one minutes, thirty-five seconds and forty-two milliseconds”.
- **How a computer stores decimal numbers**: A model’s weights are decimal numbers like 0.0137 or −1.42.
- **What quantization is**: Quantizing means mapping numbers onto a smaller set of representable values.

### Part 2: https://llm.yoga/en/09-quantisierung-2.md

- **llama.cpp’s GGUF levels**: GGUF is llama.cpp’s file format, which Ollama and LM Studio use too.
- **MLX, MXFP4 and NVFP4**: Besides GGUF, there are three 4-bit formats you’ll come across more and more often.

### Part 3: https://llm.yoga/en/09-quantisierung-3.md

- **The rule-of-thumb formula for memory**: With this knowledge, you can work out how much memory a model needs.
- **Which level pays off when**: The numbers lead to some rules of thumb.
- **Exercise: quantize and compare**: Goal: you see the difference between two levels of the same model in size, speed and answer quality, and you work out the size beforehand with the formula.
- **Common misconceptions**: A 4-bit model is exactly a quarter the size of the FP16 version.

### Part 4: https://llm.yoga/en/09-quantisierung-4.md

- **Review questions**: 1. Quantize the block 0.2 · −0.6 · 1.4 · 0.05 to integers from −7 to 7.
- **Go further**: llama.cpp: quantize README with bits per weight and speed for each level; quantize.cpp with the perplexity increase; PR 1684, which introduced k-quants.
