Text Generation
GGUF
English
quant
experimental
conversational
eaddario commited on
Commit
18d7797
·
verified ·
1 Parent(s): 08259b8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +144 -91
README.md CHANGED
@@ -14,25 +14,26 @@ tags:
14
  - experimental
15
  ---
16
 
17
- # Experimental GGUF quantized versions of cognitivecomputations/Dolphin3.0-Mistral-24B
18
 
19
- Using [LLaMA C++](<https://github.com/ggerganov/llama.cpp>) release [b4837](<https://github.com/ggerganov/llama.cpp/releases/tag/b4837>) for quantization.
20
 
21
- Original model: [cognitivecomputations/Dolphin3.0-Mistral-24B](https://huggingface.co/cognitivecomputations/Dolphin3.0-Mistral-24B)
22
 
23
  From the original model creators:
24
 
25
- >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.
26
  >
27
- >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.
28
- >1) They maintain control of the system prompt, deprecating and changing things as they wish, often causing software to break.
29
- >2) They maintain control of the model versions, sometimes changing things silently, or deprecating older models that your business relies on.
30
- >3) They maintain control of the alignment, and in particular the alignment is one-size-fits all, not tailored to the application.
31
- >4) They can see all your queries and they can potentially use that data in ways you wouldn't want.
32
- >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.
33
  >
34
- >Dolphin belongs to YOU, it is your tool, an extension of your will.
35
- >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.
 
 
36
 
37
  From Eric Hartford's, the creator of the Dolphin model series, [Uncensored Models](https://erichartford.com/uncensored-models):
38
 
@@ -42,113 +43,165 @@ From Eric Hartford's, the creator of the Dolphin model series, [Uncensored Model
42
 
43
  # PLEASE READ THIS BEFORE USING THESE EXPERIMENTAL VERSIONS!
44
 
45
- 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.
 
 
 
 
 
 
46
 
