Experimental GGUF quantized versions of deepseek-ai/DeepSeek-R1-Distill-Llama-8B

Using LLaMA C++ release b4930 for quantization.

Original model: deepseek-ai/DeepSeek-R1-Distill-Llama-8B

From the original model creators:

DeepSeek-R1-Zero, a model trained via large-scale reinforcement learning (RL) without supervised fine-tuning (SFT) as a preliminary step, demonstrated remarkable performance on reasoning. With RL, DeepSeek-R1-Zero naturally emerged with numerous powerful and interesting reasoning behaviors. However, DeepSeek-R1-Zero encounters challenges such as endless repetition, poor readability, and language mixing. To address these issues and further enhance reasoning performance, we introduce DeepSeek-R1, which incorporates cold-start data before RL. DeepSeek-R1 achieves performance comparable to OpenAI-o1 across math, code, and reasoning tasks. To support the research community, we have open-sourced DeepSeek-R1-Zero, DeepSeek-R1, and six dense models distilled from DeepSeek-R1 based on Llama and Qwen. DeepSeek-R1-Distill-Qwen-32B outperforms OpenAI-o1-mini across various benchmarks, achieving new state-of-the-art results for dense models.

NOTE: Before running DeepSeek-R1 series models locally, we kindly recommend reviewing the Usage Recommendation section.

PLEASE READ THIS BEFORE USING THESE EXPERIMENTAL VERSIONS!

An area of personal interest is finding ways to optimize the inference performance of LLMs when deployed in resource-constrained environments like commodity hardware, desktops, laptops, mobiles, edge devices, etc. There are many approaches to accomplish this, including architecture simplification and knowledge distillation, but my focus has been primarily on quantization and pruning.

The method that I'm using to produce these experimental versions is explained in Squeezing Tensor Bits: the quest for smaller LLMs, but at a high level it involves using a custom version of the llama-quantize tool to selectively quantize different tensors at different levels.

