Gemma-2-quantized
Collection
Gemma-2-2B and Gemma-2-9B Quantized in low-bit • 4 items • Updated
How to use StoyanGanchev/gemma-2-9b-nf4 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="StoyanGanchev/gemma-2-9b-nf4") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("StoyanGanchev/gemma-2-9b-nf4")
model = AutoModelForCausalLM.from_pretrained("StoyanGanchev/gemma-2-9b-nf4")How to use StoyanGanchev/gemma-2-9b-nf4 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "StoyanGanchev/gemma-2-9b-nf4"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "StoyanGanchev/gemma-2-9b-nf4",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/StoyanGanchev/gemma-2-9b-nf4
How to use StoyanGanchev/gemma-2-9b-nf4 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "StoyanGanchev/gemma-2-9b-nf4" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "StoyanGanchev/gemma-2-9b-nf4",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "StoyanGanchev/gemma-2-9b-nf4" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "StoyanGanchev/gemma-2-9b-nf4",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use StoyanGanchev/gemma-2-9b-nf4 with Docker Model Runner:
docker model run hf.co/StoyanGanchev/gemma-2-9b-nf4
This repository contains a 4-bit quantized version of the Gemma-2-9B model. Designed to minimize memory consumption and speed up inference.
| Gemma-2-9b | Wiki | C4 | PIQA | ARC-E | ARC-C | HellaSwag | Wino | Avg. |
|---|---|---|---|---|---|---|---|---|
| 0-shot | 0-shot | 0-shot | 0-shot | 25-shot | 0-shot | 0-shot | ||
| Unquantized | 6.88 | 10.12 | 81.39 | 87.25 | 64.33 | 61.27 | 74.11 | 73.67 |
| NF4 | 7.05 | 11.04 | 81.45 | 86.78 | 64.62 | 60.87 | 74.51 | 73.65 |
Benchmark scores are computed with lm-evaluation-harness.
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("StoyanGanchev/gemma-2-9b-nf4")
model = AutoModelForCausalLM.from_pretrained("StoyanGanchev/gemma-2-9b-nf4")
All files could be accesed on repository