Experimental layer-wise quantization of cognitivecomputations/Dolphin-Mistral-24B-Venice-Edition

Using LLaMA C++ release b5600 for quantization.

Original model: cognitivecomputations/Dolphin-Mistral-24B-Venice-Edition

From the original model creators:

Discord Discord: https://discord.gg/h3K4XGj2RH
Website: https://dphn.ai
Twitter: https://x.com/dphnAI

image/jpeg

What is Dolphin Mistral 24B Venice Edition?

Dolphin Mistral 24B Venice Edition is a collaborative project we undertook with Venice.ai with the goal of creating the most uncensored version of Mistral 24B for use within the Venice ecosystem.

Dolphin Mistral 24B Venice Edition is now live on https://venice.ai/ as โ€œVenice Uncensored,โ€ the new default model for all Venice users.

Dolphin aims to be a general purpose 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...

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:

  • ฮฃ(Actยฒ): the sum of all squared activations over the tensor (i.e. the Importance Scores)
  • Min & Max: minimum and maximum squared activation values
  • ฮผ & ฯƒ: activations' mean and standard deviation
  • % Active: proportion of elements whose average squared activation exceeds a very small threshold (1e-5). Helpful to determine how alive/dormant the tensor is during inference
  • N: number of squared activations in the tensor
  • Entropy: entropy of the squared 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 individual 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 ฮฃ(Actยฒ) 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 modelled, 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 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 appropriate 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
Dolphin-Mistral-24B-Venice-Edition-IQ3_M 6.982632 ยฑ0.049472 97.79% 0.103385 ยฑ0.000562 9.341 ยฑ0.053
Dolphin-Mistral-24B-Venice-Edition-IQ3_S 7.363739 ยฑ0.053846 97.05% 0.142269 ยฑ0.000710 10.632 ยฑ0.054
Dolphin-Mistral-24B-Venice-Edition-IQ4_NL 6.494645 ยฑ0.044686 99.22% 0.034702 ยฑ0.000219 5.662 ยฑ0.041
Dolphin-Mistral-24B-Venice-Edition-Q3_K_L 6.664819 ยฑ0.045809 97.93% 0.089022 ยฑ0.000546 8.997 ยฑ0.054
Dolphin-Mistral-24B-Venice-Edition-Q3_K_M 6.725143 ยฑ0.045490 97.34% 0.122502 ยฑ0.000669 11.044 ยฑ0.057
Dolphin-Mistral-24B-Venice-Edition-Q3_K_S 6.988906 ยฑ0.049047 96.56% 0.146027 ยฑ0.000845 11.359 ยฑ0.062
Dolphin-Mistral-24B-Venice-Edition-Q4_K_M 6.349140 ยฑ0.042768 99.30% 0.029709 ยฑ0.000211 5.279 ยฑ0.039
Dolphin-Mistral-24B-Venice-Edition-Q4_K_M-bartowski 6.304728 ยฑ0.042418 99.60% 0.016941 ยฑ0.000138 4.031 ยฑ0.037
Dolphin-Mistral-24B-Venice-Edition-Q4_K_S 6.443819 ยฑ0.043899 99.20% 0.034773 ยฑ0.000234 5.646 ยฑ0.040
Dolphin-Mistral-24B-Venice-Edition-Q5_K_M 6.208247 ยฑ0.041268 99.78% 0.009127 ยฑ0.000080 3.001 ยฑ0.032
Dolphin-Mistral-24B-Venice-Edition-Q5_K_S 6.230846 ยฑ0.041563 99.73% 0.011255 ยฑ0.000090 3.313 ยฑ0.031
Dolphin-Mistral-24B-Venice-Edition-Q6_K 6.218229 ยฑ0.041473 99.93% 0.002698 ยฑ0.000035 1.625 ยฑ0.020
Dolphin-Mistral-24B-Venice-Edition-Q8_0 6.181990 ยฑ0.041079 99.97% 0.000739 ยฑ0.000017 0.822 ยฑ0.015
Dolphin-Mistral-24B-Venice-Edition-F16 6.180577 ยฑ0.041038 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 appropriate links: HellaSwag, ARC, MMLU, Truthful QA and WinoGrande

