Instructions to use BSC-LT/salamandra-7b-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BSC-LT/salamandra-7b-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="BSC-LT/salamandra-7b-instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("BSC-LT/salamandra-7b-instruct") model = AutoModelForCausalLM.from_pretrained("BSC-LT/salamandra-7b-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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use BSC-LT/salamandra-7b-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "BSC-LT/salamandra-7b-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": "BSC-LT/salamandra-7b-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/BSC-LT/salamandra-7b-instruct
- SGLang
How to use BSC-LT/salamandra-7b-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 "BSC-LT/salamandra-7b-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": "BSC-LT/salamandra-7b-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 "BSC-LT/salamandra-7b-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": "BSC-LT/salamandra-7b-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use BSC-LT/salamandra-7b-instruct with Docker Model Runner:
docker model run hf.co/BSC-LT/salamandra-7b-instruct
Recommended ollama modelfile to install?
The model works fine with a standard template. I download the repository into the hf cache and then I create the Modelfile
FROM /home/kampal/.cache/huggingface/hub/models--BSC-LT--salamandra-7b-instruct/snapshots/e6c39f6092eb496f7feac065cf7a645bc792bbc6
TEMPLATE """
{{- range .Messages }}<|im_start|>{{ .Role }}
{{ .Content }}<|im_end|>
{{ end }}<|im_start|>assistant
""""
and it goes well:
(venv) kampal@kampal4090:~$ ollama create salamandra7b -f salamandra-7b-instruct-Modelfile
transferring model data 100%
using cached layer sha256:8d113310ba85d754a212e2f15a9de3c7d24fb3c0620809e95c2474ade5b1724b
using existing layer sha256:8d113310ba85d754a212e2f15a9de3c7d24fb3c0620809e95c2474ade5b1724b
creating new layer sha256:b7b5f247c4e3106fa129fa5f1c2a50ac79987ca766340fb66cf860d7d8ff61d3
creating new layer sha256:6e6b543a72c4b5f811a818f1818069b98eb5ac6433e328867da7ba962d523884
writing manifest
success
(venv) kampal@kampal4090:~$ ollama run salamandra7b:latest
>>> hla
Hello there!" - that is the English greeting "Hi". It is an informal way to start a conversation. If
you are looking for something more formal, consider using "Good day" or "Good morning".
Would you like me to assist you in any other matter?
>>> me puedes decir a que instituto de unizar corresponde el BIFI?
BIFI" es una sigla que pertenece al Instituto de Biocomputación y Física de Sistemas Complejos,
ubicado en la Universidad de Zaragoza. ¿Desea saber más sobre este Instituto?
But I note you recommend a more complex prompt, including date and general roles, and on the other hand I am not sure if the default temperature sampling etc are adequate. Can someone recommend a more complete Modelfile along the lines of https://github.com/ollama/ollama/blob/main/docs/modelfile.md Note that ollama uses Go templates instead of Jinja
I have quantized and uploaded the models to ollama, they can be run with ease with a single line of code:
ollama run hdnh2006/salamandra-7b-instruct
or
ollama run hdnh2006/salamandra-2b-instruct
I have quantized them from 2 to 8 bits and they can also be downloaded from HuggingFace:
https://huggingface.co/hdnh2006/BSC-LT-salamandra-2b-instruct-gguf
https://huggingface.co/hdnh2006/BSC-LT-salamandra-7b-instruct-gguf
Ollama links:
https://ollama.com/hdnh2006/salamandra-2b-instruct
https://ollama.com/hdnh2006/salamandra-7b-instruct