Experimental layer-wise quantization of cognitivecomputations/Dolphin3.0-R1-Mistral-24B

Using LLaMA C++ release b5269 for quantization.

Original model: cognitivecomputations/Dolphin3.0-R1-Mistral-24B

From the original model creators:

Dolphin 3.0 is the next generation of the Dolphin series of instruct-tuned models. Designed to be the ultimate general purpose local model, enabling coding, math, agentic, function calling, and general use cases.

Dolphin aims to be a general purpose instruct model, similar to the models behind ChatGPT, Claude, Gemini. But these models present problems for businesses seeking to include AI in their products.

  1. They maintain control of the system prompt, deprecating and changing things as they wish, often causing software to break.
  2. They maintain control of the model versions, sometimes changing things silently, or deprecating older models that your business relies on.
  3. They maintain control of the alignment, and in particular the alignment is one-size-fits all, not tailored to the application.
  4. They can see all your queries and they can potentially use that data in ways you wouldn't want.

Dolphin, in contrast, is steerable and gives control to the system owner. You set the system prompt. You decide the alignment. You have control of your data. Dolphin does not impose its ethics or guidelines on you. You are the one who decides the guidelines.

Dolphin belongs to YOU, it is your tool, an extension of your will. Just as you are personally responsible for what you do with a knife, gun, fire, car, or the internet, you are the creator and originator of any content you generate with Dolphin.

From Eric Hartford's, the creator of the Dolphin model series, Uncensored Models:

Most of these models (for example, Alpaca, Vicuna, WizardLM, MPT-7B-Chat, Wizard-Vicuna, GPT4-X-Vicuna) have some sort of embedded alignment. For general purposes, this is a good thing. This is what stops the model from doing bad things, like teaching you how to cook meth and make bombs. But what is the nature of this alignment? And, why is it so?

The reason these models are aligned is that they are trained with data that was generated by ChatGPT, which itself is aligned by an alignment team at OpenAI. As it is a black box, we don't know all the reasons for the decisions that were made, but we can observe it generally is aligned with American popular culture, and to obey American law, and with a liberal and progressive political bias.

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 used to produce these experimental versions is covered in Squeezing Tensor Bits: the quest for smaller LLMs, but at a high level it involves using a custom version of llama-imatrix and llama-quantize to identify influential tensors, and quantize the most important layers to higher bit precision and the less important to lower bits. This process was partly inspired by Dumitru's et al Layer-Wise Quantization: A Pragmatic and Effective Method for Quantizing LLMs Beyond Integer Bit-Levels.

As of version b5125 llama-quantize can now perform tensor-wide quantization (TWQ), whereby user-defined tensors are quantized at a specific level, or perform layer-wise quantization (LWQ) by selecting different quantization types per tensor/layer. For example, --tensor-type attn_v=q6_k will quantize all Attention Value tensors at q6_k (TWQ), and --tensor-type "\.([0-9]|1[01257]|31)\.attn_k=q4_k" will quantize Attention Key tensors on layers 0 to 9, 10, 11, 12, 15, 17 and 31 at q4_k, leaving the remaining layers at their default value (LWQ).

The modified version of llama-imatrix generates useful statistics to guide the tensor selection process, --show-statistics will display:

  • Σ(Bias): the sum of all activations over the tensor (i.e. the Importance Scores)
  • Min & Max: minimum and maximum activation values
  • μ & σ: activations' mean and standard deviation
  • % Active: proportion of elements whose average activation exceeds a very small threshold (1e-6). Helpful to determine how alive/dormant the tensor is during inference
  • N: number of activations in the tensor
  • Entropy: entropy of the activation distribution, in bits (standard Shannon entropy measurement)
  • E (norm): Normalized entropy.
  • ZD Score: z-score distribution as described in 3.1 Layer Importance Scores in the Layer-Wise Quantization paper
  • CosSim: cosine similarity between same type tensors with respect to the previous layer (i.e. blk.7.attn_k and blk.6.attn_k)

