Instructions to use KikoCis/salamandra-7b-instruct-2606-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use KikoCis/salamandra-7b-instruct-2606-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="KikoCis/salamandra-7b-instruct-2606-GGUF", filename="salamandra-7b-IQ4_XS.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use KikoCis/salamandra-7b-instruct-2606-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf KikoCis/salamandra-7b-instruct-2606-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf KikoCis/salamandra-7b-instruct-2606-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf KikoCis/salamandra-7b-instruct-2606-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf KikoCis/salamandra-7b-instruct-2606-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf KikoCis/salamandra-7b-instruct-2606-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf KikoCis/salamandra-7b-instruct-2606-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf KikoCis/salamandra-7b-instruct-2606-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf KikoCis/salamandra-7b-instruct-2606-GGUF:Q4_K_M
Use Docker
docker model run hf.co/KikoCis/salamandra-7b-instruct-2606-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use KikoCis/salamandra-7b-instruct-2606-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "KikoCis/salamandra-7b-instruct-2606-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "KikoCis/salamandra-7b-instruct-2606-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/KikoCis/salamandra-7b-instruct-2606-GGUF:Q4_K_M
- Ollama
How to use KikoCis/salamandra-7b-instruct-2606-GGUF with Ollama:
ollama run hf.co/KikoCis/salamandra-7b-instruct-2606-GGUF:Q4_K_M
- Unsloth Studio
How to use KikoCis/salamandra-7b-instruct-2606-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for KikoCis/salamandra-7b-instruct-2606-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for KikoCis/salamandra-7b-instruct-2606-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for KikoCis/salamandra-7b-instruct-2606-GGUF to start chatting
- Atomic Chat new
- Docker Model Runner
How to use KikoCis/salamandra-7b-instruct-2606-GGUF with Docker Model Runner:
docker model run hf.co/KikoCis/salamandra-7b-instruct-2606-GGUF:Q4_K_M
- Lemonade
How to use KikoCis/salamandra-7b-instruct-2606-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull KikoCis/salamandra-7b-instruct-2606-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.salamandra-7b-instruct-2606-GGUF-Q4_K_M
List all available models
lemonade list
salamandra-7b GGUF ladder (imatrix es) + KLD/PPL/Top-1 fidelity metrics + charts
Browse files- .gitattributes +6 -0
- Modelfile.4096 +6 -0
- Modelfile.8192 +6 -0
- README.md +135 -0
- metrics/chart-ppl-delta.png +0 -0
- metrics/chart-quality-vs-size.png +0 -0
- metrics/chart-top1-match.png +0 -0
- metrics/quant-summary-with-kld.csv +7 -0
- metrics/quant-summary-with-kld.json +80 -0
- reports/artifact-sha256sums.txt +8 -0
- salamandra-7b-IQ4_XS.gguf +3 -0
- salamandra-7b-Q3_K_M.gguf +3 -0
- salamandra-7b-Q4_K_M.gguf +3 -0
- salamandra-7b-Q5_K_M.gguf +3 -0
- salamandra-7b-Q6_K.gguf +3 -0
- salamandra-7b-Q8_0.gguf +3 -0
- scripts/kld_sweep.py +61 -0
- scripts/make_charts.py +27 -0
- scripts/reproduce.sh +10 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
salamandra-7b-IQ4_XS.gguf filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
salamandra-7b-Q3_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
salamandra-7b-Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
salamandra-7b-Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
salamandra-7b-Q6_K.gguf filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
salamandra-7b-Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
|
Modelfile.4096
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM ./salamandra-7b-Q4_K_M.gguf
|
| 2 |
+
PARAMETER num_ctx 4096
|
| 3 |
+
PARAMETER temperature 0.7
|
| 4 |
+
PARAMETER top_p 0.95
|
| 5 |
+
PARAMETER top_k 40
|
| 6 |
+
PARAMETER repeat_penalty 1.1
|
Modelfile.8192
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM ./salamandra-7b-Q4_K_M.gguf
|
| 2 |
+
PARAMETER num_ctx 8192
|
| 3 |
+
PARAMETER temperature 0.7
|
| 4 |
+
PARAMETER top_p 0.95
|
| 5 |
+
PARAMETER top_k 40
|
| 6 |
+
PARAMETER repeat_penalty 1.1
|
README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: BSC-LT/salamandra-7b-instruct-2606
|
| 4 |
+
base_model_relation: quantized
|
| 5 |
+
language:
|
| 6 |
+
- es
|
| 7 |
+
- ca
|
| 8 |
+
- gl
|
| 9 |
+
- eu
|
| 10 |
+
- en
|
| 11 |
+
pipeline_tag: text-generation
|
| 12 |
+
tags:
|
| 13 |
+
- gguf
|
| 14 |
+
- llama.cpp
|
| 15 |
+
- quantized
|
| 16 |
+
- imatrix
|
| 17 |
+
- spanish
|
| 18 |
+
- salamandra
|
| 19 |
+
- bsc
|
| 20 |
+
library_name: gguf
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
<div align="center">
|
| 24 |
+
|
| 25 |
+
```
|
| 26 |
+
╔══════════════════════════════════════════════════════════════╗
|
| 27 |
+
║ S A L A M A N D R A · 7 B · I N S T R U C T · 2 6 0 6 ║
|
| 28 |
+
║ ─────────────────────────────────────────────────────── ║
|
| 29 |
+
║ GGUF quant ladder · imatrix (calibrado en español) ║
|
| 30 |
+
║ Q3 ▸ IQ4 ▸ Q4 ▸ Q5 ▸ Q6 ▸ Q8 · fidelidad medida (KLD) ║
|
| 31 |
+
╚══════════════════════════════════════════════════════════════╝
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
# Salamandra-7B-Instruct-2606 · GGUF
|
| 35 |
+
|
| 36 |
+
**Cuantizaciones GGUF con imatrix del modelo soberano español/europeo de BSC-LT.**
|
| 37 |
+
Escalera completa Q3→Q8 · matriz de importancia calibrada **en español** · fidelidad objetiva **medida contra el BF16** (KLD + PPL + Top-1).
|
| 38 |
+
|
| 39 |
+
</div>
|
| 40 |
+
|
| 41 |
+
> **Qué es esto**: [BSC-LT/salamandra-7b-instruct-2606](https://huggingface.co/BSC-LT/salamandra-7b-instruct-2606) —
|
| 42 |
+
> el modelo multilingüe (ES · CA · GL · EU · EN…) del Barcelona Supercomputing Center— empaquetado en GGUF para
|
| 43 |
+
> correr en local con `llama.cpp` / Ollama. **No es un modelo de código**: su valor es lingüístico y de soberanía,
|
| 44 |
+
> así que aquí lo importante es que **la cuantización no rompa el modelo** — y eso se demuestra con la tabla de fidelidad de abajo, no con un benchmark de programación.
|
| 45 |
+
|
| 46 |
+
## ✅ Qué archivo elegir
|
| 47 |
+
|
| 48 |
+
| Si quieres… | Usa | Por qué |
|
| 49 |
+
|---|---|---|
|
| 50 |
+
| **Lo mejor equilibrado** | **Q4_K_M** (4.5 GB) | el estándar seguro — cabe en 8 GB, buena fidelidad |
|
| 51 |
+
| Máxima calidad práctica | **Q6_K** (6.0 GB) | KLD 0.004, casi indistinguible del original |
|
| 52 |
+
| Fidelidad de archivo | **Q8_0** (7.7 GB) | prácticamente sin pérdida (Top-1 98.9%) |
|
| 53 |
+
| Lo más pequeño usable | **Q3_K_M** (3.8 GB) | para RAM muy justa; algo de deriva |
|
| 54 |
+
| Compacto con imatrix | **IQ4_XS** (4.2 GB) | más pequeño que Q4_K_M, fidelidad parecida |
|
| 55 |
+
|
| 56 |
+
## 📦 Archivos
|
| 57 |
+
|
| 58 |
+
| Quant | Bits (aprox) | Tamaño |
|
| 59 |
+
|---|---|---|
|
| 60 |
+
| `salamandra-7b-Q3_K_M.gguf` | ~3.9 | 3.8 GB |
|
| 61 |
+
| `salamandra-7b-IQ4_XS.gguf` | ~4.25 | 4.2 GB |
|
| 62 |
+
| `salamandra-7b-Q4_K_M.gguf` | ~4.8 | 4.5 GB |
|
| 63 |
+
| `salamandra-7b-Q5_K_M.gguf` | ~5.6 | 5.2 GB |
|
| 64 |
+
| `salamandra-7b-Q6_K.gguf` | ~6.5 | 6.0 GB |
|
| 65 |
+
| `salamandra-7b-Q8_0.gguf` | ~8.5 | 7.7 GB |
|
| 66 |
+
|
| 67 |
+
## 📊 Fidelidad medida (vs BF16 · corpus español)
|
| 68 |
+
|
| 69 |
+
**KLD** (divergencia Kullback–Leibler) mide cuánto se aleja la distribución de salida de cada cuantización respecto al modelo original en BF16 — es el patrón oro de fidelidad de cuantización, más fino que la perplejidad sola. **Top-1** = con qué frecuencia el token más probable coincide con el del BF16.
|
| 70 |
+
|
| 71 |
+
| Quant | Tamaño | PPL (es) | PPL Δ vs BF16 | **KLD media** | Top-1 vs BF16 |
|
| 72 |
+
|---|---|---|---|---|---|
|
| 73 |
+
| BF16 (ref) | 14.8 GB | 7.437 | — | 0 | 100% |
|
| 74 |
+
| Q8_0 | 7.7 GB | 7.437 | **+0.0002** | **0.00043** | **98.9%** |
|
| 75 |
+
| Q6_K | 6.0 GB | 7.460 | +0.023 | 0.00376 | 96.8% |
|
| 76 |
+
| Q5_K_M | 5.2 GB | 7.485 | +0.048 | 0.00865 | 95.3% |
|
| 77 |
+
| Q4_K_M | 4.5 GB | 7.611 | +0.174 | 0.02808 | 91.9% |
|
| 78 |
+
| IQ4_XS | 4.2 GB | 7.705 | +0.268 | 0.03421 | 91.3% |
|
| 79 |
+
| Q3_K_M | 3.8 GB | 8.117 | +0.680 | 0.08682 | 86.1% |
|
| 80 |
+
|
| 81 |
+
## 📈 Gráficas
|
| 82 |
+
|
| 83 |
+

|
| 84 |
+

|
| 85 |
+

|
| 86 |
+
|
| 87 |
+
## 🧮 ¿Me cabe? (RAM aproximada, contexto 8K)
|
| 88 |
+
|
| 89 |
+
| Quant | RAM mínima |
|
| 90 |
+
|---|---|
|
| 91 |
+
| Q3_K_M / IQ4_XS | ~6 GB |
|
| 92 |
+
| Q4_K_M / Q5_K_M | ~7–8 GB |
|
| 93 |
+
| Q6_K / Q8_0 | ~8–10 GB |
|
| 94 |
+
|
| 95 |
+
## 🚀 Cómo ejecutarlo
|
| 96 |
+
|
| 97 |
+
**Ollama** (usa la plantilla ChatML que ya trae el GGUF):
|
| 98 |
+
```bash
|
| 99 |
+
ollama create salamandra7b -f Modelfile.8192
|
| 100 |
+
ollama run salamandra7b "Explica la fotosíntesis en una frase."
|
| 101 |
+
```
|
| 102 |
+
**llama.cpp**:
|
| 103 |
+
```bash
|
| 104 |
+
llama-cli -m salamandra-7b-Q4_K_M.gguf -ngl 99 -c 8192 \
|
| 105 |
+
-p "<|im_start|>user\n¿Cuál es la capital de Galicia?<|im_end|>\n<|im_start|>assistant\n"
|
| 106 |
+
```
|
| 107 |
+
Muestreo recomendado: `temp 0.7 · top_p 0.95 · top_k 40`. Contexto nativo **8192**.
|
| 108 |
+
|
| 109 |
+
## ⚠️ Bueno saber
|
| 110 |
+
|
| 111 |
+
- **Es un modelo lingüístico, no de código.** Brilla en español y lenguas cooficiales (catalán, gallego, euskera) y multilingüe; no esperes rendimiento de un modelo especializado en programación.
|
| 112 |
+
- **Gate de calidad = fidelidad, no SWE.** Para una cuantización de un modelo así, lo que importa es que se parezca al original (KLD arriba), no un test de coding que sería ~0 por diseño del modelo base.
|
| 113 |
+
- **imatrix en español**: la matriz de importancia se calibró con prosa española, no inglesa — evita la deriva que introduce calibrar en el idioma equivocado.
|
| 114 |
+
|
| 115 |
+
## 🔁 Procedencia y reproducibilidad
|
| 116 |
+
|
| 117 |
+
- **Base**: `BSC-LT/salamandra-7b-instruct-2606` · arquitectura Llama · licencia Apache-2.0.
|
| 118 |
+
- **imatrix**: corpus en español, `-c 512`, sobre el BF16.
|
| 119 |
+
- **Ladder**: `llama-quantize --imatrix` para cada tier. Magic verificado en cada `.gguf`.
|
| 120 |
+
- **Fidelidad**: `llama-perplexity --kl-divergence` contra base BF16 (`kld.dat`) + PPL en español.
|
| 121 |
+
- Comandos exactos en `scripts/reproduce.sh`; métricas en `metrics/quant-summary-with-kld.{json,csv}`; checksums en `reports/artifact-sha256sums.txt`.
|
| 122 |
+
|
| 123 |
+
## Evaluation methodology
|
| 124 |
+
|
| 125 |
+
- **Métrica**: KLD (mean/max) + Top-1 match + PPL, cada cuantización vs la referencia BF16, sobre un corpus **español**. Sin gate SWE — no aplica a un modelo lingüístico no-coder (sería 0 por diseño, no por la cuantización).
|
| 126 |
+
- **Herramientas**: `llama.cpp` (`llama-imatrix`, `llama-quantize`, `llama-perplexity --kl-divergence`).
|
| 127 |
+
- **Fecha**: 2026-07. Caveat: PPL/KLD sobre un corpus acotado; comparativa relativa entre tiers, no un ranking absoluto.
|
| 128 |
+
|
| 129 |
+
## 🗒️ Changelog
|
| 130 |
+
|
| 131 |
+
- **2026-07** — release inicial: escalera Q3→Q8 + IQ4_XS, imatrix español, tabla KLD/PPL/Top-1 + gráficas.
|
| 132 |
+
|
| 133 |
+
---
|
| 134 |
+
|
| 135 |
+
Cuantizado por **KikoCis**. Modelo base © Barcelona Supercomputing Center (BSC-LT), Apache-2.0. Todo el mérito del modelo es de BSC-LT; aquí solo se empaqueta y se mide la fidelidad de las cuantizaciones.
|
metrics/chart-ppl-delta.png
ADDED
|
metrics/chart-quality-vs-size.png
ADDED
|
metrics/chart-top1-match.png
ADDED
|
metrics/quant-summary-with-kld.csv
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name,size_bytes,size_gb_decimal,kld_nats_mean,kld_nats_max,kld_nats_p95,kld_nats_p50,top1_match_rate,ppl_c512,ppl_delta_vs_bf16
|
| 2 |
+
Q3_K_M,4047942752,4.05,0.08682,9.011917,0.728921,0.043465,86.063,8.1171,0.6803
|
| 3 |
+
IQ4_XS,4458263648,4.46,0.03421,5.305482,0.287807,0.017275,91.255,7.7047,0.2679
|
| 4 |
+
Q4_K_M,4850562144,4.85,0.028081,21.190672,0.22577,0.014207,91.93,7.6111,0.1743
|
| 5 |
+
Q5_K_M,5591905376,5.59,0.008646,1.567585,0.069664,0.00456,95.298,7.4848,0.048
|
| 6 |
+
Q6_K,6379582560,6.38,0.003758,0.422751,0.029011,0.002122,96.811,7.4601,0.0233
|
| 7 |
+
Q8_0,8260858976,8.26,0.000433,0.519766,0.003259,0.000223,98.88,7.437,0.0002
|
metrics/quant-summary-with-kld.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": "salamandra-7b-instruct-2606",
|
| 3 |
+
"ref": "BF16",
|
| 4 |
+
"ref_ppl": 7.4368,
|
| 5 |
+
"corpus": "es",
|
| 6 |
+
"rows": [
|
| 7 |
+
{
|
| 8 |
+
"name": "Q3_K_M",
|
| 9 |
+
"size_bytes": 4047942752,
|
| 10 |
+
"size_gb_decimal": 4.05,
|
| 11 |
+
"kld_nats_mean": 0.08682,
|
| 12 |
+
"kld_nats_max": 9.011917,
|
| 13 |
+
"kld_nats_p95": 0.728921,
|
| 14 |
+
"kld_nats_p50": 0.043465,
|
| 15 |
+
"top1_match_rate": 86.063,
|
| 16 |
+
"ppl_c512": 8.1171,
|
| 17 |
+
"ppl_delta_vs_bf16": 0.6803
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"name": "IQ4_XS",
|
| 21 |
+
"size_bytes": 4458263648,
|
| 22 |
+
"size_gb_decimal": 4.46,
|
| 23 |
+
"kld_nats_mean": 0.03421,
|
| 24 |
+
"kld_nats_max": 5.305482,
|
| 25 |
+
"kld_nats_p95": 0.287807,
|
| 26 |
+
"kld_nats_p50": 0.017275,
|
| 27 |
+
"top1_match_rate": 91.255,
|
| 28 |
+
"ppl_c512": 7.7047,
|
| 29 |
+
"ppl_delta_vs_bf16": 0.2679
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"name": "Q4_K_M",
|
| 33 |
+
"size_bytes": 4850562144,
|
| 34 |
+
"size_gb_decimal": 4.85,
|
| 35 |
+
"kld_nats_mean": 0.028081,
|
| 36 |
+
"kld_nats_max": 21.190672,
|
| 37 |
+
"kld_nats_p95": 0.22577,
|
| 38 |
+
"kld_nats_p50": 0.014207,
|
| 39 |
+
"top1_match_rate": 91.93,
|
| 40 |
+
"ppl_c512": 7.6111,
|
| 41 |
+
"ppl_delta_vs_bf16": 0.1743
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
"name": "Q5_K_M",
|
| 45 |
+
"size_bytes": 5591905376,
|
| 46 |
+
"size_gb_decimal": 5.59,
|
| 47 |
+
"kld_nats_mean": 0.008646,
|
| 48 |
+
"kld_nats_max": 1.567585,
|
| 49 |
+
"kld_nats_p95": 0.069664,
|
| 50 |
+
"kld_nats_p50": 0.00456,
|
| 51 |
+
"top1_match_rate": 95.298,
|
| 52 |
+
"ppl_c512": 7.4848,
|
| 53 |
+
"ppl_delta_vs_bf16": 0.048
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"name": "Q6_K",
|
| 57 |
+
"size_bytes": 6379582560,
|
| 58 |
+
"size_gb_decimal": 6.38,
|
| 59 |
+
"kld_nats_mean": 0.003758,
|
| 60 |
+
"kld_nats_max": 0.422751,
|
| 61 |
+
"kld_nats_p95": 0.029011,
|
| 62 |
+
"kld_nats_p50": 0.002122,
|
| 63 |
+
"top1_match_rate": 96.811,
|
| 64 |
+
"ppl_c512": 7.4601,
|
| 65 |
+
"ppl_delta_vs_bf16": 0.0233
|
| 66 |
+
},
|
| 67 |
+
{
|
| 68 |
+
"name": "Q8_0",
|
| 69 |
+
"size_bytes": 8260858976,
|
| 70 |
+
"size_gb_decimal": 8.26,
|
| 71 |
+
"kld_nats_mean": 0.000433,
|
| 72 |
+
"kld_nats_max": 0.519766,
|
| 73 |
+
"kld_nats_p95": 0.003259,
|
| 74 |
+
"kld_nats_p50": 0.000223,
|
| 75 |
+
"top1_match_rate": 98.88,
|
| 76 |
+
"ppl_c512": 7.437,
|
| 77 |
+
"ppl_delta_vs_bf16": 0.0002
|
| 78 |
+
}
|
| 79 |
+
]
|
| 80 |
+
}
|
reports/artifact-sha256sums.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
7a775454cdb1be9fc3ac4c4c51ef4691ba474867d283b95b268fcac14d853c8a salamandra-7b-Q3_K_M.gguf
|
| 2 |
+
0643c080734e33486f0f10bd721b502e33b1eeaf5a0a1dd754c7466dd36f6c2d salamandra-7b-Q4_K_M.gguf
|
| 3 |
+
0d9ba4318e8c73c46d729ac62b9a65897ad57a22918545b39b64cb9d7db324e5 salamandra-7b-Q5_K_M.gguf
|
| 4 |
+
8837ea5c00cbb6bbb3ae3775a5cdc5369c32e1aa7b59a961a6c2a1ecfd87f8b0 salamandra-7b-Q6_K.gguf
|
| 5 |
+
f49e470cec70107b2d173fe05ccfad630d27876758328ce90762626e9eb96bd8 salamandra-7b-Q8_0.gguf
|
| 6 |
+
61c60dd48df883b8ad3ae05ed0f1fbf4327f9e07879f1d54ac3cf2bc959456ae salamandra-7b-IQ4_XS.gguf
|
| 7 |
+
efe8ce6a43d37f787b5de5bc46e9bd9b21eb81842b97738f84f00f331e99bc56 metrics/quant-summary-with-kld.json
|
| 8 |
+
3954710b67300253ce5c8ecb5491b30a32d5df18b82170b4b80f3618d70d6406 metrics/quant-summary-with-kld.csv
|
salamandra-7b-IQ4_XS.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:61c60dd48df883b8ad3ae05ed0f1fbf4327f9e07879f1d54ac3cf2bc959456ae
|
| 3 |
+
size 4458263648
|
salamandra-7b-Q3_K_M.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7a775454cdb1be9fc3ac4c4c51ef4691ba474867d283b95b268fcac14d853c8a
|
| 3 |
+
size 4047942752
|
salamandra-7b-Q4_K_M.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0643c080734e33486f0f10bd721b502e33b1eeaf5a0a1dd754c7466dd36f6c2d
|
| 3 |
+
size 4850562144
|
salamandra-7b-Q5_K_M.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0d9ba4318e8c73c46d729ac62b9a65897ad57a22918545b39b64cb9d7db324e5
|
| 3 |
+
size 5591905376
|
salamandra-7b-Q6_K.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8837ea5c00cbb6bbb3ae3775a5cdc5369c32e1aa7b59a961a6c2a1ecfd87f8b0
|
| 3 |
+
size 6379582560
|
salamandra-7b-Q8_0.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f49e470cec70107b2d173fe05ccfad630d27876758328ce90762626e9eb96bd8
|
| 3 |
+
size 8260858976
|
scripts/kld_sweep.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""KLD + PPL + Top-1 sweep for the salamandra-7b quant ladder vs the BF16 reference.
|
| 3 |
+
Waits for the ladder, builds the KLD base from BF16, then per-quant measures KLD (mean/p50/p95/max,
|
| 4 |
+
nats) + Top-1 match rate + PPL (Spanish corpus). Writes metrics/quant-summary-with-kld.{json,csv}.
|
| 5 |
+
"""
|
| 6 |
+
import os, re, json, csv, time, subprocess, glob
|
| 7 |
+
D = "/Users/kikocisneros/coco_ppl/aq_salamandra7b"
|
| 8 |
+
REF = f"{D}/salamandra-7b-BF16.gguf"
|
| 9 |
+
CORPUS = f"{D}/es_prose.txt" # Spanish (model's language)
|
| 10 |
+
KLDBASE = f"{D}/kld.dat"
|
| 11 |
+
METR = f"{D}/metrics"; os.makedirs(METR, exist_ok=True)
|
| 12 |
+
CTX = "512"; LADDER = ["Q3_K_M", "IQ4_XS", "Q4_K_M", "Q5_K_M", "Q6_K", "Q8_0"]
|
| 13 |
+
|
| 14 |
+
def log(m): print(f"[kld {time.strftime('%H:%M:%S')}] {m}", flush=True)
|
| 15 |
+
def sh(cmd):
|
| 16 |
+
p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
|
| 17 |
+
return p.stdout
|
| 18 |
+
|
| 19 |
+
def gnum(pat, text, d=float("nan")):
|
| 20 |
+
m = re.search(pat, text)
|
| 21 |
+
return float(m.group(1)) if m else d
|
| 22 |
+
|
| 23 |
+
# wait for ladder
|
| 24 |
+
while not os.path.exists(f"{D}/salamandra-7b-Q8_0.gguf") or subprocess.run(["pgrep","-f","llama-quantize"],capture_output=True).returncode==0:
|
| 25 |
+
time.sleep(8)
|
| 26 |
+
log("ladder present; building KLD base from BF16")
|
| 27 |
+
sh(["llama-perplexity","-m",REF,"-f",CORPUS,"-c",CTX,"--kl-divergence-base",KLDBASE,"-ngl","99"])
|
| 28 |
+
log("KLD base built")
|
| 29 |
+
|
| 30 |
+
rows = []
|
| 31 |
+
for Q in LADDER:
|
| 32 |
+
g = f"{D}/salamandra-7b-{Q}.gguf"
|
| 33 |
+
if not os.path.exists(g): log(f"skip {Q} (missing)"); continue
|
| 34 |
+
size = os.path.getsize(g)
|
| 35 |
+
log(f"KLD {Q}")
|
| 36 |
+
kld = sh(["llama-perplexity","-m",g,"--kl-divergence-base",KLDBASE,"--kl-divergence","-ngl","99"])
|
| 37 |
+
log(f"PPL {Q}")
|
| 38 |
+
ppl = sh(["llama-perplexity","-m",g,"-f",CORPUS,"-c",CTX,"-ngl","99"])
|
| 39 |
+
row = {
|
| 40 |
+
"name": Q, "size_bytes": size, "size_gb_decimal": round(size/1e9, 2),
|
| 41 |
+
"kld_nats_mean": gnum(r"[Mm]ean\s+KLD\s*[:=]\s*([0-9.eE-]+)", kld),
|
| 42 |
+
"kld_nats_max": gnum(r"[Mm]ax(?:imum)?\s+KLD\s*[:=]\s*([0-9.eE-]+)", kld),
|
| 43 |
+
"kld_nats_p95": gnum(r"99\.0%\s+KLD\s*[:=]\s*([0-9.eE-]+)", kld),
|
| 44 |
+
"kld_nats_p50": gnum(r"[Mm]edian\s+KLD\s*[:=]\s*([0-9.eE-]+)", kld),
|
| 45 |
+
"top1_match_rate": gnum(r"[Ss]ame top p:\s*([0-9.]+)", kld) or gnum(r"top.?1.*?([0-9.]+)%", kld),
|
| 46 |
+
"ppl_c512": gnum(r"PPL\s*[:=]\s*([0-9.]+)", ppl) or gnum(r"perplexity:\s*([0-9.]+)", ppl) or gnum(r"Final estimate:\s*PPL\s*=\s*([0-9.]+)", ppl),
|
| 47 |
+
}
|
| 48 |
+
rows.append(row)
|
| 49 |
+
log(f" {Q}: KLD_mean={row['kld_nats_mean']} top1={row['top1_match_rate']} ppl={row['ppl_c512']}")
|
| 50 |
+
json.dump({"model":"salamandra-7b-instruct-2606","ref":"BF16","corpus":"es","rows":rows},
|
| 51 |
+
open(f"{METR}/quant-summary-with-kld.json","w"), indent=2)
|
| 52 |
+
|
| 53 |
+
# ppl delta vs bf16 ref (compute ref ppl once)
|
| 54 |
+
refppl = sh(["llama-perplexity","-m",REF,"-f",CORPUS,"-c",CTX,"-ngl","99"])
|
| 55 |
+
rp = gnum(r"Final estimate:\s*PPL\s*=\s*([0-9.]+)", refppl) or gnum(r"PPL\s*[:=]\s*([0-9.]+)", refppl)
|
| 56 |
+
for r in rows: r["ppl_delta_vs_bf16"] = round(r["ppl_c512"]-rp,4) if r["ppl_c512"]==r["ppl_c512"] and rp==rp else None
|
| 57 |
+
json.dump({"model":"salamandra-7b-instruct-2606","ref":"BF16","ref_ppl":rp,"corpus":"es","rows":rows},
|
| 58 |
+
open(f"{METR}/quant-summary-with-kld.json","w"), indent=2)
|
| 59 |
+
with open(f"{METR}/quant-summary-with-kld.csv","w",newline="") as f:
|
| 60 |
+
w = csv.DictWriter(f, fieldnames=list(rows[0].keys())); w.writeheader(); w.writerows(rows)
|
| 61 |
+
log("KLD_SWEEP_DONE")
|
scripts/make_charts.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json, matplotlib
|
| 2 |
+
matplotlib.use("Agg")
|
| 3 |
+
import matplotlib.pyplot as plt
|
| 4 |
+
D="/Users/kikocisneros/coco_ppl/aq_salamandra7b"
|
| 5 |
+
d=json.load(open(f"{D}/metrics/quant-summary-with-kld.json"))
|
| 6 |
+
rows=d["rows"]; names=[r["name"] for r in rows]
|
| 7 |
+
gb=[r["size_gb_decimal"] for r in rows]; kld=[r["kld_nats_mean"] for r in rows]
|
| 8 |
+
ppld=[r["ppl_delta_vs_bf16"] for r in rows]; top1=[r["top1_match_rate"] for r in rows]
|
| 9 |
+
C="#3b5bdb"; G="#0ca678"; O="#e8590c"
|
| 10 |
+
def style(ax,t,xl,yl): ax.set_title(t,fontweight="bold"); ax.set_xlabel(xl); ax.set_ylabel(yl); ax.grid(alpha=.25)
|
| 11 |
+
# 1. quality vs size (KLD vs GB, log y) — the money chart
|
| 12 |
+
fig,ax=plt.subplots(figsize=(7,4.5))
|
| 13 |
+
ax.plot(gb,kld,"-o",color=C,lw=2,ms=8)
|
| 14 |
+
for x,y,n in zip(gb,kld,names): ax.annotate(n,(x,y),textcoords="offset points",xytext=(6,6),fontsize=9)
|
| 15 |
+
ax.set_yscale("log"); style(ax,"Fidelity vs size — salamandra-7b GGUF","file size (GB)","KLD mean vs BF16 (nats, log) — lower is better")
|
| 16 |
+
fig.tight_layout(); fig.savefig(f"{D}/metrics/chart-quality-vs-size.png",dpi=130); plt.close()
|
| 17 |
+
# 2. ppl delta
|
| 18 |
+
fig,ax=plt.subplots(figsize=(7,4))
|
| 19 |
+
b=ax.bar(names,ppld,color=[G if v<0.1 else (C if v<0.4 else O) for v in ppld])
|
| 20 |
+
for r,v in zip(b,ppld): ax.text(r.get_x()+r.get_width()/2,v,f"+{v:.3f}",ha="center",va="bottom",fontsize=9)
|
| 21 |
+
style(ax,"Perplexity increase vs BF16 (Spanish)","","PPL Δ — lower is better"); fig.tight_layout(); fig.savefig(f"{D}/metrics/chart-ppl-delta.png",dpi=130); plt.close()
|
| 22 |
+
# 3. top-1 match
|
| 23 |
+
fig,ax=plt.subplots(figsize=(7,4))
|
| 24 |
+
b=ax.bar(names,top1,color=G)
|
| 25 |
+
for r,v in zip(b,top1): ax.text(r.get_x()+r.get_width()/2,v,f"{v:.1f}%",ha="center",va="bottom",fontsize=9)
|
| 26 |
+
ax.set_ylim(80,100); style(ax,"Top-1 token agreement with BF16","","% argmax matches — higher is better"); fig.tight_layout(); fig.savefig(f"{D}/metrics/chart-top1-match.png",dpi=130); plt.close()
|
| 27 |
+
print("CHARTS_DONE", [n for n in names])
|
scripts/reproduce.sh
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# salamandra-7b-instruct-2606 GGUF — reproduction
|
| 2 |
+
# 1. convert reference
|
| 3 |
+
python llama.cpp/convert_hf_to_gguf.py BSC-LT/salamandra-7b-instruct-2606 --outfile salamandra-7b-BF16.gguf --outtype bf16
|
| 4 |
+
# 2. imatrix — calibrated in SPANISH (the model's language)
|
| 5 |
+
llama-imatrix -m salamandra-7b-BF16.gguf -f imatrix_calib_es.txt -o salamandra-7b.imatrix -c 512 -ngl 99
|
| 6 |
+
# 3. quantize the ladder
|
| 7 |
+
for Q in Q3_K_M IQ4_XS Q4_K_M Q5_K_M Q6_K Q8_0; do
|
| 8 |
+
llama-quantize --imatrix salamandra-7b.imatrix salamandra-7b-BF16.gguf salamandra-7b-$Q.gguf $Q
|
| 9 |
+
done
|
| 10 |
+
# 4. KLD/PPL/Top-1 sweep vs BF16 (Spanish corpus) -> metrics/quant-summary-with-kld.json
|