47
- The process of [quantization](<https://huggingface.co/docs/optimum/en/concept_guides/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!).
 
 
 
 
 
 
 
 
48
 
49
- Another approach is to [prune](<https://en.wikipedia.org/wiki/Pruning_(artificial_neural_network>) 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!
50
 
51
- 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 **3% 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.
52
 
53
- For testing and comparison I'd normally use models produced by [Unsloth](<https://huggingface.co/unsloth>) ([Daniel and Michael Han](<https://unsloth.ai/>) do some really advanced level stuff!) and [Bartowski](<https://huggingface.co/bartowski>) (see credits below), but only the latter offers a version of these model so all tests and comparisons are done against a single reference.
54
 
55
- All experimental versions were generated using an appropriate imatrix created from calibration datasets available at [eaddario/imatrix-calibration](<https://huggingface.co/datasets/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.
56
 
57
  The process to generate these models is roughly as follows:
58
 
59
- 1. Convert the the original model's tensors to [GGUF](<https://huggingface.co/docs/hub/en/gguf>) F16*
60
- 2. Estimate the Perplexity score for the F16 model (baseline) using the [wikitext-2-raw-v1](<https://huggingface.co/datasets/Salesforce/wikitext/tree/main/wikitext-2-raw-v1>) dataset, and save the [logits](<https://huggingface.co/eaddario/Dolphin3.0-Mistral-24B-GGUF/tree/main/logits>)
61
- 3. Generate an [imatrix](<https://huggingface.co/eaddario/Dolphin3.0-Mistral-24B-GGUF/tree/main/imatrix>) from selected calibration datasets
62
- 4. Quantize & prune versions of the base model
63
- 5. Calculate Perplexity, KL Divergence, ARC (Easy+Challenge), HellaSwag, MMLU, Truthful QA and WinoGrande [scores](<https://huggingface.co/eaddario/Dolphin3.0-Mistral-24B-GGUF/tree/main/scores>) for each quantized model
64
- 6. Keep versions with the best scores
65
- 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.
 
66
 
67
- *[BF16](<https://en.wikipedia.org/wiki/Bfloat16_floating-point_format>) 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
68
 
69
  # Models
70
 
71
  ### Sizes (in GB)
72
  | Model | Bartowski | Repo | Shrinkage |
73
- |-----------------------------------------------------------------------|----------:|------:|----------:|
74
- | [Dolphin3.0-Mistral-24B-IQ3_M](./Dolphin3.0-Mistral-24B-IQ3_M.gguf) | 10.65 | 10.25 | 3.8% |
75
- | [Dolphin3.0-Mistral-24B-IQ3_S](./Dolphin3.0-Mistral-24B-IQ3_S.gguf) | N/A | 10.03 | N/A |
76
- | [Dolphin3.0-Mistral-24B-IQ4_NL](./Dolphin3.0-Mistral-24B-IQ4_NL.gguf) | 13.05 | 13.05 | 0% |
77
- | [Dolphin3.0-Mistral-24B-Q3_K_L](./Dolphin3.0-Mistral-24B-Q3_K_L.gguf) | 12.40 | 12.00 | 0% |
78
- | [Dolphin3.0-Mistral-24B-Q3_K_M](./Dolphin3.0-Mistral-24B-Q3_K_M.gguf) | 11.47 | 11.08 | 3.4% |
79
- | [Dolphin3.0-Mistral-24B-Q3_K_S](./Dolphin3.0-Mistral-24B-Q3_K_S.gguf) | 10.40 | 10.00 | 3.8% |
80
- | [Dolphin3.0-Mistral-24B-Q4_K_M](./Dolphin3.0-Mistral-24B-Q4_K_M.gguf) | 14.33 | 13.99 | 2.4% |
81
- | [Dolphin3.0-Mistral-24B-Q4_K_S](./Dolphin3.0-Mistral-24B-Q4_K_S.gguf) | 13.55 | 13.13 | 3.1% |
82
- | [Dolphin3.0-Mistral-24B-Q5_K_M](./Dolphin3.0-Mistral-24B-Q5_K_M.gguf) | 16.76 | 16.26 | 3% |
83
- | [Dolphin3.0-Mistral-24B-Q5_K_S](./Dolphin3.0-Mistral-24B-Q5_K_S.gguf) | 16.30 | 15.80 | 3.1% |
84
- | [Dolphin3.0-Mistral-24B-Q6_K](./Dolphin3.0-Mistral-24B-Q6_K.gguf) | 19.35 | 18.75 | 3.1% |
85
- | [Dolphin3.0-Mistral-24B-Q8_0](./Dolphin3.0-Mistral-24B-Q8_0.gguf) | 25.05 | 24.14 | 3.6% |
86
 
87
  ### Perplexity and KL Divergence scores
88
- | Model | μPPL | 𝜌PPL | μKLD | RMS Δp |
89
- |-----------------------------------------------------------------------|--------------------:|-------:|-------------------:|--------------:|
90
- | [Dolphin3.0-Mistral-24B-IQ3_M](./Dolphin3.0-Mistral-24B-IQ3_M.gguf) | 8.536738 ±0.059988 | 98.03% | 0.103999 ±0.000378 | 9.251 ±0.039 |
91
- | [Dolphin3.0-Mistral-24B-IQ3_S](./Dolphin3.0-Mistral-24B-IQ3_S.gguf) | 8.602292 ±0.060945 | 97.95% | 0.108536 ±0.000393 | 9.309 ±0.040 |
92
- | [Dolphin3.0-Mistral-24B-IQ4_NL](./Dolphin3.0-Mistral-24B-IQ4_NL.gguf) | 7.895583 ±0.054759 | 99.38% | 0.031400 ±0.000136 | 5.278 ±0.027 |
93
- | [Dolphin3.0-Mistral-24B-Q3_K_L](./Dolphin3.0-Mistral-24B-Q3_K_L.gguf) | 8.320959 ±0.058079 | 98.43% | 0.083143 ±0.000296 | 8.464 ±0.035 |
94
- | [Dolphin3.0-Mistral-24B-Q3_K_M](./Dolphin3.0-Mistral-24B-Q3_K_M.gguf) | 8.389337 ±0.058940 | 98.30% | 0.089559 ±0.000330 | 8.734 ±0.037 |
95
- | [Dolphin3.0-Mistral-24B-Q3_K_S](./Dolphin3.0-Mistral-24B-Q3_K_S.gguf) | 8.681563 ±0.061366 | 97.26% | 0.138030 ±0.000557 | 10.731 ±0.047 |
96
- | [Dolphin3.0-Mistral-24B-Q4_K_M](./Dolphin3.0-Mistral-24B-Q4_K_M.gguf) | 7.868503 ±0.054510 | 99.45% | 0.027967 ±0.000110 | 4.959 ±0.024 |
97
- | [Dolphin3.0-Mistral-24B-Q4_K_S](./Dolphin3.0-Mistral-24B-Q4_K_S.gguf) | 7.922314 ±0.055044 | 99.40% | 0.030745 ±0.000128 | 5.176 ±0.026 |
98
- | [Dolphin3.0-Mistral-24B-Q5_K_M](./Dolphin3.0-Mistral-24B-Q5_K_M.gguf) | 7.785290 ±0.053616 | 99.63% | 0.018900 ±0.000070 | 4.199 ±0.019 |
99
- | [Dolphin3.0-Mistral-24B-Q5_K_S](./Dolphin3.0-Mistral-24B-Q5_K_S.gguf) | 7.819818 ±0.053887 | 99.62% | 0.019857 ±0.000076 | 4.338 ±0.020 |
100
- | [Dolphin3.0-Mistral-24B-Q6_K](./Dolphin3.0-Mistral-24B-Q6_K.gguf) | 7.757601 ±0.053375 | 99.70% | 0.015707 ±0.000047 | 3.852 ±0.014 |
101
- | [Dolphin3.0-Mistral-24B-Q8_0](./Dolphin3.0-Mistral-24B-Q8_0.gguf) | 7.737414 ±0.053007 | 99.72% | 0.014644 ±0.000046 | 3.754 ±0.015 |
102
- | [Dolphin3.0-Mistral-24B-F16](./Dolphin3.0-Mistral-24B-F16.gguf) | 9.366577 ±0.066397 | 100% | N/A | N/A |
 
103
 
104
  ### ARC, HellaSwag, MMLU, Truthful QA and WinoGrande scores
105
- Scores generated using [llama-perplexity](<https://github.com/ggml-org/llama.cpp/tree/master/examples/perplexity>) with 750 tasks per test, and a context size of 768 tokens. Naive (`llama-quantize` with no optimization) Q4_K_M quantization included for comparison.
106
-
107
- For the test data used in the generation of these scores, follow the appropiate links: [HellaSwag](<https://github.com/klosax/hellaswag_text_data>), [ARC, MMLU, Truthful QA](<https://huggingface.co/datasets/ikawrakow/validation-datasets-for-llama.cpp/tree/main>) and [WinoGrande](<https://huggingface.co/datasets/ikawrakow/winogrande-eval-for-llama.cpp/tree/main>)
108
-
109
- | Model | ARC | HellaSwag | MMLU | Truthful QA | WinoGrande |
110
- |-------------------------------------------------------------------------------------------------------------------------------|----------------:|----------:|----------------:|----------------:|----------------:|
111
- | [Dolphin3.0-Mistral-24B-IQ3_M](./Dolphin3.0-Mistral-24B-IQ3_M.gguf) | 70.5333 ±1.6658 | 80.80 | 43.7333 ±1.8126 | 35.4667 ±1.7481 | 74.9333 ±1.5836 |
112
- | [Dolphin3.0-Mistral-24B-IQ3_S](./Dolphin3.0-Mistral-24B-IQ3_S.gguf) | 70.1333 ±1.6723 | 80.93 | 43.7333 ±1.8126 | 36.5333 ±1.7594 | 74.4000 ±1.5947 |
113
- | [Dolphin3.0-Mistral-24B-IQ4_NL](./Dolphin3.0-Mistral-24B-IQ4_NL.gguf) | 72.1333 ±1.6382 | 80.27 | 42.6667 ±1.8072 | 35.7333 ±1.7510 | 76.5333 ±1.5485 |
114
- | [Dolphin3.0-Mistral-24B-Q3_K_L](./Dolphin3.0-Mistral-24B-Q3_K_L.gguf) | 72.5333 ±1.6309 | 80.93 | 41.6000 ±1.8010 | 34.2667 ±1.7342 | 75.7333 ±1.5664 |
115
- | [Dolphin3.0-Mistral-24B-Q3_K_M](./Dolphin3.0-Mistral-24B-Q3_K_M.gguf) | 73.4667 ±1.6132 | 80.93 | 42.1333 ±1.8042 | 34.9300 ±1.6774 | 76.1333 ±1.5576 |
116
- | [Dolphin3.0-Mistral-24B-Q3_K_S](./Dolphin3.0-Mistral-24B-Q3_K_S.gguf) | 70.5333 ±1.6658 | 80.67 | 41.2000 ±1.7984 | 35.2000 ±1.7451 | 74.6667 ±1.5892 |
117
- | [Dolphin3.0-Mistral-24B-Q4_K_M](./Dolphin3.0-Mistral-24B-Q4_K_M.gguf) | 72.6667 ±1.6284 | 81.73 | 42.5333 ±1.8065 | 35.0667 ±1.7436 | 77.6000 ±1.5234 |
118
- | [Dolphin3.0-Mistral-24B-Q4_K_M-bartowski](https://huggingface.co/bartowski/cognitivecomputations_Dolphin3.0-Mistral-24B-GGUF) | 72.2667 ±1.6358 | 81.73 | 42.8000 ±1.8079 | 35.0667 ±1.7436 | 76.8000 ±1.5424 |
119
- | [Dolphin3.0-Mistral-24B-Q4_K_S](./Dolphin3.0-Mistral-24B-Q4_K_S.gguf) | 72.4000 ±1.6334 | 81.47 | 43.0667 ±1.8093 | 35.3333 ±1.7466 | 77.2000 ±1.5330 |
120
- | [Dolphin3.0-Mistral-24B-Q5_K_M](./Dolphin3.0-Mistral-24B-Q5_K_M.gguf) | 72.0000 ±1.6406 | 81.20 | 42.9333 ±1.8086 | 35.7333 ±1.7510 | 78.1333 ±1.5103 |
121
- | [Dolphin3.0-Mistral-24B-Q5_K_S](./Dolphin3.0-Mistral-24B-Q5_K_S.gguf) | 72.6667 ±1.6284 | 81.47 | 41.6000 ±1.8010 | 35.7333 ±1.7510 | 76.5333 ±1.5485 |
122
- | [Dolphin3.0-Mistral-24B-Q6_K](./Dolphin3.0-Mistral-24B-Q6_K.gguf) | 72.4000 ±1.6334 | 81.47 | 43.0667 ±1.8093 | 36.6667 ±1.7608 | 77.8667 ±1.5169 |
123
- | [Dolphin3.0-Mistral-24B-Q8_0](./Dolphin3.0-Mistral-24B-Q8_0.gguf) | 72.8000 ±1.6260 | 81.33 | 43.0667 ±1.8093 | 35.7333 ±1.7510 | 77.4667 ±1.5266 |
124
- | [Dolphin3.0-Mistral-24B-F16](./Dolphin3.0-Mistral-24B-F16.gguf) | 71.6000 ±1.6477 | 81.47 | 43.4667 ±1.8113 | 35.4667 ±1.7481 | 77.6000 ±1.5234 |
125
 
126
  ### Tokens per Second - Benchmarks
127
- Scores generated using [llama-bench](<https://github.com/ggml-org/llama.cpp/tree/master/examples/llama-bench>). Naive (`llama-quantize` with no optimization) Q4_K_M quantization included for comparison.
128
 
129
- | model | size | params | backend | ngl | test | t/s |
130
- |-------------------------------------------------------------------------------------------------------------------------------|----------:|--------:|---------|----:|--------------:|--------------:|
131
- | [Dolphin3.0-Mistral-24B-Q4_K_M](./Dolphin3.0-Mistral-24B-Q4_K_M.gguf) | 12.95 GiB | 23.57 B | CUDA | 12 | pp512 | 164.39 ± 0.20 |
132
- | [Dolphin3.0-Mistral-24B-Q4_K_M](./Dolphin3.0-Mistral-24B-Q4_K_M.gguf) | 12.95 GiB | 23.57 B | CUDA | 12 | tg128 | 4.71 ± 0.06 |
133
- | [Dolphin3.0-Mistral-24B-Q4_K_M](./Dolphin3.0-Mistral-24B-Q4_K_M.gguf) | 12.95 GiB | 23.57 B | CUDA | 12 | pp1024+tg1024 | 8.87 ± 0.04 |
134
- | [Dolphin3.0-Mistral-24B-Q4_K_M-bartowski](https://huggingface.co/bartowski/cognitivecomputations_Dolphin3.0-Mistral-24B-GGUF) | 13.34 GiB | 23.57 B | CUDA | 12 | pp512 | 162.55 ± 0.47 |
135
- | [Dolphin3.0-Mistral-24B-Q4_K_M-bartowski](https://huggingface.co/bartowski/cognitivecomputations_Dolphin3.0-Mistral-24B-GGUF) | 13.34 GiB | 23.57 B | CUDA | 12 | tg128 | 4.57 ± 0.03 |
136
- | [Dolphin3.0-Mistral-24B-Q4_K_M-bartowski](https://huggingface.co/bartowski/cognitivecomputations_Dolphin3.0-Mistral-24B-GGUF) | 13.34 GiB | 23.57 B | CUDA | 12 | pp1024+tg1024 | 8.62 ± 0.03 |
137
 
138
  # Metrics used
139
- **[Perplexity](<https://huggingface.co/docs/transformers/en/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.
140
 
141
- **[Kullback–Leibler (KL) Divergence](<https://en.wikipedia.org/wiki/Kullback–Leibler_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.
142
 
143
- **[AI2 Reasoning Challenge (ARC)](<https://leaderboard.allenai.org/arc/submissions/get-started>):** a benchmark to evaluate the ability of AI models to answer complex science questions that require logical reasoning beyond pattern matching.
144
 
145
- **[HellaSwag](<https://rowanzellers.com/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.
146
 
147
- **[MMLU](<https://github.com/hendrycks/test>):** 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.
148
 
149
- **[Truthful QA](<https://github.com/sylinrl/TruthfulQA>):** 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.
150
 
151
- **[Winogrande](<https://winogrande.allenai.org/>):** based on the [Winograd Schema Challenge](<https://cdn.aaai.org/ocs/4492/4492-21843-1-PB.pdf>), is a natural language understanding task requiring models to resolve ambiguities in sentences involving pronoun references.
152
 
153
  ## Credits
154
- A big **Thank You!** to [Colin Kealty](<https://huggingface.co/bartowski>) 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](<https://github.com/ggerganov>) for his amazing work with **llama.cpp** and the **gguf** file format.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  - experimental
15
  ---
16
 
17
+ # Experimental layer-wise quantization of cognitivecomputations/Dolphin3.0-Mistral-24B
18
 
19
+ Using [LLaMA C++][llm] release [b5269][llm-rel] for quantization.
20
 
21
+ Original model: [cognitivecomputations/Dolphin3.0-Mistral-24B][mdl]
22
 
23
  From the original model creators:
24
 
25
+ > 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.
26
  >
27
+ > 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.
28
+ > 1) They maintain control of the system prompt, deprecating and changing things as they wish, often causing software to break.
29
+ > 2) They maintain control of the model versions, sometimes changing things silently, or deprecating older models that your business relies on.
30
+ > 3) They maintain control of the alignment, and in particular the alignment is one-size-fits all, not tailored to the application.
31
+ > 4) They can see all your queries and they can potentially use that data in ways you wouldn't want.
 
32
  >
33
+ > 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.
34
+ >
35
+ > Dolphin belongs to YOU, it is your tool, an extension of your will.
36
+ > 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.
37
 
38
  From Eric Hartford's, the creator of the Dolphin model series, [Uncensored Models](https://erichartford.com/uncensored-models):
39
 
 
43
 
44
  # PLEASE READ THIS BEFORE USING THESE EXPERIMENTAL VERSIONS!
45
 
46
+ 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.
47
+
48
+ The method used to produce these experimental versions is covered in [Squeezing Tensor Bits: the quest for smaller LLMs][mdm], 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][lwq-ppr].
49
+
50
+ As of version [b5125][qtz-rel] [llama-quantize][qtz] 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).
51
+
52
+ The modified version of [llama-imatrix][imx] generates useful statistics to guide the tensor selection process, `--show-statistics` will display:
53
 
54
+ - **Σ(Bias):** the sum of all activations over the tensor (i.e. the Importance Scores)
55
+ - **Min & Max:** minimum and maximum activation values
56
+ - **μ & σ:** activations' mean and standard deviation
57
+ - **% 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
58
+ - **N:** number of activations in the tensor
59
+ - **Entropy:** entropy of the activation distribution, in bits (standard Shannon entropy measurement)
60
+ - **E (norm):** Normalized entropy.
61
+ - **ZD Score:** z-score distribution as described in 3.1 Layer Importance Scores in the Layer-Wise Quantization paper
62
+ - **CosSim:** cosine similarity between same type tensors with respect to the previous layer (i.e. blk.7.attn_k and blk.6.attn_k)
63
 
64
+ 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.
65
 
66
+ There’s a [pull request][imtx-pr] 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][gh].
67
 
68
+ For testing and comparison I use models produced by [Unsloth][ust] ([Daniel and Michael Han][ust-ai] do some really advanced level stuff!) and [Bartowski][btk] (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.
69
 
70
+ All experimental versions were generated using an appropriate imatrix created from calibration datasets available at [eaddario/imatrix-calibration][ical]. 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.
71
 
72
  The process to generate these models is roughly as follows:
73
 
74
+ 1. Convert the the original model's tensors to [GGUF][ggf] F16*
75
+ 2. Estimate the Perplexity score for the F16 model (baseline) using the [wikitext-2-raw-v1][wki-dat] dataset, and save the [logits][lgt]
76
+ 3. Generate an [imatrix][imx-dat] from selected calibration datasets
77
+ 4. Determine tensor and layer Importance Score contribution using the modified version of `llama-imatrix`
78
+ 5. Select an appropiate quant level for each tensor and quantize the model using `llama-quantize`
79
+ 6. Calculate Perplexity, KL Divergence, ARC (Easy+Challenge), HellaSwag, MMLU, Truthful QA and WinoGrande scores for each quantized model
80
+ 7. Keep versions with the best scores
81
+ 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.
82
 
83
+ *[BF16][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
84
 
85
  # Models
86
 
87
  ### Sizes (in GB)
88
  | Model | Bartowski | Repo | Shrinkage |
89
+ | --------------------------------------------------------------------- | --------: | ----: | --------: |
90
+ | [Dolphin3.0-Mistral-24B-IQ3_M](./Dolphin3.0-Mistral-24B-IQ3_M.gguf) | 10.70 | 10.82 | -1.1% |
91
+ | [Dolphin3.0-Mistral-24B-IQ3_S](./Dolphin3.0-Mistral-24B-IQ3_S.gguf) | 9.91 | 10.18 | -2.7% |
92
+ | [Dolphin3.0-Mistral-24B-IQ4_NL](./Dolphin3.0-Mistral-24B-IQ4_NL.gguf) | 13.50 | 13.05 | 3.3% |
93
+ | [Dolphin3.0-Mistral-24B-Q3_K_L](./Dolphin3.0-Mistral-24B-Q3_K_L.gguf) | 12.40 | 10.96 | 11.6% |
94
+ | [Dolphin3.0-Mistral-24B-Q3_K_M](./Dolphin3.0-Mistral-24B-Q3_K_M.gguf) | 11.50 | 10.42 | 9.4% |
95
+ | [Dolphin3.0-Mistral-24B-Q3_K_S](./Dolphin3.0-Mistral-24B-Q3_K_S.gguf) | 10.40 | 9.78 | 6.0% |
96
+ | [Dolphin3.0-Mistral-24B-Q4_K_M](./Dolphin3.0-Mistral-24B-Q4_K_M.gguf) | 14.30 | 13.07 | 8.6% |
97
+ | [Dolphin3.0-Mistral-24B-Q4_K_S](./Dolphin3.0-Mistral-24B-Q4_K_S.gguf) | 13.50 | 12.64 | 6.4% |
98
+ | [Dolphin3.0-Mistral-24B-Q5_K_M](./Dolphin3.0-Mistral-24B-Q5_K_M.gguf) | 16.80 | 15.58 | 7.3% |
99
+ | [Dolphin3.0-Mistral-24B-Q5_K_S](./Dolphin3.0-Mistral-24B-Q5_K_S.gguf) | 16.30 | 14.91 | 8.5% |
100
+ | [Dolphin3.0-Mistral-24B-Q6_K](./Dolphin3.0-Mistral-24B-Q6_K.gguf) | 19.30 | 19.28 | 0.1% |
101
+ | [Dolphin3.0-Mistral-24B-Q8_0](./Dolphin3.0-Mistral-24B-Q8_0.gguf) | 25.10 | 22.98 | 8.4% |
102
 
103
  ### Perplexity and KL Divergence scores
104
+ | Model | μPPL | 𝜌PPL | μKLD | RMS Δp |
105
+ | --------------------------------------------------------------------- | -----------------: | -----: | -----------------: | -------------: |
106
+ | [Dolphin3.0-Mistral-24B-IQ3_M](./Dolphin3.0-Mistral-24B-IQ3_M.gguf) | 8.012181 ±0.057587 | 98.51% | 0.075215 ±0.000327 | 7.532 ±0.039 |
107
+ | [Dolphin3.0-Mistral-24B-IQ3_S](./Dolphin3.0-Mistral-24B-IQ3_S.gguf) | 8.287859 ±0.060555 | 98.01% | 0.103139 ±0.000420 | 8.803 ±0.042 |
108
+ | [Dolphin3.0-Mistral-24B-IQ4_NL](./Dolphin3.0-Mistral-24B-IQ4_NL.gguf) | 7.258862 ±0.048917 | 99.42% | 0.026173 ±0.000130 | 4.620 ±0.028 |
109
+ | [Dolphin3.0-Mistral-24B-Q3_K_L](./Dolphin3.0-Mistral-24B-Q3_K_L.gguf) | 7.797546 ±0.054239 | 98.21% | 0.082339 ±0.000394 | 8.255 ±0.044 |
110
+ | [Dolphin3.0-Mistral-24B-Q3_K_M](./Dolphin3.0-Mistral-24B-Q3_K_M.gguf) | 7.782805 ±0.053599 | 97.99% | 0.090775 ±0.000432 | 8.667 ±0.047 |
111
+ | [Dolphin3.0-Mistral-24B-Q3_K_S](./Dolphin3.0-Mistral-24B-Q3_K_S.gguf) | 7.985599 ±0.055344 | 97.24% | 0.124740 ±0.000599 | 10.136 ± 0.052 |
112
+ | [Dolphin3.0-Mistral-24B-Q4_K_M](./Dolphin3.0-Mistral-24B-Q4_K_M.gguf) | 7.326599 ±0.049682 | 99.44% | 0.025003 ±0.000124 | 4.552 ±0.028 |
113
+ | [Dolphin3.0-Mistral-24B-Q4_K_M-bartowski][b-q4km] | 7.245078 ±0.049005 | 99.66% | 0.015387 ±0.000084 | 3.597 ±0.025 |
114
+ | [Dolphin3.0-Mistral-24B-Q4_K_S](./Dolphin3.0-Mistral-24B-Q4_K_S.gguf) | 7.348107 ±0.049924 | 99.40% | 0.026971 ±0.000135 | 4.731 ±0.030 |
115
+ | [Dolphin3.0-Mistral-24B-Q5_K_M](./Dolphin3.0-Mistral-24B-Q5_K_M.gguf) | 7.209640 ±0.048722 | 99.78% | 0.009535 ±0.000047 | 2.871 ±0.017 |
116
+ | [Dolphin3.0-Mistral-24B-Q5_K_S](./Dolphin3.0-Mistral-24B-Q5_K_S.gguf) | 7.232320 ±0.048920 | 99.76% | 0.010237 ±0.000053 | 2.954 ±0.019 |
117
+ | [Dolphin3.0-Mistral-24B-Q6_K](./Dolphin3.0-Mistral-24B-Q6_K.gguf) | 7.183488 ±0.048400 | 99.90% | 0.003797 ±0.000020 | 1.880 ±0.012 |
118
+ | [Dolphin3.0-Mistral-24B-Q8_0](./Dolphin3.0-Mistral-24B-Q8_0.gguf) | 7.161438 ±0.048174 | 99.94% | 0.001880 ±0.000012 | 1.384 ±0.009 |
119
+ | [Dolphin3.0-Mistral-24B-F16](./Dolphin3.0-Mistral-24B-F16.gguf) | 7.148748 ±0.047873 | 100% | N/A | N/A |
120
 
121
  ### ARC, HellaSwag, MMLU, Truthful QA and WinoGrande scores
122
+ Scores generated using [llama-perplexity][ppl] with 750 tasks per test, and a context size of 768 tokens.
123
+
124
+ For the test data used in the generation of these scores, follow the appropiate links: [HellaSwag][hsw-tst], [ARC, MMLU, Truthful QA][tst-dat] and [WinoGrande][wng-tst]
125
+
126
+ | Model | ARC | HellaSwag | MMLU | Truthful QA | WinoGrande | Avg Score |
127
+ | --------------------------------------------------------------------- | --------------: | --------: | --------------: | --------------: | --------------: | --------: |
128
+ | [Dolphin3.0-Mistral-24B-IQ3_M](./Dolphin3.0-Mistral-24B-IQ3_M.gguf) | 72.2667 ±1.6358 | 81.33 | 42.9333 ±1.8086 | 35.7333 ±1.7510 | 75.7333 ±1.5664 | 61.60 |
129
+ | [Dolphin3.0-Mistral-24B-IQ3_S](./Dolphin3.0-Mistral-24B-IQ3_S.gguf) | 70.2667 ±1.6702 | 81.20 | 41.8667 ±1.8026 | 36.5333 ±1.7594 | 73.6000 ±1.6106 | 60.69 |
130
+ | [Dolphin3.0-Mistral-24B-IQ4_NL](./Dolphin3.0-Mistral-24B-IQ4_NL.gguf) | 72.1333 ±1.6382 | 80.80 | 43.2000 ±1.8100 | 35.8667 ±1.7525 | 76.6667 ±1.5454 | 61.73 |
131
+ | [Dolphin3.0-Mistral-24B-Q3_K_L](./Dolphin3.0-Mistral-24B-Q3_K_L.gguf) | 70.8000 ±1.6614 | 81.33 | 40.1333 ±1.7910 | 35.6000 ±1.7496 | 77.0667 ±1.5361 | 60.99 |
132
+ | [Dolphin3.0-Mistral-24B-Q3_K_M](./Dolphin3.0-Mistral-24B-Q3_K_M.gguf) | 71.6000 ±1.6477 | 80.27 | 40.6667 ±1.7948 | 34.5333 ±1.7374 | 76.0000 ±1.5605 | 60.61 |
133
+ | [Dolphin3.0-Mistral-24B-Q3_K_S](./Dolphin3.0-Mistral-24B-Q3_K_S.gguf) | 71.0667 ±1.6569 | 80.13 | 40.4000 ±1.7930 | 34.4000 ±1.7358 | 75.8667 ±1.5635 | 60.37 |
134
+ | [Dolphin3.0-Mistral-24B-Q4_K_M](./Dolphin3.0-Mistral-24B-Q4_K_M.gguf) | 72.8000 ±1.6260 | 81.07 | 42.1333 ±1.8042 | 35.3333 ±1.7466 | 76.5333 ±1.5485 | 61.57 |
135
+ | [Dolphin3.0-Mistral-24B-Q4_K_M-bartowski][b-q4km] | 72.1333 ±1.6382 | 81.20 | 42.2667 ±1.8050 | 35.0667 ±1.7436 | 76.6667 ±1.5454 | 61.47 |
136
+ | [Dolphin3.0-Mistral-24B-Q4_K_S](./Dolphin3.0-Mistral-24B-Q4_K_S.gguf) | 72.2667 ±1.6358 | 80.93 | 42.2667 ±1.8050 | 35.8667 ±1.7525 | 76.1333 ±1.5576 | 61.49 |
137
+ | [Dolphin3.0-Mistral-24B-Q5_K_M](./Dolphin3.0-Mistral-24B-Q5_K_M.gguf) | 71.2000 ±1.6546 | 82.13 | 43.0667 ±1.8093 | 35.6000 ±1.7496 | 76.4000 ±1.5515 | 61.68 |
138
+ | [Dolphin3.0-Mistral-24B-Q5_K_S](./Dolphin3.0-Mistral-24B-Q5_K_S.gguf) | 72.2667 ±1.6358 | 81.60 | 43.0667 ±1.8093 | 35.0667 ±1.7436 | 76.0000 ±1.5605 | 61.60 |
139
+ | [Dolphin3.0-Mistral-24B-Q6_K](./Dolphin3.0-Mistral-24B-Q6_K.gguf) | 71.8667 ±1.6430 | 81.33 | 42.5333 ±1.8065 | 35.7333 ±1.7510 | 77.7333 ±1.5202 | 61.84 |
140
+ | [Dolphin3.0-Mistral-24B-Q8_0](./Dolphin3.0-Mistral-24B-Q8_0.gguf) | 71.6000 ±1.6477 | 81.73 | 42.4000 ±1.8057 | 36.0000 ±1.7539 | 77.8667 ±1.5169 | 61.92 |
141
+ | [Dolphin3.0-Mistral-24B-F16](./Dolphin3.0-Mistral-24B-F16.gguf) | 71.4667 ±1.6500 | 81.60 | 43.0667 ±1.8093 | 35.7333 ±1.7510 | 78.4000 ±1.5036 | 62.05 |
142
 
143
  ### Tokens per Second - Benchmarks
144
+ Scores generated using [llama-bench][bch]. Naive (`llama-quantize` with no optimization) Q4_K_M quantization included for comparison.
145
 
146
+ | model | size | params | backend | threads | test | t/s |
147
+ | --------------------------------------------------------------------- | --------: | ------: | ---------- | ------: | ------------: | ------------: |
148
+ | [Dolphin3.0-Mistral-24B-Q4_K_M](./Dolphin3.0-Mistral-24B-Q4_K_M.gguf) | 12.17 GiB | 23.57 B | Metal,BLAS | 6 | pp512 | 100.97 ± 0.31 |
149
+ | [Dolphin3.0-Mistral-24B-Q4_K_M](./Dolphin3.0-Mistral-24B-Q4_K_M.gguf) | 12.17 GiB | 23.57 B | Metal,BLAS | 6 | tg128 | 9.70 ± 0.07 |
150
+ | [Dolphin3.0-Mistral-24B-Q4_K_M](./Dolphin3.0-Mistral-24B-Q4_K_M.gguf) | 12.17 GiB | 23.57 B | Metal,BLAS | 6 | pp1024+tg1024 | 15.96 ± 0.07 |
151
+ | [Dolphin3.0-Mistral-24B-Q4_K_M-bartowski][b-q4km] | 13.34 GiB | 23.57 B | Metal,BLAS | 6 | pp512 | 105.38 ± 0.24 |
152
+ | [Dolphin3.0-Mistral-24B-Q4_K_M-bartowski][b-q4km] | 13.34 GiB | 23.57 B | Metal,BLAS | 6 | tg128 | 8.72 ± 0.04 |
153
+ | [Dolphin3.0-Mistral-24B-Q4_K_M-bartowski][b-q4km] | 13.34 GiB | 23.57 B | Metal,BLAS | 6 | pp1024+tg1024 | 15.25 ± 0.02 |
154
 
155
  # Metrics used
156
+ **[Perplexity][ppx]:** 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.
157
 
158
+ **[Kullback–Leibler (KL) Divergence][kld]:** 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.
159
 
160
+ **[AI2 Reasoning Challenge (ARC)][arc]:** a benchmark to evaluate the ability of AI models to answer complex science questions that require logical reasoning beyond pattern matching.
161
 
162
+ **[HellaSwag][hsw]:** 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.
163
 
164
+ **[MMLU][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.
165
 
166
+ **[Truthful QA][tqa]:** 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.
167
 
168
+ **[Winogrande][wng]:** based on the [Winograd Schema Challenge][wng-chl], is a natural language understanding task requiring models to resolve ambiguities in sentences involving pronoun references.
169
 
170
  ## Credits
171
+ A big **Thank You!** to [Colin Kealty][btk] 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][ggg] for his amazing work with **llama.cpp** and the **ggml/gguf** libraries.
172
+
173
+ [arc]: https://leaderboard.allenai.org/arc/submissions/get-started
174
+ [btk]: https://huggingface.co/bartowski
175
+ [bch]: https://github.com/ggml-org/llama.cpp/tree/master/tools/llama-bench
176
+ [bf16]: https://en.wikipedia.org/wiki/Bfloat16_floating-point_format
177
+ [b-q4km]: https://huggingface.co/bartowski/cognitivecomputations_Dolphin3.0-Mistral-24B-GGUF/blob/main/cognitivecomputations_Dolphin3.0-Mistral-24B-Q4_K_M.gguf
178
+ [u-q4km]: https://huggingface.co/unsloth
179
+ [ical]: https://huggingface.co/datasets/eaddario/imatrix-calibration
180
+ [ggg]: https://github.com/ggerganov
181
+ [ggf]: https://huggingface.co/docs/hub/en/gguf
182
+ [gh]: https://github.com/EAddario/llama.cpp/tree/imatrix
183
+ [hsw]: https://rowanzellers.com/hellaswag
184
+ [hsw-tst]: https://github.com/klosax/hellaswag_text_data
185
+ [imx-dat]: https://huggingface.co/eaddario/Dolphin3.0-Mistral-24B-GGUF/tree/main/imatrix
186
+ [imx]: https://github.com/ggml-org/llama.cpp/tree/master/tools/imatrix
187
+ [imtx-pr]: https://github.com/ggml-org/llama.cpp/pull/12718
188
+ [kld]: https://en.wikipedia.org/wiki/Kullback–Leibler_divergence
189
+ [llm]: https://github.com/ggerganov/llama.cpp
190
+ [llm-rel]: https://github.com/ggerganov/llama.cpp/releases/tag/b5269
191
+ [lgt]: https://huggingface.co/eaddario/Dolphin3.0-Mistral-24B-GGUF/tree/main/logits
192
+ [lwq-ppr]: https://arxiv.org/abs/2406.17415
193
+ [mdm]: https://medium.com/@eaddario/squeezing-tensor-bits-the-quest-for-smaller-llms-86b23bd052ca
194
+ [mmlu]: https://github.com/hendrycks/test
195
+ [mdl]: https://huggingface.co/cognitivecomputations/Dolphin3.0-Mistral-24B
196
+ [ppl]: https://github.com/ggml-org/llama.cpp/tree/master/tools/perplexity
197
+ [ppx]: https://huggingface.co/docs/transformers/en/perplexity
198
+ [qtz]: https://github.com/ggml-org/llama.cpp/tree/master/tools/quantize
199
+ [qtz-rel]: https://github.com/ggerganov/llama.cpp/releases/tag/b5125
200
+ [tst-dat]: https://huggingface.co/datasets/ikawrakow/validation-datasets-for-llama.cpp/tree/main
201
+ [tqa]: https://github.com/sylinrl/TruthfulQA
202
+ [ust]: https://huggingface.co/unsloth
203
+ [ust-ai]: https://unsloth.ai
204
+ [wng-chl]: https://cdn.aaai.org/ocs/4492/4492-21843-1-PB.pdf
205
+ [wki-dat]: https://huggingface.co/datasets/Salesforce/wikitext/tree/main/wikitext-2-raw-v1
206
+ [wng]: https://winogrande.allenai.org
207
+ [wng-tst]: https://huggingface.co/datasets/ikawrakow/winogrande-eval-for-llama.cpp/tree/main