Model reference · open weights
Zamba2 is an open-weight language model from Zyphra. AxForge deploys and operates it for you on dedicated EU-owned hardware — with the licence handled where one is required.
Available as managed deployment — configured and operated for you on dedicated EU hardware, quoted per deployment.
What it is
| Released by | Zyphra |
|---|---|
| Type | Language models |
| Task | Text gen |
| Parameters (lead) | 1.2B |
| Context | 4k tokens |
| Runs with | transformers |
| Based on | Zyphra/Zamba2-1.2B |
| Released | 2024-09-19 |
| Popularity | 179k downloads / month |
| Licence | Open weights |
About
Zamba2-1.2B-instruct is obtained from Zamba2-1.2B by fine-tuning on instruction-following and chat datasets. Specifically:
Zamba2-1.2B-Instruct is a hybrid model composed of state-space (Mamba2) and transformer blocks.
To download Zamba2-1.2B-instruct, install transformers from source:
git clone https://github.com/huggingface/transformers.gitcd transformers && pip install .To install dependencies necessary to run Mamba2 kernels, install mamba-ssm from source (due to compatibility issues with PyTorch) as well as causal-conv1d:
git clone https://github.com/state-spaces/mamba.gitcd mamba && git checkout v2.1.0 && pip install .pip install causal-conv1dYou can run the model without using the optimized Mamba2 kernels, but it is not recommended as it will result in significantly higher latency and memory usage.
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
# Instantiate model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("Zyphra/Zamba2-1.2B-instruct")
model = AutoModelForCausalLM.from_pretrained("Zyphra/Zamba2-1.2B-instruct", device_map="cuda", torch_dtype=torch.bfloat16)
# Format the input as a chat template
prompt = "What factors contributed to the fall of the Roman Empire?"
sample = [{'role': 'user', 'content': prompt}]
chat_sample = tokenizer.apply_chat_template(sample, tokenize=False)
# Tokenize input and generate output
input_ids = tokenizer(chat_sample, return_tensors='pt', add_special_tokens=False).to("cuda")
outputs = model.generate(**input_ids, max_new_tokens=150, return_dict_in_generate=False, output_scores=False, use_cache=True, num_beams=1, do_sample=False)
print((tokenizer.decode(outputs[0])))
Zamba2-1.2B-Instruct achieves leading instruction-following and multi-turn chat performance for a model of its size and matches strong models significantly larger. For instance, Zamba2-1.2B-Instruct outperforms Gemma2-2B-Instruct, a very strong model over 2x its size.
| Model | Size | Aggregate MT-Bench | IFEval |
|---|---|---|---|
| Zamba2-1.2B-Instruct | 1.2B | 59.53 | 41.45 |
| Gemma2-2B-Instruct | 2.7B | 51.69 | 42.20 |
| H2O-Danube-1.8B-Chat | 1.6B | 49.78 | 27.95 |
| StableLM-1.6B-Chat | 1.6B | 49.87 | 33.77 |
| SmolLM-1.7B-Instruct | 1.7B | 43.37 | 16.53 |
| Qwen2-1.5B-Instruct | 1.5B | N/A | 34.68 |
Moreover, due to its unique hybrid SSM architecture, Zamba2-1.2B-Instruct achieves extremely low inference latency and rapid generation with a significantly smaller memory footprint than comparable transformer-based models.
| Time to First Token (TTFT) | Output Generation |
|---|
And memory overhead
Zamba2-1.2B utilizes and extends our original Zamba hybrid SSM-attention architecture. The core Zamba architecture consists of a backbone of Mamba2 layers interleaved with one or more shared attention layers. This attention has shared weights to minimize the parameter cost of the model. We find that concatenating the original model embeddings to the input to this attention block improves performance, likely due to better maintenance of information across depth. The Zamba2 architecture also applies LoRA projection matrices to the shared transformer blocks to gain some additional expressivity in each block and allow each shared block to specialize slightly to its own unique position while keeping the additional parameter overhead small.
Note: this is a temporary HuggingFace implementation of Zamba2-1.2B. It may not yet be fully compatible with all frameworks and tools intended to interface with HuggingFace models.
A standalone Pytorch implementation of Zamba2-1.2B may be found here.
From the published model card. Full card on the HuggingFace links in the sidebar.
Using it via the API
Once AxForge deploys zamba2 for you, it answers on the OpenAI-compatible API — the same base URL and keys as every other model. (zamba2 below is illustrative; you get the exact model name on deployment.)
$ curl -sS https://api.axforge.ai/v1/chat/completions \
-H "Authorization: Bearer $AXFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"zamba2","messages":[{"role":"user","content":"Hello"}]}'
Create an account — your API key is available in the console. 3M free tokens every 30 days with every new account.