Downloads · 30 days
272
25% of all-time downloads
tiiuae/falcon-mamba-7b-pre-decay
falcon-mamba-7b-pre-decay is a machine learning model from tiiuae. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as other.
<img src="https://huggingface.co/datasets/tiiuae/documentation-images/resolve/main/falconmamba/thumbnail.png" alt="drawing" width="800"/
Downloads · 30 days
272
25% of all-time downloads
All-time downloads
1.1K
Public
Parameters
7.3B
14.5 GB on disk
Likes
3
Public
Click a slice to open those files.
.safetensors14.5 GB · 100%
From the Hugging Face model README
Falcon Mamba 7B - pre-decay checkpoint for continuous pretraining.
Paper link: https://hf.co/papers/2410.05355
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):
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay")
model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay")
input_text = "Question: How many hours in one day? Answer: "
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
</details>
# pip install accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay")
model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay", device_map="auto")
input_text = "Question: How many hours in one day? Answer: "
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
</details>
torch.compileimport torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay")
model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay", torch_dtype=torch.bfloat16).to(0)
model = torch.compile(model)
input_text = "Question: How many hours in one day? Answer: "
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
</details>
# pip install accelerate
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay")
model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay", device_map="auto", torch_dtype=torch.float16)
input_text = "Question: How many hours in one day? Answer: "
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
</details>
# pip install bitsandbytes accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay")
model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay", device_map="auto", quantization_config=BitsAndBytesConfig(load_in_4bit=True))
input_text = "Question: How many hours in one day? Answer: "
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
</details>
<br>
Falcon-Mamba has been trained with ~ 5,500 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.
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.
| 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_{\mathrm{min}}=128\) to \(b_{\mathrm{max}}=2048\) during first 50 GT of training. In the stable phase we used maximal learning rate \(\eta_{\mathrm{max}}=6.4 \times 10^{-4}\), and decayed it to the minimal value \(\eta_{\mathrm{min}}=\frac{\eta_{\mathrm{max}}}{256}\) with exponential schedule over 500 GT. Also, we applied BatchScaling during the rampup — rescaling learning rate \(\eta\) so that the Adam noise temperature \(T_{\mathrm{noise}}\equiv\frac{\eta}{\sqrt{b}}\) is kept constant.
The model training took roughly two months.
<br>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 FalconMamba blogpost for more details about performance evaluation.
<br>Falcon-Mamba-7B is a causal decoder-only model trained on a causal language modeling task (i.e., predict the next token).
The model is based on the Mamba architecture (Gu et al., 2023).
| Hyperparameter | Value | Comment |
|---|---|---|
| Layers | 64 | Number of layers |
d_model | 4096 | Hidden dimension |
d_state | 16 | The SSM state dimension |
| Vocabulary | 65024 | Vocabulary Size |
| Sequence length | 8192 | During the last training stages |
Falcon-Mamba-7B was trained on AWS SageMaker, using on average 256 H100 80GB GPUs in 32 p5 instances.
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.
<br>@misc{zuo2024falconmambacompetitiveattentionfree,
title={Falcon Mamba: The First Competitive Attention-free 7B Language Model},
author={Jingwei Zuo and Maksim Velikanov and Dhia Eddine Rhaiem and Ilyas Chahed and Younes Belkada and Guillaume Kunsch and Hakim Hacid},
year={2024},
eprint={2410.05355},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2410.05355},
}