Text Generation
Transformers
Safetensors
English
falcon_mamba
Eval Results
Inference Endpoints
falcon-mamba-7b / README.md
Gkunsch's picture
Update README.md
9492b8c verified
|
raw
history blame
8.87 kB
metadata
datasets:
  - tiiuae/falcon-refinedweb
  - HuggingFaceFW/fineweb-edu
language:
  - en
license: apache-2.0

Model Card for Falcon-Mamba-7B

Table of Contents

  1. TL;DR
  2. Model Details
  3. Usage
  4. Training Details
  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

Running the model on a CPU

Click to expand
from transformers import AutoTokenizer, AutoModelForCausalLM

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

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]))

Running the model on a GPU

Click to expand
# pip install accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b")
model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b", 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]))

Running the model on a GPU using different precisions

FP16

Click to expand
# pip install accelerate
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b")
model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b", 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]))

4-bit

Click to expand
# pip install bitsandbytes accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig

tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b")
model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b", 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]))

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 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
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 bmin=128b_{\mathrm{min}}=128 to bmax=2048b_{\mathrm{max}}=2048 during first 50 GT of training. In the stable phase we used maximal learning rate ηmax=6.4×10−4\eta_{\mathrm{max}}=6.4 \times 10^{-4}, and decayed it to the minimal value ηmin=ηmax256\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 Tnoise≡ηbT_{\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 L2 ARC HellaSwag MMLU Winogrande TruthfulQA GSM8K Average L1
meta-llama/Meta-Llama-3-8B 14.55 24.50 3.25 7.38 6.24 24.55 13.41 60.24 82.23 66.70 78.45 42.93 45.19 62.62
tiiuae/falcon2-11B 32.61 21.94 2.34 2.8 7.53 15.44 13.78 59.73 82.91 58.37 78.30 52.56 53.83 64.28
mistralai/Mistral-7B-v0.1 23.86 22.02 2.49 5.59 10.68 22.36 14.50 59.98 83.31 64.16 78.37 42.15 37.83 60.97
Zyphra/Zamba-7B-v1 - - - - - - - 46.48 80.24 57.72 76.4 - - -
Ours 32.16 21.07 4.08 10.18 6.97 13.43 14.65 61.69 80.63 61.05 74.03 53.60 51.86 63.81

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).

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

Hyperparameter Value Comment
Layers 64
d_model 4096
d_state 16 The SSM state dimension
Vocabulary 65024
Sequence length 8192 During 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

Paper coming soon 😊.