Instructions to use Zyphra/Zamba2-1.2B-Instruct-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Zyphra/Zamba2-1.2B-Instruct-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Zyphra/Zamba2-1.2B-Instruct-v2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Zyphra/Zamba2-1.2B-Instruct-v2") model = AutoModelForCausalLM.from_pretrained("Zyphra/Zamba2-1.2B-Instruct-v2") 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 Zyphra/Zamba2-1.2B-Instruct-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Zyphra/Zamba2-1.2B-Instruct-v2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Zyphra/Zamba2-1.2B-Instruct-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Zyphra/Zamba2-1.2B-Instruct-v2
- SGLang
How to use Zyphra/Zamba2-1.2B-Instruct-v2 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 "Zyphra/Zamba2-1.2B-Instruct-v2" \ --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": "Zyphra/Zamba2-1.2B-Instruct-v2", "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 "Zyphra/Zamba2-1.2B-Instruct-v2" \ --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": "Zyphra/Zamba2-1.2B-Instruct-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Zyphra/Zamba2-1.2B-Instruct-v2 with Docker Model Runner:
docker model run hf.co/Zyphra/Zamba2-1.2B-Instruct-v2
Upload folder using huggingface_hub
Browse files- config.json +97 -0
- generation_config.json +7 -0
- model.safetensors +3 -0
- special_tokens_map.json +27 -0
- tokenizer.json +0 -0
- tokenizer_config.json +52 -0
config.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"adapter_rank": 128,
|
| 3 |
+
"add_bias_linear": false,
|
| 4 |
+
"architectures": [
|
| 5 |
+
"Zamba2ForCausalLM"
|
| 6 |
+
],
|
| 7 |
+
"attention_dropout": 0.0,
|
| 8 |
+
"attention_head_dim": 128,
|
| 9 |
+
"attention_hidden_size": 4096,
|
| 10 |
+
"bos_token_id": 1,
|
| 11 |
+
"chunk_size": 256,
|
| 12 |
+
"eos_token_id": 2,
|
| 13 |
+
"ffn_hidden_size": 8192,
|
| 14 |
+
"hidden_act": "gelu",
|
| 15 |
+
"hidden_size": 2048,
|
| 16 |
+
"hybrid_layer_ids": [
|
| 17 |
+
5,
|
| 18 |
+
11,
|
| 19 |
+
17,
|
| 20 |
+
23,
|
| 21 |
+
29,
|
| 22 |
+
35
|
| 23 |
+
],
|
| 24 |
+
"initializer_range": 0.02,
|
| 25 |
+
"intermediate_size": 8192,
|
| 26 |
+
"kv_channels": 64,
|
| 27 |
+
"layers_block_type": [
|
| 28 |
+
"mamba",
|
| 29 |
+
"mamba",
|
| 30 |
+
"mamba",
|
| 31 |
+
"mamba",
|
| 32 |
+
"mamba",
|
| 33 |
+
"hybrid",
|
| 34 |
+
"mamba",
|
| 35 |
+
"mamba",
|
| 36 |
+
"mamba",
|
| 37 |
+
"mamba",
|
| 38 |
+
"mamba",
|
| 39 |
+
"hybrid",
|
| 40 |
+
"mamba",
|
| 41 |
+
"mamba",
|
| 42 |
+
"mamba",
|
| 43 |
+
"mamba",
|
| 44 |
+
"mamba",
|
| 45 |
+
"hybrid",
|
| 46 |
+
"mamba",
|
| 47 |
+
"mamba",
|
| 48 |
+
"mamba",
|
| 49 |
+
"mamba",
|
| 50 |
+
"mamba",
|
| 51 |
+
"hybrid",
|
| 52 |
+
"mamba",
|
| 53 |
+
"mamba",
|
| 54 |
+
"mamba",
|
| 55 |
+
"mamba",
|
| 56 |
+
"mamba",
|
| 57 |
+
"hybrid",
|
| 58 |
+
"mamba",
|
| 59 |
+
"mamba",
|
| 60 |
+
"mamba",
|
| 61 |
+
"mamba",
|
| 62 |
+
"mamba",
|
| 63 |
+
"hybrid",
|
| 64 |
+
"mamba",
|
| 65 |
+
"mamba"
|
| 66 |
+
],
|
| 67 |
+
"mamba_d_conv": 4,
|
| 68 |
+
"mamba_d_state": 128,
|
| 69 |
+
"mamba_expand": 2,
|
| 70 |
+
"mamba_headdim": 64,
|
| 71 |
+
"mamba_ngroups": 1,
|
| 72 |
+
"max_position_embeddings": 4096,
|
| 73 |
+
"model_type": "zamba2",
|
| 74 |
+
"n_mamba_heads": 64,
|
| 75 |
+
"num_attention_heads": 32,
|
| 76 |
+
"num_hidden_layers": 38,
|
| 77 |
+
"num_key_value_heads": 32,
|
| 78 |
+
"num_logits_to_keep": 1,
|
| 79 |
+
"num_mem_blocks": 1,
|
| 80 |
+
"num_query_groups": 32,
|
| 81 |
+
"pad_token_id": 0,
|
| 82 |
+
"rms_norm_eps": 1e-05,
|
| 83 |
+
"rope_theta": 10000,
|
| 84 |
+
"time_step_floor": 0.0001,
|
| 85 |
+
"time_step_limit": null,
|
| 86 |
+
"time_step_max": 0.1,
|
| 87 |
+
"time_step_min": 0.001,
|
| 88 |
+
"transformers_version": "4.49.0.dev0",
|
| 89 |
+
"use_cache": true,
|
| 90 |
+
"use_conv_bias": true,
|
| 91 |
+
"use_long_context": false,
|
| 92 |
+
"use_mem_eff_path": false,
|
| 93 |
+
"use_mem_rope": true,
|
| 94 |
+
"use_shared_attention_adapter": true,
|
| 95 |
+
"use_shared_mlp_adapter": true,
|
| 96 |
+
"vocab_size": 32000
|
| 97 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 1,
|
| 4 |
+
"eos_token_id": 2,
|
| 5 |
+
"pad_token_id": 0,
|
| 6 |
+
"transformers_version": "4.49.0.dev0"
|
| 7 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5101cce10fcb81387d833463e7f1ada6af5084fdffbdd02938c548f2211fc6e6
|
| 3 |
+
size 2430175896
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"additional_special_tokens": [
|
| 3 |
+
"<|im_start|>",
|
| 4 |
+
"<|im_end|>"
|
| 5 |
+
],
|
| 6 |
+
"bos_token": {
|
| 7 |
+
"content": "<|im_start|>",
|
| 8 |
+
"lstrip": false,
|
| 9 |
+
"normalized": false,
|
| 10 |
+
"rstrip": false,
|
| 11 |
+
"single_word": false
|
| 12 |
+
},
|
| 13 |
+
"eos_token": {
|
| 14 |
+
"content": "<|im_end|>",
|
| 15 |
+
"lstrip": false,
|
| 16 |
+
"normalized": false,
|
| 17 |
+
"rstrip": false,
|
| 18 |
+
"single_word": false
|
| 19 |
+
},
|
| 20 |
+
"pad_token": {
|
| 21 |
+
"content": "[PAD]",
|
| 22 |
+
"lstrip": false,
|
| 23 |
+
"normalized": false,
|
| 24 |
+
"rstrip": false,
|
| 25 |
+
"single_word": false
|
| 26 |
+
}
|
| 27 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_bos_token": true,
|
| 3 |
+
"add_eos_token": false,
|
| 4 |
+
"add_prefix_space": null,
|
| 5 |
+
"added_tokens_decoder": {
|
| 6 |
+
"0": {
|
| 7 |
+
"content": "[PAD]",
|
| 8 |
+
"lstrip": false,
|
| 9 |
+
"normalized": false,
|
| 10 |
+
"rstrip": false,
|
| 11 |
+
"single_word": false,
|
| 12 |
+
"special": true
|
| 13 |
+
},
|
| 14 |
+
"1": {
|
| 15 |
+
"content": "<|im_start|>",
|
| 16 |
+
"lstrip": false,
|
| 17 |
+
"normalized": false,
|
| 18 |
+
"rstrip": false,
|
| 19 |
+
"single_word": false,
|
| 20 |
+
"special": true
|
| 21 |
+
},
|
| 22 |
+
"2": {
|
| 23 |
+
"content": "<|im_end|>",
|
| 24 |
+
"lstrip": false,
|
| 25 |
+
"normalized": false,
|
| 26 |
+
"rstrip": false,
|
| 27 |
+
"single_word": false,
|
| 28 |
+
"special": true
|
| 29 |
+
}
|
| 30 |
+
},
|
| 31 |
+
"additional_special_tokens": [
|
| 32 |
+
"<|im_start|>",
|
| 33 |
+
"<|im_end|>"
|
| 34 |
+
],
|
| 35 |
+
"bos_token": "<|im_start|>",
|
| 36 |
+
"chat_template": "{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
|
| 37 |
+
"clean_up_tokenization_spaces": false,
|
| 38 |
+
"eos_token": "<|im_end|>",
|
| 39 |
+
"extra_special_tokens": {},
|
| 40 |
+
"legacy": true,
|
| 41 |
+
"max_length": 4096,
|
| 42 |
+
"model_max_length": 4096,
|
| 43 |
+
"pad_token": "[PAD]",
|
| 44 |
+
"sp_model_kwargs": {},
|
| 45 |
+
"spaces_between_special_tokens": false,
|
| 46 |
+
"stride": 0,
|
| 47 |
+
"tokenizer_class": "LlamaTokenizer",
|
| 48 |
+
"truncation_side": "right",
|
| 49 |
+
"truncation_strategy": "longest_first",
|
| 50 |
+
"unk_token": null,
|
| 51 |
+
"use_default_system_prompt": false
|
| 52 |
+
}
|