Text Generation
GGUF
English
quant
experimental
conversational

Experimental layer-wise quantization of MadeAgents/Hammer2.1-7b

Using LLaMA C++ release b5170 for quantization.

Original model: MadeAgents/Hammer2.1-7b

From the original model creators:

Hammer refers to a series of lightweight Large Action Models. Currently, we are releasing Hammer 2.1 models (0.5B, 1.5B, 3B, and 7B) with strong function calling capability. These models are based on the Qwen 2.5 coder series and utilize function masking techniques and other advanced technologies. Hammer 2.1 series bring significant enhancements, while still maintaining the basic functionality of Hammer 2.0's Single-Turn interaction and further strengthening other capabilities.

The Hammer 2.1 models, fine-tuned from the Qwen 2.5 coder series, inherit Hammer 2.0's advantages and are enhanced as follows:

  • Multi-Step Function Calling: The assistant can perform multiple internal function calls to handle a single user request, actively planning and gathering information to fulfill complex tasks.
  • Multi-Turn Function Calling: Enables continuous and context-aware interactions over multiple exchanges, with each turn potentially containing multiple steps, for a more natural conversation experience.
  • Enhanced Irrelevant Information Inspection: Better at identifying when provided functions are irrelevant to a user query, by providing a non-function call response.

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 custom versions of llama-imatrix and llama-quantize to identify the 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.

There’re two pull requests (imatrix & quantize) to merge these changes back into the core llama.cpp project. This may or may not ever happen so, until then, the modified versions will be available on GitHub.

For testing and comparison I'd normally use models produced by Unsloth (Daniel and Michael Han do some really advanced level stuff!) and 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.

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 a modified version of llama-imatrix
  5. Select an appropiate quant level for each tensor using a modified version of 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 Naive Repo Shrinkage
Hammer2.1-7b-IQ3_M 3.57 3.48 2.5%
Hammer2.1-7b-IQ3_S 3.50 3.25 7.1%
Hammer2.1-7b-IQ4_NL 4.44 4.17 6.1%
Hammer2.1-7b-Q3_K_L 4.09 3.54 13.4%
Hammer2.1-7b-Q3_K_M 3.81 3.37 11.5%
Hammer2.1-7b-Q3_K_S 3.49 3.14 10.0%
Hammer2.1-7b-Q4_K_M 4.68 4.18 10.7%
Hammer2.1-7b-Q4_K_S 4.46 4.06 9.0%
Hammer2.1-7b-Q5_K_M 5.44 5.09 6.4%
Hammer2.1-7b-Q5_K_S 5.31 4.96 6.6%
Hammer2.1-7b-Q6_K 6.25 6.23 0.3%
Hammer2.1-7b-Q8_0 8.10 7.27 10.2%

Perplexity and KL Divergence scores

