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

Using LLaMA C++ release b4872 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, edge devices, etc. There are many approaches to accomplish this, including architecture simplification and knowledge distillation, but for now I'm focusing primarily on quantization and pruning.

The process of quantization reduces the precision of the model's weights, leading to significant reductions in model size, memory needs and computational requirements (a good thing), but this however comes at the expense of a loss in the model's capabilities and accuracy (a bad thing!).

Another approach is to prune the model, that is, to selectively zero-out groups of parameters. Although significant reductions can be achieved this way, the risk of severely degrading the model's performance is markedly higher than when quantizing, as the process requires a deep understanding of the model's architecture in order to identify which tensors can be safely zero'ed. For all means and purposes, pruning is the equivalent of lobotomizing the LLM!

A successful outcome is when the overall size is reduced with no, or negligible, loss of capabilities (i.e. language understanding, math and logic problem-solving, conversation, coding, domain-specific knowledge, etc.) compared to the original version. On that regard, the method I'm using seems to yield some modest but encouraging results, and the versions available in this repo are on average 7.5% smaller than other, high-quality, sources with negligible loss of capability. As I continue to improve the process and develop tools to automate it, I aim to achieve further reductions in the 10-15% range, maybe more.

For testing and comparison I used 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. Quantize & prune versions of the base model
  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.47 8.2%
DeepSeek-R1-Distill-Llama-8B-IQ3_S N/A N/A 3.37 N/A
DeepSeek-R1-Distill-Llama-8B-IQ4_NL 4.68 N/A 4.35 7.1%
DeepSeek-R1-Distill-Llama-8B-Q3_K_L 4.32 N/A 4.01 7.2%
DeepSeek-R1-Distill-Llama-8B-Q3_K_M 4.02 4.02 3.70 8.0%
DeepSeek-R1-Distill-Llama-8B-Q3_K_S 3.66 N/A 3.35 8.5%
DeepSeek-R1-Distill-Llama-8B-Q4_K_M 4.92 4.92 4.59 6.7%
DeepSeek-R1-Distill-Llama-8B-Q4_K_S 4.69 N/A 4.36 7.0%
DeepSeek-R1-Distill-Llama-8B-Q5_K_M 5.73 5.73 5.34 6.8%
DeepSeek-R1-Distill-Llama-8B-Q5_K_S 5.60 N/A 5.21 7.0%
DeepSeek-R1-Distill-Llama-8B-Q6_K 6.60 6.60 6.13 7.1%
DeepSeek-R1-Distill-Llama-8B-Q8_0 8.54 8.54 7.82 8.4%

Perplexity and KL Divergence scores

