CoolFace
Modelpublic

tiiuae/falcon-mamba-7b-4bit

sourceHugging Faceotherupdated 2y agoView on Hugging Face
11likes262downloads
Model Card

<img src="https://huggingface.co/datasets/tiiuae/documentation-images/resolve/main/falcon_mamba/thumbnail.png" alt="drawing" width="800"/>

Make sure to install `bitsandbytes` and have a GPU compatible with `bitsandbytes` to run this model

Table of Contents

  1. 1.TL;DR
  2. 2.Model Details
  3. 3.Usage
  4. 4.Training Details
  5. 5.Evaluation

TL;DR

Model Details

Model Description

  • Developed by: https://www.tii.ae
  • Model type: Causal decoder-only
  • Architecture: Mamba
  • Language(s) (NLP): Mainly English
  • License: TII Falcon-Mamba License 2.0

Model Source

  • Paper: coming soon.

Usage

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

This checkpoint will only run on a GPU device with bitsandbytes installed. See below for more details on how to load it

<details> <summary> Click to expand </summary>

python
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-4bit")
model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-4bit")

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>

You can also dequantize the model with model.dequantize() method:

<details> <summary> Click to expand </summary>

python
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-4bit")
model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-4bit")
model = model.dequantize()

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>

Training Details

Training Data

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 training from 2,048 up to 8,192. 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 conversational data extracted from public sources. In particular, we used samples coming from Fineweb-edu.

The data was tokenized with the Falcon-7B/11B tokenizer.

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**
Precisionbfloat16
OptimizerAdamW
Max learning rate6.4e-4Following a WSD (warmup-stable-decay) learning rate schedule
Weight decay1e-1
Batch size2048

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.

Speeds, Sizes, Times

The model training took roughly two months.

Evaluation

Benchmarks

We evaluate our model on all benchmarks of the leaderboard's version 2 using the lm-evaluation-harness package, and we evaluate it on the benchmarks of version 1 using lighteval.

`model name``IFEval``BBH``MATH LvL5``GPQA``MUSR``MMLU-PRO``Average`
*Pure SSM models*
Falcon-Mamba-7B33.3619.883.638.0510.8614.4715.04
TRI-ML/mamba-7b-rw22.466.710.451.125.511.696.25
*Hybrid SSM-attention models*
Zamba-7B-v124.0621.123.323.037.7416.0212.55
recurrentgemma-9b30.7614.804.834.706.6017.8813.20
*Transformer models*
Falcon2-11B32.6121.942.342.807.5315.4413.78
Meta-Llama-3-8B14.5524.503.257.386.2424.5513.41
gemma-7B26.5921.126.424.9210.9821.6415.28
Mistral-7B-v0.123.8622.022.495.5910.6822.3614.50
Mistral-Nemo-Base16.8329.374.985.826.5227.4615.08
`model name``ARC``HellaSwag``MMLU``Winogrande``TruthfulQA``GSM8K``Average`
*Pure SSM models*
Falcon-Mamba-7B62.0380.8262.1173.6453.4252.5464.09
TRI-ML/mamba-7b-rw46.4880.2457.7276.40-4.70-
*Hybrid SSM-attention models*
recurrentgemma-9b52.0080.4060.5073.6038.6042.6057.95
Zyphra/Zamba-7B-v146.4880.2457.7276.40-30.78-
*Transformer models*
Falcon2-11B59.7382.9158.3778.3052.5653.8364.28
Meta-Llama-3-8B60.2482.2366.7078.4542.9345.1962.62
gemma-7B61.0982.2064.5679.0144.7950.8763.75
Mistral-7B-v0.159.9883.3164.1678.3742.1537.8360.97

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:

bash
pip install "causal-conv1d>=1.4.0" mamba-ssm

Refer to our FalconMamba blogpost 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).

The model is based on the Mamba architecture (Gu et al., 2023).

**Hyperparameter****Value****Comment**
Layers64Number of layers
d_model4096Hidden dimension
d_state16The SSM state dimension
Vocabulary65024Vocabulary Size
Sequence length8192During stages 4 and LR Decay stage

Compute Infrastructure

Hardware

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 an internal distributed training codebase, Gigatron. It uses a 3D parallelism approach combined with ZeRO, high-performance Triton kernels.

Citation

You can use the following bibtex citation:

@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}, 
}