Model μPPL 𝜌PPL μKLD RMS Δp
Hammer2.1-7b-IQ3_M 9.827809 ±0.071236 98.97% 0.059970 ±0.000226 6.574 ±0.032
Hammer2.1-7b-IQ3_S 9.942560 ±0.071243 98.64% 0.079935 ±0.000289 7.445 ±0.038
Hammer2.1-7b-IQ4_NL 9.585928 ±0.068060 99.51% 0.026627 ±0.000108 4.346 ±0.026
Hammer2.1-7b-Q3_K_L 10.010842 ±0.071669 98.55% 0.080230 ±0.000317 7.556 ±0.040
Hammer2.1-7b-Q3_K_M 10.109660 ±0.072549 98.44% 0.086444 ±0.000342 7.845 ±0.041
Hammer2.1-7b-Q3_K_S 10.224307 ±0.073520 98.16% 0.101951 ±0.000397 8.487 ±0.044
Hammer2.1-7b-Q4_K_M 9.513981 ±0.067589 99.56% 0.023792 ±0.000107 4.057 ±0.026
Hammer2.1-7b-Q4_K_M (naive) 9.469517 ±0.067164 99.70% 0.016770 ±0.000081 3.364 ±0.022
Hammer2.1-7b-Q4_K_S 9.529467 ±0.067693 99.53% 0.025429 ±0.000116 4.191 ±0.026
Hammer2.1-7b-Q5_K_M 9.411472 ±0.066924 99.88% 0.005881 ±0.000035 2.028 ±0.015
Hammer2.1-7b-Q5_K_S 9.410802 ±0.066883 99.88% 0.006252 ±0.000036 2.085 ±0.015
Hammer2.1-7b-Q6_K 9.384561 ±0.066615 99.96% 0.001779 ±0.000018 1.101 ±0.012
Hammer2.1-7b-Q8_0 9.379380 ±0.066571 99.98% 0.000692 ±0.000012 0.706 ±0.010
Hammer2.1-7b-F16 9.366577 ±0.066397 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
Hammer2.1-7b-IQ3_M 56.5333 ±1.8113 71.46 38.0000 ±1.7736 29.8667 ±1.6723 70.6667 ±1.6636 53.31
Hammer2.1-7b-IQ3_S 55.8667 ±1.8143 70.26 38.6667 ±1.7794 30.9333 ±1.6889 70.4000 ±1.6680 53.23
Hammer2.1-7b-IQ4_NL 57.3333 ±1.8072 71.20 38.5333 ±1.7783 30.1333 ±1.6766 69.8667 ±1.6766 53.41
Hammer2.1-7b-Q3_K_L 57.2000 ±1.8079 69.86 36.6667 ±1.7608 29.6000 ±1.6680 70.9333 ±1.6591 52.85
Hammer2.1-7b-Q3_K_M 55.7333 ±1.8149 69.87 37.2000 ±1.7661 29.8667 ±1.6723 70.4000 ±1.6680 52.61
Hammer2.1-7b-Q3_K_S 56.5333 ±1.8113 68.80 37.3333 ±1.7674 29.0667 ±1.6591 69.3333 ±1.6849 52.21
Hammer2.1-7b-Q4_K_M 57.8667 ±1.8042 71.20 38.0000 ±1.7736 29.8667 ±1.6723 69.8667 ±1.6766 53.36
Hammer2.1-7b-Q4_K_M (naive) 57.8313 ±1.8080 73.47 35.0667 ±1.7436 33.9683 ±2.6727 70.8000 ±1.6614 54.23
Hammer2.1-7b-Q4_K_S 57.8667 ±1.8042 71.07 37.8667 ±1.7724 29.6000 ±1.6680 69.6000 ±1.6807 53.20
Hammer2.1-7b-Q5_K_M 58.0000 ±1.8034 71.33 38.6667 ±1.7794 30.2667 ±1.6787 70.6667 ±1.6636 53.79
Hammer2.1-7b-Q5_K_S 58.4000 ±1.8010 71.47 38.8000 ±1.7805 30.5333 ±1.6828 70.6667 ±1.6636 53.97
Hammer2.1-7b-Q6_K 58.8000 ±1.7984 72.00 38.9333 ±1.7816 29.7333 ±1.6702 70.4000 ±1.6680 53.97
Hammer2.1-7b-Q8_0 58.5333 ±1.8002 72.00 38.9333 ±1.7816 30.1333 ±1.6766 70.2667 ±1.6702 53.97
Hammer2.1-7b-F16 58.9333 ±1.7976 72.13 39.0667 ±1.7827 30.4000 ±1.6807 70.5333 ±1.6658 54.21

Tokens per Second - Benchmarks

Scores generated using llama-bench. Naive Q4_K_M quantization included for comparison.

model size params backend threads test t/s
Hammer2.1-7b-Q4_K_M 3.89 GiB 7.61 B Metal,BLAS 6 pp512 336.11 ± 0.60
Hammer2.1-7b-Q4_K_M 3.89 GiB 7.61 B Metal,BLAS 6 tg128 29.32 ± 0.14
Hammer2.1-7b-Q4_K_M 3.89 GiB 7.61 B Metal,BLAS 6 pp1024+tg1024 48.00 ± 0.16
Hammer2.1-7b-Q4_K_M (naive) 4.35 GiB 7.61 B Metal,BLAS 6 pp512 355.08 ± 0.19
Hammer2.1-7b-Q4_K_M (naive) 4.35 GiB 7.61 B Metal,BLAS 6 tg128 28.21 ± 0.00
Hammer2.1-7b-Q4_K_M (naive) 4.35 GiB 7.61 B Metal,BLAS 6 pp1024+tg1024 45.92 ± 1.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

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

Downloads last month
701
GGUF
Model size
7.61B params
Architecture
qwen2
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/Hammer2.1-7b-GGUF

Base model

Qwen/Qwen2.5-7B
Quantized
(10)
this model

Dataset used to train eaddario/Hammer2.1-7b-GGUF