If a model is too big to fit your computer, you do not have to give up on it: you can shrink it. Quantization reduces the precision of model weights — for example, from 32-bit floats to 4-bit integers — which shrinks the model’s size and can speed up inference. The llama.cpp quantize guide gives the workflow in two phases: convert the original model to GGUF format, then quantize the converted GGUF file.
Step 1: make a high-precision GGUF
First convert a model from a Hugging Face repo to a high-precision GGUF. The guide’s own example converts Gemma 4:
python convert_hf_to_gguf.py --outfile gemma-4-E2B-it-bf16.gguf --outtype bf16 --remote google/gemma-4-E2B-it
Install the Python requirements first (python3 -m pip install -r requirements.txt from the llama.cpp repo), and keep this high-precision file: every quantization you make later should start from it, not from an already-quantized file. The guide warns that re-quantizing tensors that are already quantized can severely reduce quality compared to quantizing from 16-bit or 32-bit.
Step 2: quantize to Q4_K_M
Then use llama-quantize to apply quantization. The guide’s example:
./build/bin/llama-quantize gemma-4-E2B-it-bf16.gguf gemma-4-E2B-it-Q4_K_M.gguf Q4_K_M
How much smaller does it get? The guide’s own size table for Llama 3.1 shows the scale of the change:
| Model | Original size | Quantized size (Q4_K_M) |
|---|---|---|
| Llama 3.1 8B | 32.1 GB | 4.9 GB |
| Llama 3.1 70B | 280.9 GB | 43.1 GB |
| Llama 3.1 405B | 1,625.1 GB | 249.1 GB |
Those are the guide’s figures for Llama 3.1, not a promise for every model — but they show why Q4_K_M is the usual target: the 8B model drops from 32.1 GB to 4.9 GB. Run the new file with llama cli and ask it the same test question you used before, so you can compare the smaller model’s answers with what you expect.
Try it: check the trade-off on one question
Ask the quantized model a question whose answer you already know — for example, Why is the sky blue? — and read the reply. If the reply is correct, the smaller file works for your purpose. If it is wrong or garbled, quantization cost too much quality for that model, and a lighter quant such as Q8_0, or a different model, is the next thing to try. Expected result. We checked the llama.cpp quantize guide. We did not run llama-quantize on a sample model.
Limits
Quantization may introduce some accuracy loss, usually measured in perplexity or Kullback–Leibler divergence, and the guide says this can be minimized by using a suitable importance matrix file. You also need enough disk space to store all the intermediate files, and enough RAM to load the model — the guide says memory and disk requirements are the same for this step, so a model that barely fits your disk may not fit your memory while quantizing. Never delete the high-precision original until you are happy with the quantized copy. We did not run llama-quantize, so no file size here is a measured result.
