GGUF i-quants use an importance matrix, a measurement of which weights matter most for the model’s output, and spend more bits on those weights while the rest shrink further. They let big models fit in little memory, with sizes from about 2 to 4.5 bits per weight. The matrix comes from running calibration text through the model, so its quality depends on the text you choose.
Before you start
The llama.cpp quantize tool, a calibration text file that matches your use, and a quality test with a scoring rule.
Build the importance matrix
Run the llama.cpp imatrix tool over calibration text that matches what the model will actually do: your domain text, not generic web text. The matrix records which weights the model relies on for that kind of input.
Use enough calibration text to cover the model’s main uses. A matrix built from one kind of text protects that kind and may under-protect others.
Quantize with the imatrix
Run the quantize tool with an i-quant level, such as IQ4_XS, and the imatrix file. The tool spends more bits on the important weights and fewer on the rest, so the average bits per weight fall below the plain 4-bit level.
Note the resulting file size and bits per weight, and compare them with the plain Q4_K_M file for the same model.
Check the quality gain
Run your task test on the imatrix model and on the plain Q4_K_M model, and compare the scores. The imatrix version should win, or at least match, at a smaller size.
If it does not win, the calibration text probably does not match your task: rebuild the matrix from text closer to the real use.
Practice check: fictional Maple Corner 70B model, IQ4_XS vs Q4_K_M
The table below is fictional practice material, worked out by hand from the stated quantization levels. It is the expected result for the practice model, not a run of any tool.
| Version | Bits per weight | File size | Task score | Verdict |
|---|---|---|---|---|
| Q4_K_M | 4.89 | 42.5 GB | 80 of 100 | Baseline |
| IQ4_XS | 4.25 | 37.0 GB | 80 of 100 | Pass – same score, smaller |
| IQ3_XXS | 3.06 | 27.0 GB | 74 of 100 | Fail – too much loss |
IQ4_XS matches Q4_K_M at 80 of 100 with a smaller file, so it wins. IQ3_XXS saves more space but loses 6 points, so it is rejected for this use.
Expected result. UNTESTED: the scores and sizes in the practice table are worked out by hand, not measured by running the llama.cpp tools. Build your own imatrix from calibration text that matches your use, quantize, and compare task scores with the plain quant.
Limits
- The imatrix is only as good as the calibration text: text from the wrong domain protects the wrong weights.
- i-quants need a llama.cpp version that supports them; older builds may not read the files.
