Find below some example scripts on how to use the model in
transformers
(Make sure to have the latest transformers, or the one built from source):
Using the Pytorch model
Running the model on a CPU
Click to expand
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-instruct")
model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-instruct")
# We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
messages = [
{"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
]
input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
input_ids = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(input_ids, max_new_tokens=30)
print(tokenizer.decode(outputs[0]))
Running the model on a GPU
Click to expand
# pip install acceleratefrom transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-instruct")
model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-instruct", device_map="auto")
# We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
messages = [
{"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
]
input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids, max_new_tokens=30)
print(tokenizer.decode(outputs[0]))
Running the model on a GPU using
torch.compile
Click to expand
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-instruct")
model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-instruct", torch_dtype=torch.bfloat16).to(0)
model = torch.compile(model)
# We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
messages = [
{"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
]
input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids, max_new_tokens=30)
print(tokenizer.decode(outputs[0]))
Running the model on a GPU using different precisions
FP16
Click to expand
# pip install accelerateimport torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-instruct")
model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-instruct", device_map="auto", torch_dtype=torch.float16)
# We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
messages = [
{"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
]
input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids, max_new_tokens=30)
print(tokenizer.decode(outputs[0]))
4-bit
Click to expand
# pip install bitsandbytes acceleratefrom transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-instruct")
model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-instruct", device_map="auto", quantization_config=BitsAndBytesConfig(load_in_4bit=True))
# We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
messages = [
{"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
]
input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids, max_new_tokens=30)
print(tokenizer.decode(outputs[0]))
Training Details
Training Data
Falcon-Mamba has been trained with ~ 6,000 GT mainly coming from
Refined-Web
, a large volume web-only dataset filtered and deduplicated.
Similar to the others
Falcon
suite models, Falcon-Mamba has been trained leveraging a multi-stage training strategy to increase the context-length from 2,048 to 8,192.
Moreover, inspired by the concept of Curriculum Learning, we carefully selected data mixtures throughout the training stages, considering both data diversity and complexity.
Note that at inference the context-length is not relevant as the Mamba architecture has no limit on long range dependency.
At the last training stage, small portion of high-quality curated data was used to further enhance performance.
Overall, the data sources included RefinedWeb-English, high quality technical data, code data and math data extracted from public sources.
In particular, we used samples coming from
Fineweb-edu
during our last training stage.
The data was tokenized with the Falcon-
7B
/
11B
tokenizer.
After pre-training, the model has been further fine-tuned on instruction data.
Training Procedure
Falcon-Mamba-7B was trained on 256 H100 80GB GPUs for the majority of the training, using a 3D parallelism strategy (TP=1, PP=1, DP=256) combined with ZeRO.
Training Hyperparameters
Hyperparameter
Value
Comment
Precision
bfloat16
Optimizer
AdamW
Max learning rate
6.4e-4
Following a WSD (warmup-stable-decay) learning rate schedule
Weight decay
1e-1
Batch size
2048
The model was trained AdamW optimizer, WSD (warmup-stable-decay) learning rate schedule, and a batch size rampup from
b
min
=
128
to
b
max
=
2048
during first 50 GT of training.
In the stable phase we used maximal learning rate
η
max
=
6.4
×
1
0
−
4
, and decayed it to the minimal value
η
min
=
256
η
max
with exponential schedule over 500 GT.
Also, we applied
BatchScaling
during the rampup — rescaling learning rate
η
so that the Adam noise temperature
T
noise
≡
b
η
is kept constant.
Speeds, Sizes, Times
The model training took roughly two months.
Evaluation
Benchmarks
We evaluate our model on all benchmarks of the new leaderboard's version using the
lm-evaluation-harness
package, and then normalize the evaluation results with HuggingFace score normalization.
model name
IFEval
BBH
MATH LvL5
GPQA
MUSR
MMLU-PRO
Average
Pure SSM models
FalconMamba-7B
33.36
19.88
3.63
8.05
10.86
14.47
15.04
TRI-ML/mamba-7b-rw
*
22.46
6.71
0.45
1.12
5.51
1.69
6.25
Hybrid SSM-attention models
recurrentgemma-9b
30.76
14.80
4.83
4.70
6.60
17.88
13.20
Zyphra/Zamba-7B-v1
*
24.06
21.12
3.32
3.03
7.74
16.02
12.55
Transformer models
Falcon2-11B
32.61
21.94
2.34
2.80
7.53
15.44
13.78
Meta-Llama-3-8B
14.55
24.50
3.25
7.38
6.24
24.55
13.41
Meta-Llama-3.1-8B
12.70
25.29
4.61
6.15
8.98
24.95
13.78
Mistral-7B-v0.1
23.86
22.02
2.49
5.59
10.68
22.36
14.50
Mistral-Nemo-Base-2407 (12B)
16.83
29.37
4.98
5.82
6.52
27.46
15.08
gemma-7B
26.59
21.12
6.42
4.92
10.98
21.64
15.28
Also, we evaluate our model on the benchmarks of the first leaderboard using
lighteval
.
model name
ARC
HellaSwag
MMLU
Winogrande
TruthfulQA
GSM8K
Average
Pure SSM models
FalconMamba-7B
*
62.03
80.82
62.11
73.64
53.42
52.54
64.09
TRI-ML/mamba-7b-rw
*
51.25
80.85
33.41
71.11
32.08
4.70
45.52
Hybrid SSM-attention models
recurrentgemma-9b
**
52.00
80.40
60.50
73.60
38.60
42.60
57.95
Zyphra/Zamba-7B-v1
*
56.14
82.23
58.11
79.87
52.88
30.78
60.00
Transformer models
Falcon2-11B
59.73
82.91
58.37
78.30
52.56
53.83
64.28
Meta-Llama-3-8B
60.24
82.23
66.70
78.45
42.93
45.19
62.62
Meta-Llama-3.1-8B
58.53
82.13
66.43
74.35
44.29
47.92
62.28
Mistral-7B-v0.1
59.98
83.31
64.16
78.37
42.15
37.83
60.97
gemma-7B
61.09
82.20
64.56
79.01
44.79
50.87
63.75
Mostly, we took evaluation results from both leaderboards. For the models marked by
star
we evaluated the tasks internally, while for the models marked by two
stars
the results were taken from paper or model card.
Throughput
This model can achieve comparable throughput and performance compared to other transformer based models that use optimized kernels such as Flash Attention 2. Make sure to install the optimized Mamba kernels with the following commands:
pip install "causal-conv1d>=1.4.0" mamba-ssm
Refer to our technical report for more details about performance evaluation.
Technical Specifications
Model Architecture and Objective
Falcon-Mamba-7B is a causal decoder-only model trained on a causal language modeling task (i.e., predict the next token).
Falcon-Mamba-7B was trained on AWS SageMaker, using on average 256 H100 80GB GPUs in 32 p5 instances.
Software
Falcon-Mamba-7B was trained on an internal distributed training codebase, Gigatron. It uses a 3D parallelism approach combined with ZeRO, high-performance Triton kernels.
Citation
Paper coming soon
😊.
Runs of tiiuae falcon-mamba-7b-instruct on huggingface.co
20.2K
Total runs
0
24-hour runs
0
3-day runs
-758
7-day runs
-973
30-day runs
More Information About falcon-mamba-7b-instruct huggingface.co Model
falcon-mamba-7b-instruct huggingface.co is an AI model on huggingface.co that provides falcon-mamba-7b-instruct's model effect (), which can be used instantly with this tiiuae falcon-mamba-7b-instruct model. huggingface.co supports a free trial of the falcon-mamba-7b-instruct model, and also provides paid use of the falcon-mamba-7b-instruct. Support call falcon-mamba-7b-instruct model through api, including Node.js, Python, http.
falcon-mamba-7b-instruct huggingface.co is an online trial and call api platform, which integrates falcon-mamba-7b-instruct's modeling effects, including api services, and provides a free online trial of falcon-mamba-7b-instruct, you can try falcon-mamba-7b-instruct online for free by clicking the link below.
tiiuae falcon-mamba-7b-instruct online free url in huggingface.co:
falcon-mamba-7b-instruct is an open source model from GitHub that offers a free installation service, and any user can find falcon-mamba-7b-instruct on GitHub to install. At the same time, huggingface.co provides the effect of falcon-mamba-7b-instruct install, users can directly use falcon-mamba-7b-instruct installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
falcon-mamba-7b-instruct install url in huggingface.co: