eaddario commited on
Commit
232b8f3
·
verified ·
1 Parent(s): 6de6927

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +100 -39
README.md CHANGED
@@ -11,69 +11,130 @@ pipeline_tag: text-generation
11
  tags:
12
  - gguf
13
  - quant
 
14
  ---
15
 
16
- # GGUF and "i-matrix" quantized versions of meta-llama/Llama-Guard-3-8B
17
 
18
- Using [LLaMA C++](https://github.com/ggerganov/llama.cpp) release [b4730](https://github.com/ggerganov/llama.cpp/releases/tag/b4730) for quantization.
19
 
20
  Original model: [meta-llama/Llama-Guard-3-8B](https://huggingface.co/meta-llama/Llama-Guard-3-8B)
21
 
22
  From the original model creators:
23
 
24
  > Llama Guard 3 is a Llama-3.1-8B pretrained model, fine-tuned for content safety classification. Similar to previous versions, it can be used to classify content in both LLM inputs (prompt classification) and in LLM responses (response classification). It acts as an LLM – it generates text in its output that indicates whether a given prompt or response is safe or unsafe, and if unsafe, it also lists the content categories violated.
25
- >
26
- > Llama Guard 3 was aligned to safeguard against the [MLCommons](https://mlcommons.org/) standardized hazards taxonomy and designed to support Llama 3.1 capabilities. Specifically, it provides content moderation in 8 languages, and was optimized to support safety and security for search and code interpreter tool calls.
27
 
28
- All quantized versions were generated using an appropriate imatrix created from datasets available at [eaddario/imatrix-calibration](https://huggingface.co/datasets/eaddario/imatrix-calibration).
29
 
30
- 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.
31
 
32
- The process to produce the quantized [GGUF](https://huggingface.co/docs/hub/en/gguf) models is roughly as follows:
33
 
34
- 1. Convert the the original model's safetensors into GGUF F16*
35
- 2. Estimate the Perplexity score for the F16 model (base) using [wikitext-2-raw-v1](https://huggingface.co/datasets/Salesforce/wikitext/tree/main/wikitext-2-raw-v1), and record the [logits](https://huggingface.co/eaddario/Llama-Guard-3-8B-GGUF/tree/main/logits)
36
- 3. Generate the [imatrix](https://huggingface.co/eaddario/Llama-Guard-3-8B-GGUF/tree/main/imatrix) for each calibration dataset
37
- 4. Create quantized versions of the base model using each imatrix per quant type
38
- 5. Calculate the Perplexity and KL Divergence scores for each quantized model [(scores)](https://huggingface.co/eaddario/Llama-Guard-3-8B-GGUF/tree/main/scores)
39
- 6. For each quant type, keep the version with the best (usually the lowest) scores
40
 
41
- *[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
42
 
43
- # Motivation
44
 
45
- An area of ongoing personal research is to optimize the inference performance of LLMs when deployed in resource-constrained environments like, for example, commodity hardware, personal desktops/laptops, edge devices, etc.
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
- By producing imatrix optimized quantized models, we can maintain inference efficiency whilst reducing memory size and CPU/GPU processing requirements. This optimization is crucial for deploying LLMs on devices with limited hardware capabilities, such as mobile phones or edge devices, without sacrificing significant accuracy.
 
 
 
 
 
 
 
 
50
 
51
  # Models
52
 
53
- | Filename | Quant type | Size | Perplexity (μ) | ln(PPL(Q)/PPL(base)) | KL Divergence (μ) | Description |
54
- |-----------------------------------------------------------|------------|--------|---------------------|----------------------|--------------------|--------------------------------------------------------------------------------|
55
- | [Llama-Guard-3-8B-F16](./Llama-Guard-3-8B-F16.gguf) | F16 | 16.10G | 6.554978 ±0.040159 | N/A | N/A | 16-bit standard IEEE 754 half-precision floating-point number |
56
- | [Llama-Guard-3-8B-Q8_0](./Llama-Guard-3-8B-Q8_0.gguf) | Q8_0 | 8.54G | 6.557455 ±0.040211 | 99.96% | 0.001610 ±0.000012 | Extremely high quality, generally unneeded but max available quant |
57
- | [Llama-Guard-3-8B-Q6_K](./Llama-Guard-3-8B-Q6_K.gguf) | Q6_K | 6.60G | 6.570115 ±0.040324 | 99.90% | 0.004383 ±0.000032 | Very high quality, near perfect, *recommended* |
58
- | [Llama-Guard-3-8B-Q5_K_M](./Llama-Guard-3-8B-Q5_K_M.gguf) | Q5_K_M | 5.73G | 6.611877 ±0.040700 | 99.79% | 0.009900 ±0.000071 | High quality |
59
- | [Llama-Guard-3-8B-Q5_K_S](./Llama-Guard-3-8B-Q5_K_S.gguf) | Q5_K_S | 5.60G | 7.996693 ±0.049993 | 99.76% | 0.011434 ±0.000081 | High quality, *recommended* |
60
- | [Llama-Guard-3-8B-IQ4_NL](./Llama-Guard-3-8B-IQ4_NL.gguf) | IQ4_NL | 4.68G | 6.763095 ±0.041790 | 99.26% | 0.034552 ±0.000246 | Good quality, new method (super-blocks with 256 weights), *recommended* |
61
- | [Llama-Guard-3-8B-Q4_K_M](./Llama-Guard-3-8B-Q4_K_M.gguf) | Q4_K_M | 4.92G | 6.727317 ±0.041420 | 99.40% | 0.027914 ±0.000205 | Good quality, default size for must use cases, *recommended* |
62
- | [Llama-Guard-3-8B-Q4_K_S](./Llama-Guard-3-8B-Q4_K_S.gguf) | Q4_K_S | 4.69G | 6.754714 ±0.041611 | 99.29% | 0.033124 ±0.000235 | Good quality, best choice in the Q4 series if RAM is scarce, *recommended* |
63
- | [Llama-Guard-3-8B-IQ3_M](./Llama-Guard-3-8B-IQ3_M.gguf) | IQ3_M | 3.78G | 7.296410 ±0.044494 | 97.80% | 0.103618 ±0.000568 | Medium-low quality, new method with decent performance comparable to Q3_K_M |
64
- | [Llama-Guard-3-8B-IQ3_S](./Llama-Guard-3-8B-IQ3_S.gguf) | IQ3_S | 3.68G | 7.301537 ±0.044767 | 97.66% | 0.108870 ±0.000594 | Lower quality, new method with decent performance, sligthly better than Q3_K_S |
65
- | [Llama-Guard-3-8B-Q3_K_L](./Llama-Guard-3-8B-Q3_K_L.gguf) | Q3_K_L | 4.32G | 6.983531 ±0.043462 | 98.37% | 0.071002 ±0.000463 | Lower quality but usable, good for low RAM availability |
66
- | [Llama-Guard-3-8B-Q3_K_M](./Llama-Guard-3-8B-Q3_K_M.gguf) | Q3_K_M | 4.02G | 7.058128 ±0.043917 | 98.13% | 0.082098 ±0.000506 | Medium-low quality |
67
- | [Llama-Guard-3-8B-Q3_K_S](./Llama-Guard-3-8B-Q3_K_S.gguf) | Q3_K_S | 3.66G | 7.996693 ±0.049993 | 95.62% | 0.192568 ±0.000912 | Lower quality but may be usable in certain cases |
68
-
69
- 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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  # Metrics used
 
72
 
73
- **[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.
74
 
75
- **[Kullback–Leibler (KL) Divergence](https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_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.
76
 
77
- ## Credits
 
 
78
 
79
- 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.
 
 
 
 
 
 
11
  tags:
12
  - gguf
13
  - quant
14
+ - experimental
15
  ---
16
 
17
+ # Experimental GGUF quantized versions of meta-llama/Llama-Guard-3-8B
18
 
19
+ Using [LLaMA C++](<https://github.com/ggerganov/llama.cpp>) release [b4801](<https://github.com/ggerganov/llama.cpp/releases/tag/b4801>) for quantization.
20
 
21
  Original model: [meta-llama/Llama-Guard-3-8B](https://huggingface.co/meta-llama/Llama-Guard-3-8B)
22
 
23
  From the original model creators:
24
 
25
  > Llama Guard 3 is a Llama-3.1-8B pretrained model, fine-tuned for content safety classification. Similar to previous versions, it can be used to classify content in both LLM inputs (prompt classification) and in LLM responses (response classification). It acts as an LLM – it generates text in its output that indicates whether a given prompt or response is safe or unsafe, and if unsafe, it also lists the content categories violated.
26
+ >
27
+ > Llama Guard 3 was aligned to safeguard against the MLCommons standardized hazards taxonomy and designed to support Llama 3.1 capabilities. Specifically, it provides content moderation in 8 languages, and was optimized to support safety and security for search and code interpreter tool calls.
28
 
29
+ # PLEASE READ THIS BEFORE USING THESE EXPERIMENTAL VERSIONS!
30
 
31
+ 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.
32
 
33
+ 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!).
34
 
35
+ 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!
 
 
 
 
 
36
 
37
+ 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 **8% 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.
38
 
39
+ 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 they don't provide GGUF versions of this model, so all tests and comparisons are done against naive quantizations obtained by simply running `llama-quantize` with no further optimization.
40
 
41
+ 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.
42
 
43
+ The process to generate these models is roughly as follows:
44
 
45
+ 1. Convert the the original model's tensors to [GGUF](<https://huggingface.co/docs/hub/en/gguf>) F16*
46
+ 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/Llama-Guard-3-8B-GGUF/tree/main/logits>)
47
+ 3. Generate an [imatrix](<https://huggingface.co/eaddario/Llama-Guard-3-8B-GGUF/tree/main/imatrix>) from selected calibration datasets
48
+ 4. Quantize & prune versions of the base model
49
+ 5. Calculate Perplexity, KL Divergence, ARC (Easy+Challenge), HellaSwag, MMLU, Truthful QA and WinoGrande [scores](<https://huggingface.co/eaddario/Llama-Guard-3-8B-GGUF/tree/main/scores>) for each quantized model
50
+ 6. Keep versions with the best scores
51
+ 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.
52
+
53
+ *[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
54
 
55
  # Models
56
 
57
+ ### Sizes (in GB)
58
+ | Model | Naive | Repo | Shrinkage |
59
+ |-----------------------------------------------------------|------:|-----:|----------:|
60
+ | [Llama-Guard-3-8B-IQ3_M](./Llama-Guard-3-8B-IQ3_M.gguf) | 3.78 | 3.47 | 8.2% |
61
+ | [Llama-Guard-3-8B-IQ3_S](./Llama-Guard-3-8B-IQ3_S.gguf) | 3.68 | 3.37 | 8.4% |
62
+ | [Llama-Guard-3-8B-IQ4_NL](./Llama-Guard-3-8B-IQ4_NL.gguf) | 4.68 | 4.35 | 7.1% |
63
+ | [Llama-Guard-3-8B-Q3_K_L](./Llama-Guard-3-8B-Q3_K_L.gguf) | 4.32 | 4.01 | 7.2% |
64
+ | [Llama-Guard-3-8B-Q3_K_M](./Llama-Guard-3-8B-Q3_K_M.gguf) | 4.02 | 3.70 | 8.0% |
65
+ | [Llama-Guard-3-8B-Q3_K_S](./Llama-Guard-3-8B-Q3_K_S.gguf) | 3.66 | 3.35 | 8.5% |
66
+ | [Llama-Guard-3-8B-Q4_K_M](./Llama-Guard-3-8B-Q4_K_M.gguf) | 4.92 | 4.59 | 6.7% |
67
+ | [Llama-Guard-3-8B-Q4_K_S](./Llama-Guard-3-8B-Q4_K_S.gguf) | 4.69 | 4.36 | 7.0% |
68
+ | [Llama-Guard-3-8B-Q5_K_M](./Llama-Guard-3-8B-Q5_K_M.gguf) | 5.73 | 5.34 | 6.8% |
69
+ | [Llama-Guard-3-8B-Q5_K_S](./Llama-Guard-3-8B-Q5_K_S.gguf) | 5.60 | 5.21 | 7.0% |
70
+ | [Llama-Guard-3-8B-Q6_K](./Llama-Guard-3-8B-Q6_K.gguf) | 6.60 | 6.13 | 7.1% |
71
+ | [Llama-Guard-3-8B-Q8_0](./Llama-Guard-3-8B-Q8_0.gguf) | 8.54 | 7.82 | 8.4% |
72
+
73
+ ### Perplexity and KL Divergence scores
74
+ | Model | μPPL | 𝜌PPL | μKLD | RMS Δp |
75
+ |-----------------------------------------------------------|--------------------:|-------:|-------------------:|--------------:|
76
+ | [Llama-Guard-3-8B-IQ3_M](./Llama-Guard-3-8B-IQ3_M.gguf) | 8.238324 ±0.051597 | 95.64% | 0.223382 ±0.000737 | 14.820 ±0.056 |
77
+ | [Llama-Guard-3-8B-IQ3_S](./Llama-Guard-3-8B-IQ3_S.gguf) | 8.262126 ±0.052116 | 95.48% | 0.228988 ±0.000778 | 14.837 ±0.057 |
78
+ | [Llama-Guard-3-8B-IQ4_NL](./Llama-Guard-3-8B-IQ4_NL.gguf) | 7.003106 ±0.043412 | 98.57% | 0.069975 ±0.000336 | 7.869 ±0.046 |
79
+ | [Llama-Guard-3-8B-Q3_K_L](./Llama-Guard-3-8B-Q3_K_L.gguf) | 7.825878 ±0.050018 | 96.39% | 0.181845 ±0.000636 | 12.836 ±0.052 |
80
+ | [Llama-Guard-3-8B-Q3_K_M](./Llama-Guard-3-8B-Q3_K_M.gguf) | 7.911577 ±0.050533 | 96.13% | 0.194188 ±0.000679 | 13.302 ±0.054 |
81
+ | [Llama-Guard-3-8B-Q3_K_S](./Llama-Guard-3-8B-Q3_K_S.gguf) | 9.042611 ±0.058114 | 93.39% | 0.314022 ±0.001100 | 17.945 ±0.066 |
82
+ | [Llama-Guard-3-8B-Q4_K_M](./Llama-Guard-3-8B-Q4_K_M.gguf) | 6.961140 ±0.043016 | 98.70% | 0.063448 ±0.000302 | 7.468 ±0.043 |
83
+ | [Llama-Guard-3-8B-Q4_K_S](./Llama-Guard-3-8B-Q4_K_S.gguf) | 6.985735 ±0.043183 | 98.61% | 0.068174 ±0.000323 | 7.787 ±0.044 |
84
+ | [Llama-Guard-3-8B-Q5_K_M](./Llama-Guard-3-8B-Q5_K_M.gguf) | 6.843617 ±0.042247 | 99.08% | 0.045866 ±0.000199 | 6.306 ±0.034 |
85
+ | [Llama-Guard-3-8B-Q5_K_S](./Llama-Guard-3-8B-Q5_K_S.gguf) | 6.849948 ±0.042246 | 99.07% | 0.046677 ±0.000201 | 6.388 ±0.034 |
86
+ | [Llama-Guard-3-8B-Q6_K](./Llama-Guard-3-8B-Q6_K.gguf) | 6.810479 ±0.041963 | 99.17% | 0.041612 ±0.000183 | 5.976 ±0.031 |
87
+ | [Llama-Guard-3-8B-Q8_0](./Llama-Guard-3-8B-Q8_0.gguf) | 6.796496 ±0.041835 | 99.23% | 0.039114 ±0.000160 | 5.806 ±0.029 |
88
+ | [Llama-Guard-3-8B-F16](./Llama-Guard-3-8B-F16.gguf) | 6.554978 ±0.040159 | 100% | N/A | N/A |
89
+
90
+ ### ARC, HellaSwag, MMLU, Truthful QA and WinoGrande scores
91
+ 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.
92
+
93
+ 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>)
94
+
95
+ | Model | ARC | HellaSwag | MMLU | Truthful QA | WinoGrande |
96
+ |-----------------------------------------------------------|----------------:|----------:|----------------:|----------------:|----------------:|
97
+ | [Llama-Guard-3-8B-IQ3_M](./Llama-Guard-3-8B-IQ3_M.gguf) | 60.2667 ±1.7880 | 79.07 | 38.5333 ±1.7783 | 32.1333 ±1.7063 | 72.9333 ±1.6235 |
98
+ | [Llama-Guard-3-8B-IQ3_S](./Llama-Guard-3-8B-IQ3_S.gguf) | 62.0000 ±1.7736 | 78.40 | 37.7333 ±1.7711 | 32.4000 ±1.7100 | 73.2000 ±1.6184 |
99
+ | [Llama-Guard-3-8B-IQ4_NL](./Llama-Guard-3-8B-IQ4_NL.gguf) | 66.5333 ±1.7242 | 81.47 | 37.3333 ±1.7674 | 34.2667 ±1.7342 | 72.6667 ±1.6284 |
100
+ | [Llama-Guard-3-8B-Q3_K_L](./Llama-Guard-3-8B-Q3_K_L.gguf) | 62.8000 ±1.7661 | 77.46 | 38.5333 ±1.7783 | 30.6667 ±1.6849 | 73.4667 ±1.6132 |
101
+ | [Llama-Guard-3-8B-Q3_K_M](./Llama-Guard-3-8B-Q3_K_M.gguf) | 62.9333 ±1.7648 | 78.00 | 38.8000 ±1.7805 | 31.2000 ±1.6929 | 72.5333 ±1.6309 |
102
+ | [Llama-Guard-3-8B-Q3_K_S](./Llama-Guard-3-8B-Q3_K_S.gguf) | 59.3333 ±1.7948 | 77.87 | 36.9333 ±1.7635 | 32.5333 ±1.7119 | 73.3333 ±1.6158 |
103
+ | [Llama-Guard-3-8B-Q4_K_M](./Llama-Guard-3-8B-Q4_K_M.gguf) | 64.1333 ±1.7525 | 81.47 | 38.0000 ±1.7736 | 33.6000 ±1.7259 | 72.4000 ±1.6334 |
104
+ | Llama-Guard-3-8B-Q4_K_M (Naive) | 66.0000 ±1.7309 | 80.67 | 38.5333 ±1.7783 | 31.6000 ±1.6988 | 72.2667 ±1.6358 |
105
+ | [Llama-Guard-3-8B-Q4_K_S](./Llama-Guard-3-8B-Q4_K_S.gguf) | 64.4000 ±1.7496 | 81.73 | 37.6000 ±1.7699 | 32.5333 ±1.7119 | 72.6667 ±1.6284 |
106
+ | [Llama-Guard-3-8B-Q5_K_M](./Llama-Guard-3-8B-Q5_K_M.gguf) | 66.4000 ±1.7259 | 81.47 | 38.5333 ±1.7783 | 33.4667 ±1.7242 | 73.2000 ±1.6184 |
107
+ | [Llama-Guard-3-8B-Q5_K_S](./Llama-Guard-3-8B-Q5_K_S.gguf) | 65.7333 ±1.7342 | 81.33 | 38.2667 ±1.7759 | 33.0667 ±1.7190 | 73.4667 ±1.6132 |
108
+ | [Llama-Guard-3-8B-Q6_K](./Llama-Guard-3-8B-Q6_K.gguf) | 66.9333 ±1.7190 | 82.00 | 38.5333 ±1.7783 | 33.7333 ±1.7276 | 73.4667 ±1.6132 |
109
+ | [Llama-Guard-3-8B-Q8_0](./Llama-Guard-3-8B-Q8_0.gguf) | 66.0000 ±1.7309 | 81.73 | 37.8667 ±1.7724 | 33.0667 ±1.7190 | 73.7333 ±1.6080 |
110
+ | [Llama-Guard-3-8B-F16](./Llama-Guard-3-8B-F16.gguf) | 64.9333 ±1.7436 | 81.60 | 38.1333 ±1.7748 | 30.6667 ±1.6849 | 72.8000 ±1.6260 |
111
+
112
+ ### Tokens per Second - Benchmarks
113
+ 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.
114
+
115
+ | model | size | params | backend | threads | test | t/s |
116
+ | --------------------------------------------------------- | -------: | -----: | ---------- | ------: | ------------: | ------------: |
117
+ | [Llama-Guard-3-8B-Q4_K_M](./Llama-Guard-3-8B-Q4_K_M.gguf) | 4.27 GiB | 8.03 B | Metal,BLAS | 6 | pp512 | 329.11 ± 0.74 |
118
+ | [Llama-Guard-3-8B-Q4_K_M](./Llama-Guard-3-8B-Q4_K_M.gguf) | 4.27 GiB | 8.03 B | Metal,BLAS | 6 | tg128 | 26.59 ± 0.18 |
119
+ | [Llama-Guard-3-8B-Q4_K_M](./Llama-Guard-3-8B-Q4_K_M.gguf) | 4.27 GiB | 8.03 B | Metal,BLAS | 6 | pp1024+tg1024 | 43.28 ± 0.14 |
120
+ | Llama-Guard-3-8B-Q4_K_M (Naive) | 4.58 GiB | 8.03 B | Metal,BLAS | 6 | pp512 | 326.68 ± 5.05 |
121
+ | Llama-Guard-3-8B-Q4_K_M (Naive) | 4.58 GiB | 8.03 B | Metal,BLAS | 6 | tg128 | 26.29 ± 0.30 |
122
+ | Llama-Guard-3-8B-Q4_K_M (Naive) | 4.58 GiB | 8.03 B | Metal,BLAS | 6 | pp1024+tg1024 | 43.14 ± 0.22 |
123
 
124
  # Metrics used
125
+ **[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.
126
 
127
+ **[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.
128
 
129
+ **[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.
130
 
131
+ **[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.
132
+
133
+ **[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.
134
 
135
+ **[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.
136
+
137
+ **[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.
138
+
139
+ ## Credits
140
+ 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.