Instructions to use galatolo/cerbero-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use galatolo/cerbero-7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="galatolo/cerbero-7b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("galatolo/cerbero-7b") model = AutoModelForCausalLM.from_pretrained("galatolo/cerbero-7b") 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use galatolo/cerbero-7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "galatolo/cerbero-7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "galatolo/cerbero-7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/galatolo/cerbero-7b
- SGLang
How to use galatolo/cerbero-7b 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 "galatolo/cerbero-7b" \ --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": "galatolo/cerbero-7b", "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 "galatolo/cerbero-7b" \ --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": "galatolo/cerbero-7b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use galatolo/cerbero-7b with Docker Model Runner:
docker model run hf.co/galatolo/cerbero-7b
Unable to load model in GPU
Hi I'm trying to play with this model, but i cannot load it in gpu (T4 16GB provided by Colab), even if I specify device_map="cuda:0" it still loads in RAM. Any advice? I have another question why the model weights so much ~ 30GB despite having 7B parameters?
import transformers
quantization_config = transformers.BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type='nf4',
bnb_4bit_use_double_quant=True,
#bnb_4bit_compute_dtype=bfloat16
)
llm = AutoModelForCausalLM.from_pretrained(
"galatolo/cerbero-7b",
quantization_config = quantization_config,
device_map="cuda:0"
)
Hi, it weighs that much because the weights are in the float32 format (rather than the more common float16).
I attempted to load the model using Google Colab, and it appears to crash due to insufficient RAM.
I will upload a float16 variant, maybe it will solve this issue
I uploaded the float16 variant, and you can load it using the following code:
model = AutoModelForCausalLM.from_pretrained("galatolo/cerbero-7b", revision="float16")
However, it appears that Colab does not have enough RAM to handle this. I believe the best option is to use the llama.cpp version, which I have already quantized to 4 bits.