Experimental layer-wise quantization of Salesforce/Llama-xLAM-2-8b-fc-r

Using LLaMA C++ release b5180 for quantization.

Original model: Salesforce/Llama-xLAM-2-8b-fc-r

From the original model creators:

Large Action Models (LAMs) are advanced language models designed to enhance decision-making by translating user intentions into executable actions. As the brains of AI agents, LAMs autonomously plan and execute tasks to achieve specific goals, making them invaluable for automating workflows across diverse domains. This model release is for research purposes only.

The new xLAM-2 series, built on our most advanced data synthesis, processing, and training pipelines, marks a significant leap in multi-turn conversation and tool usage. Trained using our novel APIGen-MT framework, which generates high-quality training data through simulated agent-human interactions. Our models achieve state-of-the-art performance on BFCL and τ-bench benchmarks, outperforming frontier models like GPT-4o and Claude 3.5. Notably, even our smaller models demonstrate superior capabilities in multi-turn scenarios while maintaining exceptional consistency across trials.

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'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 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 Naive Repo Shrinkage
Llama-xLAM-2-8b-fc-r-IQ3_M 3.78 3.69 2.4%
Llama-xLAM-2-8b-fc-r-IQ3_S 3.68 3.43 6.8%
Llama-xLAM-2-8b-fc-r-IQ4_NL 4.71 4.39 6.2%
Llama-xLAM-2-8b-fc-r-Q3_K_L 4.32 3.76 13.0%
Llama-xLAM-2-8b-fc-r-Q3_K_M 4.02 3.56 11.4%
Llama-xLAM-2-8b-fc-r-Q3_K_S 3.66 3.31 9.6%
Llama-xLAM-2-8b-fc-r-Q4_K_M 4.92 4.41 10.4%
Llama-xLAM-2-8b-fc-r-Q4_K_S 4.69 4.28 8.7%
Llama-xLAM-2-8b-fc-r-Q5_K_M 5.73 5.38 6.1%
Llama-xLAM-2-8b-fc-r-Q5_K_S 5.60 5.24 6.4%
Llama-xLAM-2-8b-fc-r-Q6_K 6.60 6.57 0.5%
Llama-xLAM-2-8b-fc-r-Q8_0 8.54 7.73 9.5%

Perplexity and KL Divergence scores