Please note that statistics are calculated for each individial tensor and should be used to compare between tensors of the same type only. For example, assuming that attn_k in layer 10 has a higher influence during inference than attn_k in layer 7 because its Σ(Bias) is larger makes sense, whilst concluding the same between attn_k and ffn_down does not.

There’s a pull request to merge these changes back into the core llama.cpp project. This may or may not ever happen so, until then, the modified version will be available on GitHub.

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) but if they don't provide versions of the required model, all tests and comparisons are done against naive quantizations obtained by simply running llama-quantize with no further optimization.

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. Determine tensor and layer Importance Score contribution using the modified version of llama-imatrix
  5. Select an appropiate quant level for each tensor and quantize the model using llama-quantize
  6. Calculate Perplexity, KL Divergence, ARC (Easy+Challenge), HellaSwag, MMLU, Truthful QA and WinoGrande scores for each quantized model
  7. Keep versions with the best scores
  8. 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)

Perplexity and KL Divergence scores

Model μPPL 𝜌PPL μKLD RMS Δp
Dolphin3.0-R1-Mistral-24B-IQ3_M 24.606928 ±0.240883 98.90% 0.084228 ±0.000329 77.239 ±0.036
Dolphin3.0-R1-Mistral-24B-IQ3_S 22.442379 ±0.210710 98.39% 0.118717 ±0.000448 8.764 ±0.041
Dolphin3.0-R1-Mistral-24B-IQ4_NL 21.928862 ±0.206557 99.48% 0.037446 ±0.000162 5.018 ±0.029
Dolphin3.0-R1-Mistral-24B-Q3_K_L 23.403845 ±0.220384 98.39% 0.116116 ±0.000467 8.812 ±0.043
Dolphin3.0-R1-Mistral-24B-Q3_K_M 33.198678 ±0.325464 93.18% 0.503668 ±0.001913 18.223 ±0.075
Dolphin3.0-R1-Mistral-24B-Q3_K_S 35.148697 ±0.355888 93.75% 0.481979 ±0.001791 17.540 ±0.073
Dolphin3.0-R1-Mistral-24B-Q4_K_M 21.803136 ±0.204778 99.47% 0.037315 ±0.000164 5.020 ±0.028
Dolphin3.0-R1-Mistral-24B-Q4_K_M-bartowski 21.965440 ±0.208103 99.62% 0.027409 ±0.000114 4.294 ±0.024
Dolphin3.0-R1-Mistral-24B-Q4_K_S 22.282006 ±0.210372 99.42% 0.041972 ±0.000184 5.297 ±0.029
Dolphin3.0-R1-Mistral-24B-Q5_K_M 21.112940 ±0.197766 99.60% 0.028216 ±0.000126 4.384 ±0.025
Dolphin3.0-R1-Mistral-24B-Q5_K_S 21.195503 ±0.197666 99.77% 0.015751 ±0.000076 3.272 ±0.021
Dolphin3.0-R1-Mistral-24B-Q6_K 21.367322 ±0.200492 99.90% 0.006579 ±0.000038 2.182 ±0.016
Dolphin3.0-R1-Mistral-24B-Q8_0 20.553420 ±0.190365 99.81% 0.013005 ±0.000059 2.908 ±0.018
Dolphin3.0-R1-Mistral-24B-F16 21.071274 ±0.196181 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
Dolphin3.0-R1-Mistral-24B-IQ3_M 52.4000 ±1.8249 62.40 34.8000 ±1.7405 29.4667 ±1.6658 61.6000 ±1.7771 48.13
Dolphin3.0-R1-Mistral-24B-IQ3_S 51.4667 ±1.8262 62.67 33.2000 ±1.7207 28.5333 ±1.6500 62.2667 ±1.7711 47.63
Dolphin3.0-R1-Mistral-24B-IQ4_NL 54.1333 ±1.8207 63.46 34.9333 ±1.7420 28.5333 ±1.6500 63.8667 ±1.7553 48.99
Dolphin3.0-R1-Mistral-24B-Q3_K_L 50.0000 ±1.8270 61.73 34.0000 ±1.7309 27.3333 ±1.6284 63.4667 ±1.7594 47.31
Dolphin3.0-R1-Mistral-24B-Q3_K_M 46.6667 ±1.8229 56.80 32.0000 ±1.7045 28.5333 ±1.6500 63.3333 ±1.7608 45.47
Dolphin3.0-R1-Mistral-24B-Q3_K_S 46.9333 ±1.8235 57.47 30.8000 ±1.6869 28.1333 ±1.6430 63.3333 ±1.7608 45.33
Dolphin3.0-R1-Mistral-24B-Q4_K_M 52.1333 ±1.8253 63.20 35.0667 ±1.7436 26.9333 ±1.6209 64.1333 ±1.7525 48.29
Dolphin3.0-R1-Mistral-24B-Q4_K_M-bartowski 51.8667 ±1.8257 63.47 35.0667 ±1.7436 28.4000 ±1.6477 64.4000 ±1.7496 48.64
Dolphin3.0-R1-Mistral-24B-Q4_K_S 51.4667 ±1.8262 63.73 33.8667 ±1.7292 27.0667 ±1.6235 62.5333 ±1.7686 47.73
Dolphin3.0-R1-Mistral-24B-Q5_K_M 53.2000 ±1.8232 62.80 35.7333 ±1.7510 27.3333 ±1.6284 63.4667 ±1.7594 48.51
Dolphin3.0-R1-Mistral-24B-Q5_K_S 53.8667 ±1.8215 63.73 34.4000 ±1.7358 28.8000 ±1.6546 64.0000 ±1.7539 48.96
Dolphin3.0-R1-Mistral-24B-Q6_K 53.3333 ±1.8229 63.33 35.4667 ±1.7481 29.2000 ±1.6614 62.5333 ±1.7686 48.77
Dolphin3.0-R1-Mistral-24B-Q8_0 53.2000 ±1.8232 63.20 35.2000 ±1.7451 28.5333 ±1.6500 63.3333 ±1.7608 48.69
Dolphin3.0-R1-Mistral-24B-F16 52.6667 ±1.8244 63.60 35.2000 ±1.7451 28.6667 ±1.6523 63.4667 ±1.7594 48.72

