Instructions to use robbiemu/salamandra-2b-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use robbiemu/salamandra-2b-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="robbiemu/salamandra-2b-instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("robbiemu/salamandra-2b-instruct") model = AutoModelForCausalLM.from_pretrained("robbiemu/salamandra-2b-instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - llama-cpp-python
How to use robbiemu/salamandra-2b-instruct with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="robbiemu/salamandra-2b-instruct", filename="salamandra-2b-instruct_IQ2_M.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 robbiemu/salamandra-2b-instruct 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 robbiemu/salamandra-2b-instruct:Q4_K_M # Run inference directly in the terminal: llama cli -hf robbiemu/salamandra-2b-instruct:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf robbiemu/salamandra-2b-instruct:Q4_K_M # Run inference directly in the terminal: llama cli -hf robbiemu/salamandra-2b-instruct: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 robbiemu/salamandra-2b-instruct:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf robbiemu/salamandra-2b-instruct: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 robbiemu/salamandra-2b-instruct:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf robbiemu/salamandra-2b-instruct:Q4_K_M
Use Docker
docker model run hf.co/robbiemu/salamandra-2b-instruct:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use robbiemu/salamandra-2b-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "robbiemu/salamandra-2b-instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "robbiemu/salamandra-2b-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/robbiemu/salamandra-2b-instruct:Q4_K_M
- SGLang
How to use robbiemu/salamandra-2b-instruct with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "robbiemu/salamandra-2b-instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "robbiemu/salamandra-2b-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "robbiemu/salamandra-2b-instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "robbiemu/salamandra-2b-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use robbiemu/salamandra-2b-instruct with Ollama:
ollama run hf.co/robbiemu/salamandra-2b-instruct:Q4_K_M
- Unsloth Studio
How to use robbiemu/salamandra-2b-instruct 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 robbiemu/salamandra-2b-instruct 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 robbiemu/salamandra-2b-instruct to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for robbiemu/salamandra-2b-instruct to start chatting
- Atomic Chat new
- Docker Model Runner
How to use robbiemu/salamandra-2b-instruct with Docker Model Runner:
docker model run hf.co/robbiemu/salamandra-2b-instruct:Q4_K_M
- Lemonade
How to use robbiemu/salamandra-2b-instruct with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull robbiemu/salamandra-2b-instruct:Q4_K_M
Run and chat with the model
lemonade run user.salamandra-2b-instruct-Q4_K_M
List all available models
lemonade list
updated readme
Browse files- noted tooling used to quantize models
- updated summary
- revised recommendations
- added detail of how PPL was calculated.
README.md
CHANGED
|
@@ -45,14 +45,24 @@ language:
|
|
| 45 |
---
|
| 46 |
source repo: [BSC-LT/salamandra-2b-instruct](https://huggingface.co/BSC-LT/salamandra-2b-instruct)
|
| 47 |
|
| 48 |
-
# Quantization summary
|
| 49 |
|
| 50 |
-
The base model was quantized with a substantive importance matrix over all target languages (some 34x1000 samples, 96MB of text) with samples from the [Open Super-large Crawled ALMAnaCH coRpus](/datasets/oscar-corpus/oscar) dataset.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
| **Quantization Type** | **PPL(Q)** | **ln(PPL(Q)/PPL(bf16))** | **File Size (G)** | **Notes** |
|
| 53 |
|-----------------------|------------|------------------------|-------------------|----------------------------------------------------------------|
|
| 54 |
| [**IQ3_M**](salamandra-2b-instruct_IQ3_M.gguf) | 16.774 | 0.086769 | 1.7 | Good size efficiency with acceptable PPL increase |
|
| 55 |
| [**Q3_K_L**](salamandra-2b-instruct_Q3_K_L.gguf) | 16.5067 | 0.070705 | 1.8 | Further size reduction with modest PPL increase |
|
|
|
|
| 56 |
| [**Q4_K_S**](salamandra-2b-instruct_Q4_K_S.gguf) | 15.9346 | 0.035431 | 1.9 | Good size reduction with minimal PPL impact (**recommended**) |
|
| 57 |
| [**Q5_K_M**](salamandra-2b-instruct_Q5_K_M.gguf) | 15.4746 | 0.006139 | 2.2 | Excellent balance of PPL and size (**recommended**) |
|
| 58 |
| [**Q6_K**](salamandra-2b-instruct_Q6_K.gguf) | 15.3961 | 0.001053 | 2.4 | Nearly lossless performance with reduced size |
|
|
@@ -61,12 +71,13 @@ The base model was quantized with a substantive importance matrix over all targe
|
|
| 61 |
### **Notes:**
|
| 62 |
|
| 63 |
- **Recommended Quantizations:**
|
| 64 |
-
- **
|
|
|
|
| 65 |
- **Q5_K_M:** Offers the best balance between low perplexity and reduced file size above Q4, making it ideal for most applications.
|
| 66 |
-
- **Q6_K:** Delivers nearly lossless performance compared to bf16 with a reduced file size (2.4G vs. 4.2G). Ideal for scenarios requiring maximum accuracy with some size savings.
|
| 67 |
- **Non-recommended Quantizations:**
|
| 68 |
- **IQ3_M:** Represents the best of the I quantization types below Q4, achieving good size efficiency while maintaining low perplexity.
|
| 69 |
- **Q3_K_L:** Provides a slightly larger file size (1.8G) with an acceptable PPL (16.5067). While it meets the log PPL difference criteria, it is not as balanced as the recommended quantizations.
|
|
|
|
| 70 |
- An attempt was made to get a model below **IQ3_M** size, but perplexity was unacceptable even with **IQ2_M** (more than the 0.3 selection crteria, see next section). If you need a model below 1.7GB, you may be better served by Richard Erkhov's [quantizations](https://huggingface.co/RichardErkhov/BSC-LT_-_salamandra-2b-instruct-gguf), which seem to be a static quantization instead of using an importance matrix, so they are smaller.
|
| 71 |
|
| 72 |
---
|
|
@@ -84,6 +95,8 @@ The selection of recommended models is designed to provide a spectrum of options
|
|
| 84 |
- **Log PPL diff <0.3:** All included models have a log PPL difference under 0.3, ensuring that they maintain acceptable performance even when highly quantized.
|
| 85 |
- **No Multiple Models Within 100MB of the Same File Size:** Only one model is included per similar file size range to avoid redundancy. For example, **Q3_K_L** (1.8G) is included while other models like **Q3_K_M** (1.7G) are excluded due to nearly equal file sizes and differing PPL, ensuring a sparse yet comprehensive selection.
|
| 86 |
|
|
|
|
|
|
|
| 87 |
---
|
| 88 |
|
| 89 |
# Comparison of salamandra 2b/instruct quantization results
|
|
|
|
| 45 |
---
|
| 46 |
source repo: [BSC-LT/salamandra-2b-instruct](https://huggingface.co/BSC-LT/salamandra-2b-instruct)
|
| 47 |
|
| 48 |
+
# **Quantization summary**
|
| 49 |
|
| 50 |
+
The base model was quantized in [llama.cpp](https://github.com/ggerganov/llama.cpp) with a substantive importance matrix over all target languages (some 34x1000 samples, 96MB of text) with samples from the [Open Super-large Crawled ALMAnaCH coRpus](/datasets/oscar-corpus/oscar) dataset. Logs of the process are included.
|
| 51 |
+
|
| 52 |
+
- **IQ3_M**: At <1.8GB, the smallest model worth highlighting.
|
| 53 |
+
- **IQ4_XS** or **Q4_K_S**: Its a toss up for the sub-2GB quantizations. Metal users will get more t/s from Q4_K_S.
|
| 54 |
+
- **Q5_K_M**: Excellent balance above **Q4**, recommended for most applications.
|
| 55 |
+
- **Q6_K**: Provides near-**bf16** performance with size savings.
|
| 56 |
+
|
| 57 |
+
---
|
| 58 |
+
|
| 59 |
+
# Quantization
|
| 60 |
|
| 61 |
| **Quantization Type** | **PPL(Q)** | **ln(PPL(Q)/PPL(bf16))** | **File Size (G)** | **Notes** |
|
| 62 |
|-----------------------|------------|------------------------|-------------------|----------------------------------------------------------------|
|
| 63 |
| [**IQ3_M**](salamandra-2b-instruct_IQ3_M.gguf) | 16.774 | 0.086769 | 1.7 | Good size efficiency with acceptable PPL increase |
|
| 64 |
| [**Q3_K_L**](salamandra-2b-instruct_Q3_K_L.gguf) | 16.5067 | 0.070705 | 1.8 | Further size reduction with modest PPL increase |
|
| 65 |
+
| [**IQ4_XS**](salamandra-2b-instruct_IQ4_XS.gguf) | 15.9591 | 0.036968 | 1.8 | Good size reduction with acceptable PPL increase (**recommended**) |
|
| 66 |
| [**Q4_K_S**](salamandra-2b-instruct_Q4_K_S.gguf) | 15.9346 | 0.035431 | 1.9 | Good size reduction with minimal PPL impact (**recommended**) |
|
| 67 |
| [**Q5_K_M**](salamandra-2b-instruct_Q5_K_M.gguf) | 15.4746 | 0.006139 | 2.2 | Excellent balance of PPL and size (**recommended**) |
|
| 68 |
| [**Q6_K**](salamandra-2b-instruct_Q6_K.gguf) | 15.3961 | 0.001053 | 2.4 | Nearly lossless performance with reduced size |
|
|
|
|
| 71 |
### **Notes:**
|
| 72 |
|
| 73 |
- **Recommended Quantizations:**
|
| 74 |
+
- **IQ4_XL:** A good size reduction with minimal PPL impact. The filesize is actually very close to 1.9GB, so not much different from Q4_K_S.
|
| 75 |
+
- **Q4_K_S:** A good size reduction with minimal PPL impact.
|
| 76 |
- **Q5_K_M:** Offers the best balance between low perplexity and reduced file size above Q4, making it ideal for most applications.
|
|
|
|
| 77 |
- **Non-recommended Quantizations:**
|
| 78 |
- **IQ3_M:** Represents the best of the I quantization types below Q4, achieving good size efficiency while maintaining low perplexity.
|
| 79 |
- **Q3_K_L:** Provides a slightly larger file size (1.8G) with an acceptable PPL (16.5067). While it meets the log PPL difference criteria, it is not as balanced as the recommended quantizations.
|
| 80 |
+
- **Q6_K:** Delivers nearly lossless performance compared to bf16 with a reduced file size (2.4G vs. 4.2G). Ideal for scenarios requiring maximum accuracy with some size savings.
|
| 81 |
- An attempt was made to get a model below **IQ3_M** size, but perplexity was unacceptable even with **IQ2_M** (more than the 0.3 selection crteria, see next section). If you need a model below 1.7GB, you may be better served by Richard Erkhov's [quantizations](https://huggingface.co/RichardErkhov/BSC-LT_-_salamandra-2b-instruct-gguf), which seem to be a static quantization instead of using an importance matrix, so they are smaller.
|
| 82 |
|
| 83 |
---
|
|
|
|
| 95 |
- **Log PPL diff <0.3:** All included models have a log PPL difference under 0.3, ensuring that they maintain acceptable performance even when highly quantized.
|
| 96 |
- **No Multiple Models Within 100MB of the Same File Size:** Only one model is included per similar file size range to avoid redundancy. For example, **Q3_K_L** (1.8G) is included while other models like **Q3_K_M** (1.7G) are excluded due to nearly equal file sizes and differing PPL, ensuring a sparse yet comprehensive selection.
|
| 97 |
|
| 98 |
+
PPL is measured from a sample of 50 of each language from the same dataset used to calculate the importance matrix.
|
| 99 |
+
|
| 100 |
---
|
| 101 |
|
| 102 |
# Comparison of salamandra 2b/instruct quantization results
|