Model ARC HellaSwag MMLU Truthful QA WinoGrande Avg Score
Dolphin-Mistral-24B-Venice-Edition-IQ3_M 68.1333 ยฑ1.7026 83.60 45.0667 ยฑ1.8180 38.5333 ยฑ1.7783 77.8667 ยฑ1.5169 62.64
Dolphin-Mistral-24B-Venice-Edition-IQ3_S 67.4667 ยฑ1.7119 83.60 45.7333 ยฑ1.8203 38.5333 ยฑ1.7783 77.2000 ยฑ1.5330 62.51
Dolphin-Mistral-24B-Venice-Edition-IQ4_NL 71.2000 ยฑ1.6546 84.13 45.0667 ยฑ1.8180 38.5333 ยฑ1.7783 78.9333 ยฑ1.4900 63.57
Dolphin-Mistral-24B-Venice-Edition-Q3_K_L 68.9333 ยฑ1.6909 83.73 45.3333 ยฑ1.8190 38.4000 ยฑ1.7771 78.8000 ยฑ1.4934 63.04
Dolphin-Mistral-24B-Venice-Edition-Q3_K_M 69.3333 ยฑ1.6849 84.00 46.0000 ยฑ1.8211 37.4667 ยฑ1.7686 77.8667 ยฑ1.5169 62.93
Dolphin-Mistral-24B-Venice-Edition-Q3_K_S 67.8667 ยฑ1.7063 83.20 43.8667 ยฑ1.8132 37.2000 ยฑ1.7661 78.2667 ยฑ1.5070 62.08
Dolphin-Mistral-24B-Venice-Edition-Q4_K_M 71.4667 ยฑ1.6500 84.53 46.0000 ยฑ1.8211 36.9333 ยฑ1.7635 79.3333 ยฑ1.4795 63.65
Dolphin-Mistral-24B-Venice-Edition-Q4_K_M-bartowski 69.8667 ยฑ1.6766 84.27 45.3333 ยฑ1.8190 37.6000 ยฑ1.7699 80.2667 ยฑ1.4542 63.47
Dolphin-Mistral-24B-Venice-Edition-Q4_K_S 70.4000 ยฑ1.6680 84.00 46.1333 ยฑ1.8215 36.5333 ยฑ1.7594 79.4667 ยฑ1.4760 63.31
Dolphin-Mistral-24B-Venice-Edition-Q5_K_M 70.1333 ยฑ1.6723 84.93 44.9333 ยฑ1.8176 37.8667 ยฑ1.7724 79.7333 ยฑ1.4688 63.52
Dolphin-Mistral-24B-Venice-Edition-Q5_K_S 69.6000 ยฑ1.6807 84.40 45.0667 ยฑ1.8180 37.6000 ยฑ1.7699 80.2667 ยฑ1.4542 63.39
Dolphin-Mistral-24B-Venice-Edition-Q6_K 70.0000 ยฑ1.6744 84.53 45.4667 ยฑ1.8194 37.7333 ยฑ1.7711 80.2667 ยฑ1.4542 63.60
Dolphin-Mistral-24B-Venice-Edition-Q8_0 70.8000 ยฑ1.6614 84.53 45.6000 ยฑ1.8199 38.5333 ยฑ1.7783 80.6667 ยฑ1.4430 64.03
Dolphin-Mistral-24B-Venice-Edition-F16 70.8000 ยฑ1.6614 84.53 45.3333 ยฑ1.8190 38.1333 ยฑ1.7748 80.2667 ยฑ1.4542 63.81

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
Dolphin-Mistral-24B-Venice-Edition-Q4_K_M 12.20 GiB 23.57 B Metal,BLAS 12 pp512 255.89 ยฑ6.51
Dolphin-Mistral-24B-Venice-Edition-Q4_K_M 12.20 GiB 23.57 B Metal,BLAS 12 tg128 26.63 ยฑ0.34
Dolphin-Mistral-24B-Venice-Edition-Q4_K_M 12.20 GiB 23.57 B Metal,BLAS 12 pp1024+tg1024 43.78 ยฑ0.33
Dolphin-Mistral-24B-Venice-Edition-Q4_K_M-bartowski 13.34 GiB 23.57 B Metal,BLAS 12 pp512 253.67 ยฑ2.26
Dolphin-Mistral-24B-Venice-Edition-Q4_K_M-bartowski 13.34 GiB 23.57 B Metal,BLAS 12 tg128 27.69 ยฑ0.46
Dolphin-Mistral-24B-Venice-Edition-Q4_K_M-bartowski 13.34 GiB 23.57 B Metal,BLAS 12 pp1024+tg1024 45.54 ยฑ0.18

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

LLaMa C++ has a large and vibrant community of contributors (~1,200 last time I checked) that actively maintain and extend its functionality, adding new models and architectures almost as fast as they appear (considering the breakneck speed at which the AI/ML field is advancing, this alone is a remarkable feat!), and whilst I'm grateful to each and everyone of them, I want to recognise three people in particular: Thank You! Colin Kealty for the many contributions and for being one of the best sources of high quality quantized models available on Hugging Face, and a really big Thank You! to Georgi Gerganov for his amazing work with llama.cpp and the ggml/gguf libraries, and Iwan Kawrakow for being one of the key authors behind the many quantisation algorithms and the imatrix functionality.

Downloads last month
1,275
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. ๐Ÿ™‹ 1 Ask for provider support

Model tree for eaddario/Dolphin-Mistral-24B-Venice-Edition-GGUF

Dataset used to train eaddario/Dolphin-Mistral-24B-Venice-Edition-GGUF