Views
No views yet
transformers:pip install transformers -Umamba-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-conv1d1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4# Instantiate model and tokenizer
5tokenizer = AutoTokenizer.from_pretrained("Zyphra/Zamba2-7B-Instruct-v2")
6model = AutoModelForCausalLM.from_pretrained("Zyphra/Zamba2-7B-Instruct-v2", device_map="cuda", torch_dtype=torch.bfloat16)
7
8# Format the input as a chat template
9user_turn_1 = "In one season a flower blooms three times. In one year, there is one blooming season. How many times do two flowers bloom in two years? Please include your logic."
10assistant_turn_1 = "In one season, a flower blooms three times. In one year, there is one blooming season. Therefore, in two years, there are two blooming seasons. Since each flower blooms three times in one season, in two blooming seasons, each flower will bloom six times. Since there are two flowers, the total number of times they will bloom in two years is 12."
11user_turn_2 = "How many times do the two flowers blossom in three years?"
12sample = [{'role': 'user', 'content': user_turn_1}, {'role': 'assistant', 'content': assistant_turn_1}, {'role': 'user', 'content': user_turn_2}]
13chat_sample = tokenizer.apply_chat_template(sample, tokenize=False)
14
15# Tokenize input and generate output
16input_ids = tokenizer(chat_sample, return_tensors='pt', add_special_tokens=False).to("cuda")
17outputs = 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)
18print((tokenizer.decode(outputs[0])))use_long_context=True, i.e.:model = AutoModelForCausalLM.from_pretrained("Zamba2-7B-Instruct-v2", device_map="cuda", torch_dtype=torch.bfloat16, use_long_context=True)| Model | Size (B) | IFEval | BBH | GPQA | MATH (Hard) | MMLU Pro | MUSR | Aggregate |
|---|---|---|---|---|---|---|---|---|
| Zamba2-7B-Instruct-v2 | 7.36 | 81.63 | 36.72 | 8.60 | 17.76 | 34.51 | 11.94 | 31.78 |
| Zamba2-7B-Instruct | 7.36 | 69.89 | 36.18 | 8.81 | 13.02 | 32.81 | 9.20 | 28.32 |
| Granite-3.1-8B-Instruct | 8.17 | 72.20 | 38.68 | 8.23 | 19.91 | 35.22 | 17.36 | 31.93 |
| Llama-3.1-8B-Instruct | 8.03 | 78.07 | 34.68 | 2.74 | 17.10 | 37.83 | 8.13 | 29.76 |
| Mistral-NeMo-Minitron-8B-Instruct | 8.00 | 58.51 | 31.50 | 3.91 | 5.81 | 32.87 | 10.93 | 23.92 |
| Gemma2-9B-it | 9.24 | 74.35 | 46.46 | 13.38 | 0.12 | 38.73 | 9.66 | 30.45 |
| Ministral-8B-Instruct-2410 | 8.02 | 52.02 | 38.45 | 6.12 | 11.15 | 39.87 | 8.06 | 25.95 |
| Qwen2.5-7B-Instruct | 7.62 | 75.30 | 39.82 | 6.02 | 48.91 | 42.95 | 8.77 | 36.96 |
| Time to First Token (TTFT) | Output Generation |
|---|---|
![]() | ![]() |