Model μPPL 𝜌PPL μKLD RMS Δp
Llama-xLAM-2-8b-fc-r-IQ3_M 8.471225 ±0.059374 98.14% 0.096730 ±0.000436 9.339 ±0.048
Llama-xLAM-2-8b-fc-r-IQ3_S 8.675839 ±0.060418 97.37% 0.137925 ±0.000554 11.245 ±0.051
Llama-xLAM-2-8b-fc-r-IQ4_NL 8.337503 ±0.060156 99.09% 0.047455 ±0.000243 6.280 ±0.039
Llama-xLAM-2-8b-fc-r-Q3_K_L 8.894129 ±0.063417 97.22% 0.136754 ±0.000659 11.276 ±0.057
Llama-xLAM-2-8b-fc-r-Q3_K_M 8.991141 ±0.063906 96.89% 0.152094 ±0.000706 11.870 ±0.058
Llama-xLAM-2-8b-fc-r-Q3_K_S 9.352260 ±0.066573 95.91% 0.198689 ±0.000870 13.526 ±0.061
Llama-xLAM-2-8b-fc-r-Q4_K_M 8.230419 ±0.058263 99.18% 0.041808 ±0.000219 5.988 ±0.037
Llama-xLAM-2-8b-fc-r-Q4_K_M (naive) 8.072811 ±0.057158 99.60% 0.019868 ±0.000110 4.044 ±0.029
Llama-xLAM-2-8b-fc-r-Q4_K_S 8.239495 ±0.058176 99.10% 0.045691 ±0.000240 6.262 ±0.039
Llama-xLAM-2-8b-fc-r-Q5_K_M 8.062572 ±0.057549 99.77% 0.011576 ±0.000073 3.136 ±0.025
Llama-xLAM-2-8b-fc-r-Q5_K_S 8.057947 ±0.057474 99.75% 0.012330 ±0.000075 3.210 ±0.026
Llama-xLAM-2-8b-fc-r-Q6_K 7.983587 ±0.056711 99.91% 0.004239 ±0.000034 1.912 ±0.018
Llama-xLAM-2-8b-fc-r-Q8_0 7.982215 ±0.056796 99.94% 0.002365 ±0.000026 1.449 ±0.019
Llama-xLAM-2-8b-fc-r-F16 7.968796 ±0.056714 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
Llama-xLAM-2-8b-fc-r-IQ3_M 64.6667 ±1.7466 76.67 38.5333 ±1.7783 29.6000 ±1.6680 74.5333 ±1.5919 56.80
Llama-xLAM-2-8b-fc-r-IQ3_S 60.8000 ±1.7838 72.40 38.0000 ±1.7736 30.9333 ±1.6889 72.5333 ±1.6309 54.93
Llama-xLAM-2-8b-fc-r-IQ4_NL 66.0000 ±1.7309 77.73 39.0667 ±1.7827 30.8000 ±1.6869 73.7333 ±1.6080 57.47
Llama-xLAM-2-8b-fc-r-Q3_K_L 65.0667 ±1.7420 76.67 38.6667 ±1.7794 29.6000 ±1.6680 71.6000 ±1.6477 56.32
Llama-xLAM-2-8b-fc-r-Q3_K_M 64.4000 ±1.7496 76.93 37.4667 ±1.7686 30.0000 ±1.6744 71.8667 ±1.6430 56.13
Llama-xLAM-2-8b-fc-r-Q3_K_S 61.6000 ±1.7771 75.73 38.4000 ±1.7771 30.2667 ±1.6787 72.4000 ±1.6334 55.68
Llama-xLAM-2-8b-fc-r-Q4_K_M 65.6000 ±1.7358 77.33 39.0667 ±1.7827 30.4000 ±1.6807 73.8667 ±1.6054 57.25
Llama-xLAM-2-8b-fc-r-Q4_K_M (naive) 66.2667 ±1.7276 77.47 39.6000 ±1.7870 31.2000 ±1.6929 72.5333 ±1.6309 57.41
Llama-xLAM-2-8b-fc-r-Q4_K_S 65.7333 ±1.7342 77.07 39.3333 ±1.7849 30.6667 ±1.6849 73.6000 ±1.6106 57.28
Llama-xLAM-2-8b-fc-r-Q5_K_M 66.4000 ±1.7259 78.80 39.8667 ±1.7890 32.0000 ±1.7045 74.0000 ±1.6027 58.21
Llama-xLAM-2-8b-fc-r-Q5_K_S 65.7333 ±1.7342 78.93 39.4667 ±1.7860 32.0000 ±1.7045 74.1333 ±1.6001 58.05
Llama-xLAM-2-8b-fc-r-Q6_K 65.4667 ±1.7374 78.80 39.3333 ±1.7849 32.2667 ±1.7082 73.6000 ±1.6106 57.89
Llama-xLAM-2-8b-fc-r-Q8_0 66.0000 ±1.7309 78.93 39.2000 ±1.7838 32.0000 ±1.7045 74.4000 ±1.5947 58.11
Llama-xLAM-2-8b-fc-r-F16 65.7333 ±1.7342 78.40 40.0000 ±1.7900 31.3333 ±1.6949 74.1333 ±1.6001 57.92

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
Llama-xLAM-2-8b-fc-r-Q4_K_M 4.10 GiB 8.03 B Metal,BLAS 6 pp512 314.18 ± 0.08
Llama-xLAM-2-8b-fc-r-Q4_K_M 4.10 GiB 8.03 B Metal,BLAS 6 tg128 28.09 ± 0.03
Llama-xLAM-2-8b-fc-r-Q4_K_M 4.10 GiB 8.03 B Metal,BLAS 6 pp1024+tg1024 44.57 ± 0.09
Llama-xLAM-2-8b-fc-r-Q4_K_M (naive) 4.58 GiB 8.03 B Metal,BLAS 6 pp512 327.86 ± 0.57
Llama-xLAM-2-8b-fc-r-Q4_K_M (naive) 4.58 GiB 8.03 B Metal,BLAS 6 tg128 26.15 ± 0.10
Llama-xLAM-2-8b-fc-r-Q4_K_M (naive) 4.58 GiB 8.03 B Metal,BLAS 6 pp1024+tg1024 42.97 ± 0.10

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
196
GGUF
Model size
8.03B 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/Llama-xLAM-2-8b-fc-r-GGUF

Quantized
(3)
this model

Dataset used to train eaddario/Llama-xLAM-2-8b-fc-r-GGUF