Instructions to use Zyphra/Zamba2-7B-Instruct-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Zyphra/Zamba2-7B-Instruct-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Zyphra/Zamba2-7B-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-7B-Instruct-v2") model = AutoModelForCausalLM.from_pretrained("Zyphra/Zamba2-7B-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-7B-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-7B-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-7B-Instruct-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Zyphra/Zamba2-7B-Instruct-v2
- SGLang
How to use Zyphra/Zamba2-7B-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-7B-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-7B-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-7B-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-7B-Instruct-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Zyphra/Zamba2-7B-Instruct-v2 with Docker Model Runner:
docker model run hf.co/Zyphra/Zamba2-7B-Instruct-v2
| { | |
| "adapter_rank": 128, | |
| "add_bias_linear": false, | |
| "architectures": [ | |
| "Zamba2ForCausalLM" | |
| ], | |
| "attention_dropout": 0.0, | |
| "attention_head_dim": 224, | |
| "attention_hidden_size": 7168, | |
| "bos_token_id": 1, | |
| "chunk_size": 256, | |
| "eos_token_id": 2, | |
| "ffn_hidden_size": 14336, | |
| "hidden_act": "gelu", | |
| "hidden_size": 3584, | |
| "hybrid_layer_ids": [ | |
| 6, | |
| 11, | |
| 17, | |
| 23, | |
| 29, | |
| 35, | |
| 41, | |
| 47, | |
| 53, | |
| 59, | |
| 65, | |
| 71, | |
| 77 | |
| ], | |
| "initializer_range": 0.02, | |
| "intermediate_size": 14336, | |
| "kv_channels": 112, | |
| "layers_block_type": [ | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "hybrid", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "hybrid", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "hybrid", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "hybrid", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "hybrid", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "hybrid", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "hybrid", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "hybrid", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "hybrid", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "hybrid", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "hybrid", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "hybrid", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "mamba", | |
| "hybrid", | |
| "mamba", | |
| "mamba", | |
| "mamba" | |
| ], | |
| "mamba_d_conv": 4, | |
| "mamba_d_state": 64, | |
| "mamba_expand": 2, | |
| "mamba_headdim": 64, | |
| "mamba_ngroups": 2, | |
| "max_position_embeddings": 4096, | |
| "model_type": "zamba2", | |
| "n_mamba_heads": 112, | |
| "num_attention_heads": 32, | |
| "num_hidden_layers": 81, | |
| "num_key_value_heads": 32, | |
| "num_logits_to_keep": 1, | |
| "num_mem_blocks": 2, | |
| "num_query_groups": 32, | |
| "pad_token_id": 0, | |
| "rms_norm_eps": 1e-05, | |
| "rope_theta": 10000, | |
| "time_step_floor": 0.0001, | |
| "time_step_limit": null, | |
| "time_step_max": 0.1, | |
| "time_step_min": 0.001, | |
| "transformers_version": "4.49.0", | |
| "use_cache": true, | |
| "use_conv_bias": true, | |
| "use_long_context": false, | |
| "use_mem_eff_path": false, | |
| "use_mem_rope": true, | |
| "use_shared_attention_adapter": false, | |
| "use_shared_mlp_adapter": true, | |
| "vocab_size": 32000 | |
| } | |