Model μPPL 𝜌PPL μKLD RMS Δp
DeepSeek-R1-Distill-Llama-8B-IQ3_M 17.240743 ±0.144856 93.48% 0.435823 ±0.001620 17.425 ±0.066
DeepSeek-R1-Distill-Llama-8B-IQ3_S 17.465106 ±0.147682 93.39% 0.441957 ±0.001645 17.470 ±0.066
DeepSeek-R1-Distill-Llama-8B-IQ4_NL 15.346180 ±0.129934 96.24% 0.241193 ±0.001277 12.484 ±0.063
DeepSeek-R1-Distill-Llama-8B-Q3_K_L 16.876273 ±0.145643 94.72% 0.352343 ±0.001451 15.201 ±0.063
DeepSeek-R1-Distill-Llama-8B-Q3_K_M 16.919080 ±0.146005 94.48% 0.367114 ±0.001473 15.568 ±0.064
DeepSeek-R1-Distill-Llama-8B-Q3_K_S 17.644226 ±0.148490 92.27% 0.506686 ±0.001786 18.534 ±0.068
DeepSeek-R1-Distill-Llama-8B-Q4_K_M 15.147873 ±0.128370 96.59% 0.220231 ±0.001199 11.951 ±0.062
DeepSeek-R1-Distill-Llama-8B-Q4_K_S 15.349770 ±0.130408 96.40% 0.232634 ±0.001239 12.329 ±0.063
DeepSeek-R1-Distill-Llama-8B-Q5_K_M 15.039770 ±0.127564 96.94% 0.197358 ±0.001179 11.230 ±0.063
DeepSeek-R1-Distill-Llama-8B-Q5_K_S 15.206373 ±0.129316 96.84% 0.203119 ±0.001209 11.416 ±0.063
DeepSeek-R1-Distill-Llama-8B-Q6_K 14.974922 ±0.127271 97.07% 0.188803 ±0.001173 10.958 ±0.063
DeepSeek-R1-Distill-Llama-8B-Q8_0 15.069153 ±0.128019 97.05% 0.190406 ±0.001195 11.046 ±0.064
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
DeepSeek-R1-Distill-Llama-8B-IQ3_M 49.2000 ±1.8267 71.07 36.9333 ±1.7635 32.9333 ±1.7172 66.1333 ±1.7292
DeepSeek-R1-Distill-Llama-8B-IQ3_S 46.2667 ±1.8219 71.87 37.2000 ±1.7661 33.3333 ±1.7225 66.0000 ±1.7309
DeepSeek-R1-Distill-Llama-8B-IQ4_NL 50.0000 ±1.8270 74.13 36.5333 ±1.7594 32.8000 ±1.7155 67.8667 ±1.7063
DeepSeek-R1-Distill-Llama-8B-Q3_K_L 50.0000 ±1.8270 71.20 35.0667 ±1.7436 31.3333 ±1.6949 66.9333 ±1.7190
DeepSeek-R1-Distill-Llama-8B-Q3_K_M 49.2000 ±1.8267 70.00 35.7333 ±1.7510 32.0000 ±1.7045 67.6000 ±1.7100
DeepSeek-R1-Distill-Llama-8B-Q3_K_S 51.0667 ±1.8265 70.40 33.2000 ±1.7207 30.5333 ±1.6828 68.9333 ±1.6909
DeepSeek-R1-Distill-Llama-8B-Q4_K_M 49.2000 ±1.8267 74.27 35.7333 ±1.7510 34.0000 ±1.7309 66.8000 ±1.7207
DeepSeek-R1-Distill-Llama-8B-Q4_K_M-bartowski 52.0000 ±1.8255 73.73 37.0667 ±1.7648 32.2667 ±1.7082 68.4000 ±1.6988
DeepSeek-R1-Distill-Llama-8B-Q4_K_M-unsloth 50.9333 ±1.8266 73.47 36.4000 ±1.7581 32.6667 ±1.7137 67.8667 ±1.7063
DeepSeek-R1-Distill-Llama-8B-Q4_K_S 49.6000 ±1.8269 74.13 36.2667 ±1.7567 33.2000 ±1.7207 67.3333 ±1.7137
DeepSeek-R1-Distill-Llama-8B-Q5_K_M 48.1333 ±1.8257 74.13 35.0667 ±1.7436 32.5333 ±1.7119 66.8000 ±1.7207
DeepSeek-R1-Distill-Llama-8B-Q5_K_S 48.9333 ±1.8265 74.13 34.8000 ±1.7405 31.3333 ±1.6949 66.2667 ±1.7276
DeepSeek-R1-Distill-Llama-8B-Q6_K 48.1333 ±1.8257 74.80 35.6000 ±1.7496 32.0000 ±1.7045 66.6667 ±1.7225
DeepSeek-R1-Distill-Llama-8B-Q8_0 48.2667 ±1.8259 74.80 35.4667 ±1.7481 32.2667 ±1.7082 66.8000 ±1.7207
DeepSeek-R1-Distill-Llama-8B-F16 50.1333 ±1.8270 74.40 36.6667 ±1.7608 32.0000 ±1.7045 67.7333 ±1.7082

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.27 GiB 8.03 B Metal,BLAS 6 pp512 329.64 ± 0.06
DeepSeek-R1-Distill-Llama-8B-Q4_K_M 4.27 GiB 8.03 B Metal,BLAS 6 tg128 26.93 ± 0.04
DeepSeek-R1-Distill-Llama-8B-Q4_K_M 4.27 GiB 8.03 B Metal,BLAS 6 pp1024+tg1024 43.70 ± 0.09
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 orignal 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 gguf file format.

Downloads last month
1,521
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
(133)
this model

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