There’re two pull requests (#12511 & #12512) to merge these changes back into the core llama.cpp project. This may or may not ever happen but until then, the modified version will be available on my GitHub.

In addition to llama-quantize, there’s a version of llama-perplexity that allows you to continue generating test scores even if there’s a context window overflow (original behaviour is to stop).

For testing and comparison I use models produced by Unsloth (Daniel and Michael Han do some really advanced level stuff!) and Bartowski (see credits below).

All experimental versions were generated using an appropriate imatrix created from calibration datasets available at eaddario/imatrix-calibration. At its core, an Importance Matrix (imatrix) is a table or, more broadly, a structured representation that scores the relative importance of different features or parameters in a machine learning model. It essentially quantifies the "impact" each feature has on a specific outcome, prediction, or relationship being modeled, and it helps to counterbalance the negative effects of quantization and pruning.

The process to generate these models is roughly as follows:

  1. Convert the the original model's tensors to GGUF F16*
  2. Estimate the Perplexity score for the F16 model (baseline) using the wikitext-2-raw-v1 dataset, and save the logits
  3. Generate an imatrix from selected calibration datasets
  4. Select an appropiate quant level for each tensor using a modified version of llama-quantize
  5. Calculate Perplexity, KL Divergence, ARC (Easy+Challenge), HellaSwag, MMLU, Truthful QA and WinoGrande scores for each quantized model
  6. Keep versions with the best scores
  7. Repeat until all desired quants are created. I find that quantizations below Q3/IQ3 are not fit for my purposes and therefore do not usually generate them, but happy to provide other quants on request.

*BF16 would be preferred, but Apple's GPUs don't support it yet, and therefore any operations are executed in the CPU, making it unacceptably slow. This is expected to change in the near term but until then, if you are using Apple kit avoid using any models tagged BF16

Models

Sizes (in GB)

Model Bartowski Unsloth Repo Shrinkage
DeepSeek-R1-Distill-Llama-8B-IQ3_M 3.78 N/A 3.48 7.9%
DeepSeek-R1-Distill-Llama-8B-IQ3_S N/A N/A 3.24 N/A
DeepSeek-R1-Distill-Llama-8B-IQ4_NL 4.68 N/A 4.30 8.1%
DeepSeek-R1-Distill-Llama-8B-Q3_K_L 4.32 N/A 3.45 20.1%
DeepSeek-R1-Distill-Llama-8B-Q3_K_M 4.02 4.02 3.37 16.2%
DeepSeek-R1-Distill-Llama-8B-Q3_K_S 3.66 N/A 3.28 10.4%
DeepSeek-R1-Distill-Llama-8B-Q4_K_M 4.92 4.92 4.44 9.8%
DeepSeek-R1-Distill-Llama-8B-Q4_K_S 4.69 N/A 4.31 8.1%
DeepSeek-R1-Distill-Llama-8B-Q5_K_M 5.73 5.73 5.35 6.6%
DeepSeek-R1-Distill-Llama-8B-Q5_K_S 5.60 N/A 5.19 7.3%
DeepSeek-R1-Distill-Llama-8B-Q6_K 6.60 6.60 6.17 6.5%
DeepSeek-R1-Distill-Llama-8B-Q8_0 8.54 8.54 7.84 8.2%

Perplexity and KL Divergence scores

Model μPPL 𝜌PPL μKLD RMS Δp
DeepSeek-R1-Distill-Llama-8B-IQ3_M 18.513609 ±0.156607 91.75% 0.532214 ±0.001850 19.740 ±0.070
DeepSeek-R1-Distill-Llama-8B-IQ3_S 19.112490 ±0.165621 91.50% 0.547460 ±0.001918 19.434 ±0.071
DeepSeek-R1-Distill-Llama-8B-IQ4_NL 16.368324 ±0.146856 96.44% 0.243864 ±0.001293 12.434 ±0.063
DeepSeek-R1-Distill-Llama-8B-Q3_K_L 17.319338 ±0.145208 92.60% 0.477681 ±0.001783 18.029 ±0.069
DeepSeek-R1-Distill-Llama-8B-Q3_K_M 17.594278 ±0.144215 91.45% 0.553217 ±0.001919 19.812 ±0.070
DeepSeek-R1-Distill-Llama-8B-Q3_K_S 18.458827 ±0.153192 90.73% 0.602604 ±0.002075 20.369 ±0.072
DeepSeek-R1-Distill-Llama-8B-Q4_K_M 14.675582 ±0.124114 98.02% 0.126483 ±0.000727 9.254 ±0.052
DeepSeek-R1-Distill-Llama-8B-Q4_K_S 14.635869 ±0.123593 97.97% 0.130017 ±0.000732 9.361 ±0.053
DeepSeek-R1-Distill-Llama-8B-Q5_K_M 14.310641 ±0.120564 98.83% 0.076779 ±0.000579 7.195 ±0.050
DeepSeek-R1-Distill-Llama-8B-Q5_K_S 14.305297 ±0.120363 98.82% 0.077645 ±0.000576 7.256 ±0.049
DeepSeek-R1-Distill-Llama-8B-Q6_K 14.223713 ±0.119989 98.91% 0.071936 ±0.000599 6.892 ±0.051
DeepSeek-R1-Distill-Llama-8B-Q8_0 14.249305 ±0.120101 98.99% 0.066705 ±0.000592 6.662 ±0.052
DeepSeek-R1-Distill-Llama-8B-F16 14.009216 ±0.118474 100% N/A N/A

ARC, HellaSwag, MMLU, Truthful QA and WinoGrande scores

Scores generated using llama-perplexity with 750 tasks per test, and a context size of 768 tokens.

For the test data used in the generation of these scores, follow the appropiate links: HellaSwag, ARC, MMLU, Truthful QA and WinoGrande

Model ARC HellaSwag MMLU Truthful QA WinoGrande Avg Score
DeepSeek-R1-Distill-Llama-8B-IQ3_M 51.3369 ±1.8288 69.33 32.9333 ±1.7172 32.2981 ±2.6100 64.2667 ±1.7510 50.03
DeepSeek-R1-Distill-Llama-8B-IQ3_S 48.1928 ±1.8294 66.67 34.5333 ±1.7374 31.1321 ±2.6007 65.2000 ±1.7405 49.15
DeepSeek-R1-Distill-Llama-8B-IQ4_NL 51.8072 ±1.8294 72.00 36.6667 ±1.7608 32.1212 ±2.5743 65.3333 ±1.7389 51.59
DeepSeek-R1-Distill-Llama-8B-Q3_K_L 51.4056 ±1.8299 65.20 34.5333 ±1.7374 33.8509 ±2.6412 68.0000 ±1.7045 50.60
DeepSeek-R1-Distill-Llama-8B-Q3_K_M 51.5395 ±1.8298 70.13 34.4000 ±1.7358 31.3665 ±2.5897 66.1333 ±1.7292 50.71
DeepSeek-R1-Distill-Llama-8B-Q3_K_S 50.8021 ±1.8292 71.20 31.3333 ±1.6949 34.5679 ±2.6462 67.4667 ±1.7119 51.07
DeepSeek-R1-Distill-Llama-8B-Q4_K_M 52.8782 ±1.8276 74.40 35.7333 ±1.7510 34.0625 ±2.6534 67.4667 ±1.7119 52.91
DeepSeek-R1-Distill-Llama-8B-Q4_K_M-bartowski 50.3347 ±1.8306 74.40 34.8000 ±1.7405 37.1069 ±2.7133 69.4667 ±1.6828 53.22
DeepSeek-R1-Distill-Llama-8B-Q4_K_M-unsloth 52.4766 ±1.8284 73.20 33.2000 ±1.7207 36.0000 ±2.6667 68.4000 ±1.6988 52.66
DeepSeek-R1-Distill-Llama-8B-Q4_K_S 50.2008 ±1.8306 74.93 34.1333 ±1.7325 34.6875 ±2.6650 66.9333 ±1.7190 52.18
DeepSeek-R1-Distill-Llama-8B-Q5_K_M 53.6096 ±1.8246 72.66 34.6667 ±1.7389 35.7798 ±2.6549 66.0000 ±1.7309 52.54
DeepSeek-R1-Distill-Llama-8B-Q5_K_S 53.2798 ±1.8267 75.33 35.2000 ±1.7451 36.3354 ±2.6845 68.8000 ±1.6929 53.79
DeepSeek-R1-Distill-Llama-8B-Q6_K 51.8717 ±1.8281 76.00 33.3333 ±1.7225 35.1852 ±2.6571 68.6667 ±1.6949 53.01
DeepSeek-R1-Distill-Llama-8B-Q8_0 51.9359 ±1.8268 72.00 33.4667 ±1.7242 35.0000 ±2.6705 68.6667 ±1.6949 52.21
DeepSeek-R1-Distill-Llama-8B-F16 51.4706 ±1.8286 72.93 36.1333 ±1.7553 36.1111 ±2.6726 68.8000 ±1.6929 53.09

Tokens per Second - Benchmarks

Scores generated using llama-bench. Q4_K_M quantizations from Bartowski and Unsloth included for comparison.

model size params backend threads test t/s
DeepSeek-R1-Distill-Llama-8B-Q4_K_M 4.13 GiB 8.03 B Metal,BLAS 6 pp512 330.94 ± 1.42
DeepSeek-R1-Distill-Llama-8B-Q4_K_M 4.13 GiB 8.03 B Metal,BLAS 6 tg128 26.28 ± 0.11
DeepSeek-R1-Distill-Llama-8B-Q4_K_M 4.13 GiB 8.03 B Metal,BLAS 6 pp1024+tg1024 42.90 ± 0.05
DeepSeek-R1-Distill-Llama-8B-Q4_K_M-bartowski 4.58 GiB 8.03 B Metal,BLAS 6 pp512 329.03 ± 0.11
DeepSeek-R1-Distill-Llama-8B-Q4_K_M-bartowski 4.58 GiB 8.03 B Metal,BLAS 6 tg128 25.79 ± 0.92
DeepSeek-R1-Distill-Llama-8B-Q4_K_M-bartowski 4.58 GiB 8.03 B Metal,BLAS 6 pp1024+tg1024 42.35 ± 0.93
DeepSeek-R1-Distill-Llama-8B-Q4_K_M-unsloth 4.58 GiB 8.03 B Metal,BLAS 6 pp512 328.93 ± 0.15
DeepSeek-R1-Distill-Llama-8B-Q4_K_M-unsloth 4.58 GiB 8.03 B Metal,BLAS 6 tg128 26.43 ± 0.01
DeepSeek-R1-Distill-Llama-8B-Q4_K_M-unsloth 4.58 GiB 8.03 B Metal,BLAS 6 pp1024+tg1024 42.38 ± 0.97

Metrics used

Perplexity: one of the key metrics used in NLP evaluation. It measures the quality of a language model by evaluating how well it predicts the next token given a particular sequence of words. A PPL of 1 indicates an exact match between predicted and actual, whereas values greater than one indicate a degree of "surprise" the generated token differs from the expected.

Kullback–Leibler (KL) Divergence: a statistical measure of how much a probability distribution differs from another. When quantizing models (or altering the original tensors in any way for that matter), the closest we can preserve the weights' probability distribution to the original model the better, thus the closest to 0 the better.

AI2 Reasoning Challenge (ARC): a benchmark to evaluate the ability of AI models to answer complex science questions that require logical reasoning beyond pattern matching.

HellaSwag: the Harder Endings, Longer contexts, and Low-shot Activities for Situations With Adversarial Generations (bit of a mouthful!) is a benchmark designed to test commonsense natural language inference. It requires the model to predict the most likely ending of a sentence.

MMLU: the Massive Multitask Language Understanding evaluates LLMs’ general knowledge and problem-solving abilities across 57 subjects, including elementary mathematics, US history, computer science, and law.

Truthful QA: evaluates how well LLMs generate truthful responses to questions. It identifies whether AI models can avoid generating false or misleading information, particularly in areas where human knowledge is prone to misconceptions.

Winogrande: based on the Winograd Schema Challenge, is a natural language understanding task requiring models to resolve ambiguities in sentences involving pronoun references.

Credits

A big Thank You! to Colin Kealty for the many contributions and for being one of the best sources of high quality quantized models available in Hugginface, and a really big Thank You! to Georgi Gerganov for his amazing work with llama.cpp and the ggml/gguf libraries.

Downloads last month
2,147
GGUF
Model size
8.03B params
Architecture
llama

3-bit

4-bit

5-bit

6-bit

8-bit

16-bit

Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The model has no library tag.

Model tree for eaddario/DeepSeek-R1-Distill-Llama-8B-GGUF

Quantized
(143)
this model

Dataset used to train eaddario/DeepSeek-R1-Distill-Llama-8B-GGUF