Instructions to use itselouardi/ZAYA1-8B-bnb-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use itselouardi/ZAYA1-8B-bnb-4bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="itselouardi/ZAYA1-8B-bnb-4bit") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("itselouardi/ZAYA1-8B-bnb-4bit") model = AutoModelForCausalLM.from_pretrained("itselouardi/ZAYA1-8B-bnb-4bit", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use itselouardi/ZAYA1-8B-bnb-4bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "itselouardi/ZAYA1-8B-bnb-4bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "itselouardi/ZAYA1-8B-bnb-4bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/itselouardi/ZAYA1-8B-bnb-4bit
- SGLang
How to use itselouardi/ZAYA1-8B-bnb-4bit 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 "itselouardi/ZAYA1-8B-bnb-4bit" \ --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": "itselouardi/ZAYA1-8B-bnb-4bit", "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 "itselouardi/ZAYA1-8B-bnb-4bit" \ --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": "itselouardi/ZAYA1-8B-bnb-4bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use itselouardi/ZAYA1-8B-bnb-4bit with Docker Model Runner:
docker model run hf.co/itselouardi/ZAYA1-8B-bnb-4bit
ZAYA1โ8B โ 4โbit Quantized (bnbโnf4)
This repo contains a 4โbit quantized version of Zyphra/ZAYA1โ8B using bitsandbytes (load_in_4bit=True, nf4 quantization type).
It reduces VRAM usage to ~5.1โฏGB while keeping high generation quality โ ideal for local deployment, lowโresource environments, and quick experimentation.
โก Part of the ZAYA1 Community Deployment Stack
GitHub: zaya1โvllmโdocker (CUDA/ROCm Docker images & benchmarks coming soon)
๐ฆ Model Details
- Architecture: MambaโTransformer hybrid (Zyphraโs ZAYA1 design)
- Original model: Zyphra/ZAYA1โ8B
- Quantization method: BitsAndBytes 4โbit NF4 with double quantization
- Precision:
bfloat16compute dtype - VRAM after loading: ~5.1โฏGB (vs. ~16โฏGB for FP16)
๐ Quick Start
Install dependencies:
pip install transformers bitsandbytes accelerate torch
Load and generate:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "ayoubelouardi/ZAYA1-8B-bnb-4bit"
# The model loads directly in 4โbit โ no extra config needed
model = AutoModelForCausalLM.from_pretrained(
model_name,
device_map="auto",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
prompt = "Once upon a time,"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=50)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
โ ๏ธ Note:
trust_remote_code=Trueis required because the model uses a custom architecture.
๐งช How it was created
The quantization was performed using the following script (included in the community repo):
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
import torch
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16
)
model = AutoModelForCausalLM.from_pretrained(
"Zyphra/ZAYA1-8B",
quantization_config=bnb_config,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("Zyphra/ZAYA1-8B", trust_remote_code=True)
model.save_pretrained("./ZAYA1-8B-bnb-4bit")
tokenizer.save_pretrained("./ZAYA1-8B-bnb-4bit")
The saved checkpoint automatically includes the quantization config โ so you donโt need to set load_in_4bit again when loading from this repo.
๐ Benchmarks
| GPU | Quantization | Tokens/sec (batch=1) | Notes |
|---|---|---|---|
| NVIDIA A100 80GB | FP16 (original) | coming soon | via vLLM |
| NVIDIA A100 80GB | 4โbit (this repo) | coming soon | via transformers |
| AMD MI300X 192GB | FP16 (original) | coming soon | via vLLM + ROCm |
Full benchmarks will be published in the GitHub repository. Stay tuned!
๐ Links
- Original model: Zyphra/ZAYA1โ8B
- Zyphraโs vLLM fork: Zyphra/vllm
- Community deployment repo: zaya1โvllmโdocker (Docker images, GGUF progress, benchmarks)
- Author: Ayoub El Ouardi
๐ License
This model is subject to the Zyphra Community License Agreement.
Please review the original license before using.
๐ Acknowledgements
Thanks to Zyphra for releasing ZAYA1โ8B and maintaining the openโsource forks.
This quantized version is a community contribution and is not affiliated with Zyphra.
- Downloads last month
- 29