Tokens per Second - Benchmarks

Scores generated using llama-bench. Naive (llama-quantize with no optimization) Q4_K_M quantization included for comparison.

model size params backend threads test t/s
Dolphin3.0-R1-Mistral-24B-Q4_K_M 12.17 GiB 23.57 B Metal,BLAS 6 pp512 100.81 ± 0.34
Dolphin3.0-R1-Mistral-24B-Q4_K_M 12.17 GiB 23.57 B Metal,BLAS 6 tg128 9.74 ± 0.02
Dolphin3.0-R1-Mistral-24B-Q4_K_M 12.17 GiB 23.57 B Metal,BLAS 6 pp1024+tg1024 16.79 ± 0.05
Dolphin3.0-R1-Mistral-24B-Q4_K_M-bartowski 13.34 GiB 23.57 B Metal,BLAS 6 pp512 105.56 ± 0.60
Dolphin3.0-R1-Mistral-24B-Q4_K_M-bartowski 13.34 GiB 23.57 B Metal,BLAS 6 tg128 8.99 ± 0.21
Dolphin3.0-R1-Mistral-24B-Q4_K_M-bartowski 13.34 GiB 23.57 B Metal,BLAS 6 pp1024+tg1024 16.11 ± 0.12

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 on Huggingface, and a really big Thank You! to Georgi Gerganov for his amazing work with llama.cpp and the ggml/gguf libraries.

Downloads last month
766
GGUF
Model size
23.6B params
Architecture
llama
Hardware compatibility
Log In to view the estimation

3-bit

4-bit

5-bit

6-bit

8-bit

16-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for eaddario/Dolphin3.0-R1-Mistral-24B-GGUF

Quantized
(31)
this model

Dataset used to train eaddario/Dolphin3.0-R1-Mistral-24B-GGUF