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

Using LLaMA C++ release b5269 for quantization.

Original model: cognitivecomputations/Dolphin3.0-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)

Model Bartowski Repo Shrinkage
Dolphin3.0-Mistral-24B-IQ3_M 10.70 10.82 -1.1%
Dolphin3.0-Mistral-24B-IQ3_S 9.91 10.18 -2.7%
Dolphin3.0-Mistral-24B-IQ4_NL 13.50 13.05 3.3%
Dolphin3.0-Mistral-24B-Q3_K_L 12.40 10.96 11.6%
Dolphin3.0-Mistral-24B-Q3_K_M 11.50 10.42 9.4%
Dolphin3.0-Mistral-24B-Q3_K_S 10.40 9.78 6.0%
Dolphin3.0-Mistral-24B-Q4_K_M 14.30 13.07 8.6%
Dolphin3.0-Mistral-24B-Q4_K_S 13.50 12.64 6.4%
Dolphin3.0-Mistral-24B-Q5_K_M 16.80 15.58 7.3%
Dolphin3.0-Mistral-24B-Q5_K_S 16.30 14.91 8.5%
Dolphin3.0-Mistral-24B-Q6_K 19.30 19.28 0.1%
Dolphin3.0-Mistral-24B-Q8_0 25.10 22.98 8.4%

Perplexity and KL Divergence scores

Model μPPL 𝜌PPL μKLD RMS Δp
Dolphin3.0-Mistral-24B-IQ3_M 8.012181 ±0.057587 98.51% 0.075215 ±0.000327 7.532 ±0.039
Dolphin3.0-Mistral-24B-IQ3_S 8.287859 ±0.060555 98.01% 0.103139 ±0.000420 8.803 ±0.042
Dolphin3.0-Mistral-24B-IQ4_NL 7.258862 ±0.048917 99.42% 0.026173 ±0.000130 4.620 ±0.028
Dolphin3.0-Mistral-24B-Q3_K_L 7.797546 ±0.054239 98.21% 0.082339 ±0.000394 8.255 ±0.044
Dolphin3.0-Mistral-24B-Q3_K_M 7.782805 ±0.053599 97.99% 0.090775 ±0.000432 8.667 ±0.047
Dolphin3.0-Mistral-24B-Q3_K_S 7.985599 ±0.055344 97.24% 0.124740 ±0.000599 10.136 ± 0.052
Dolphin3.0-Mistral-24B-Q4_K_M 7.326599 ±0.049682 99.44% 0.025003 ±0.000124 4.552 ±0.028
Dolphin3.0-Mistral-24B-Q4_K_M-bartowski 7.245078 ±0.049005 99.66% 0.015387 ±0.000084 3.597 ±0.025
Dolphin3.0-Mistral-24B-Q4_K_S 7.348107 ±0.049924 99.40% 0.026971 ±0.000135 4.731 ±0.030
Dolphin3.0-Mistral-24B-Q5_K_M 7.209640 ±0.048722 99.78% 0.009535 ±0.000047 2.871 ±0.017
Dolphin3.0-Mistral-24B-Q5_K_S 7.232320 ±0.048920 99.76% 0.010237 ±0.000053 2.954 ±0.019
Dolphin3.0-Mistral-24B-Q6_K 7.183488 ±0.048400 99.90% 0.003797 ±0.000020 1.880 ±0.012
Dolphin3.0-Mistral-24B-Q8_0 7.161438 ±0.048174 99.94% 0.001880 ±0.000012 1.384 ±0.009
Dolphin3.0-Mistral-24B-F16 7.148748 ±0.047873 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-Mistral-24B-IQ3_M 72.2667 ±1.6358 81.33 42.9333 ±1.8086 35.7333 ±1.7510 75.7333 ±1.5664 61.60
Dolphin3.0-Mistral-24B-IQ3_S 70.2667 ±1.6702 81.20 41.8667 ±1.8026 36.5333 ±1.7594 73.6000 ±1.6106 60.69
Dolphin3.0-Mistral-24B-IQ4_NL 72.1333 ±1.6382 80.80 43.2000 ±1.8100 35.8667 ±1.7525 76.6667 ±1.5454 61.73
Dolphin3.0-Mistral-24B-Q3_K_L 70.8000 ±1.6614 81.33 40.1333 ±1.7910 35.6000 ±1.7496 77.0667 ±1.5361 60.99
Dolphin3.0-Mistral-24B-Q3_K_M 71.6000 ±1.6477 80.27 40.6667 ±1.7948 34.5333 ±1.7374 76.0000 ±1.5605 60.61
Dolphin3.0-Mistral-24B-Q3_K_S 71.0667 ±1.6569 80.13 40.4000 ±1.7930 34.4000 ±1.7358 75.8667 ±1.5635 60.37
Dolphin3.0-Mistral-24B-Q4_K_M 72.8000 ±1.6260 81.07 42.1333 ±1.8042 35.3333 ±1.7466 76.5333 ±1.5485 61.57
Dolphin3.0-Mistral-24B-Q4_K_M-bartowski 72.1333 ±1.6382 81.20 42.2667 ±1.8050 35.0667 ±1.7436 76.6667 ±1.5454 61.47
Dolphin3.0-Mistral-24B-Q4_K_S 72.2667 ±1.6358 80.93 42.2667 ±1.8050 35.8667 ±1.7525 76.1333 ±1.5576 61.49
Dolphin3.0-Mistral-24B-Q5_K_M 71.2000 ±1.6546 82.13 43.0667 ±1.8093 35.6000 ±1.7496 76.4000 ±1.5515 61.68
Dolphin3.0-Mistral-24B-Q5_K_S 72.2667 ±1.6358 81.60 43.0667 ±1.8093 35.0667 ±1.7436 76.0000 ±1.5605 61.60
Dolphin3.0-Mistral-24B-Q6_K 71.8667 ±1.6430 81.33 42.5333 ±1.8065 35.7333 ±1.7510 77.7333 ±1.5202 61.84
Dolphin3.0-Mistral-24B-Q8_0 71.6000 ±1.6477 81.73 42.4000 ±1.8057 36.0000 ±1.7539 77.8667 ±1.5169 61.92
Dolphin3.0-Mistral-24B-F16 71.4667 ±1.6500 81.60 43.0667 ±1.8093 35.7333 ±1.7510 78.4000 ±1.5036 62.05

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-Mistral-24B-Q4_K_M 12.17 GiB 23.57 B Metal,BLAS 6 pp512 100.97 ± 0.31
Dolphin3.0-Mistral-24B-Q4_K_M 12.17 GiB 23.57 B Metal,BLAS 6 tg128 9.70 ± 0.07
Dolphin3.0-Mistral-24B-Q4_K_M 12.17 GiB 23.57 B Metal,BLAS 6 pp1024+tg1024 15.96 ± 0.07
Dolphin3.0-Mistral-24B-Q4_K_M-bartowski 13.34 GiB 23.57 B Metal,BLAS 6 pp512 105.38 ± 0.24
Dolphin3.0-Mistral-24B-Q4_K_M-bartowski 13.34 GiB 23.57 B Metal,BLAS 6 tg128 8.72 ± 0.04
Dolphin3.0-Mistral-24B-Q4_K_M-bartowski 13.34 GiB 23.57 B Metal,BLAS 6 pp1024+tg1024 15.25 ± 0.02

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
778
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-Mistral-24B-GGUF

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