Safetensors
English
falcon_mamba
ybelkada commited on
Commit
8ea5bea
·
verified ·
1 Parent(s): a2f2a57

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +201 -105
README.md CHANGED
@@ -1,199 +1,295 @@
1
  ---
2
- library_name: transformers
3
- tags: []
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
 
 
 
 
10
 
 
11
 
12
- ## Model Details
13
 
14
- ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
 
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
 
 
 
 
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
- ### Model Sources [optional]
29
 
30
- <!-- Provide the basic links for the model. -->
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
 
36
- ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
 
39
 
40
- ### Direct Use
 
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
 
43
 
44
- [More Information Needed]
 
45
 
46
- ### Downstream Use [optional]
 
 
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
 
50
- [More Information Needed]
51
 
52
- ### Out-of-Scope Use
 
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
 
 
55
 
56
- [More Information Needed]
 
57
 
58
- ## Bias, Risks, and Limitations
 
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
 
 
61
 
62
- [More Information Needed]
63
 
64
- ### Recommendations
65
 
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
 
67
 
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
 
 
69
 
70
- ## How to Get Started with the Model
 
71
 
72
- Use the code below to get started with the model.
73
 
74
- [More Information Needed]
 
75
 
76
- ## Training Details
 
 
77
 
78
- ### Training Data
79
 
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
 
82
- [More Information Needed]
83
 
84
- ### Training Procedure
85
 
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
 
87
 
88
- #### Preprocessing [optional]
 
 
 
89
 
90
- [More Information Needed]
 
91
 
 
 
92
 
93
- #### Training Hyperparameters
 
 
94
 
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
 
97
- #### Speeds, Sizes, Times [optional]
98
 
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
 
100
 
101
- [More Information Needed]
 
 
102
 
103
- ## Evaluation
 
104
 
105
- <!-- This section describes the evaluation protocols and provides the results. -->
 
106
 
107
- ### Testing Data, Factors & Metrics
 
 
108
 
109
- #### Testing Data
110
 
111
- <!-- This should link to a Dataset Card if possible. -->
112
 
113
- [More Information Needed]
114
 
115
- #### Factors
116
 
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
 
 
 
 
118
 
119
- [More Information Needed]
 
120
 
121
- #### Metrics
122
 
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
 
124
 
125
- [More Information Needed]
126
 
127
- ### Results
 
 
 
 
 
 
128
 
129
- [More Information Needed]
130
 
131
- #### Summary
 
 
132
 
 
133
 
 
134
 
135
- ## Model Examination [optional]
136
 
137
- <!-- Relevant interpretability work for the model goes here -->
138
 
139
- [More Information Needed]
140
 
141
- ## Environmental Impact
142
 
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
 
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
 
153
- ## Technical Specifications [optional]
154
 
155
- ### Model Architecture and Objective
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
 
157
- [More Information Needed]
158
 
159
- ### Compute Infrastructure
160
 
161
- [More Information Needed]
162
 
163
- #### Hardware
 
 
164
 
165
- [More Information Needed]
166
 
167
- #### Software
168
 
169
- [More Information Needed]
170
 
171
- ## Citation [optional]
172
 
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
- **BibTeX:**
176
 
177
- [More Information Needed]
178
 
179
- **APA:**
 
 
 
 
 
 
180
 
181
- [More Information Needed]
182
 
183
- ## Glossary [optional]
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
190
 
191
- [More Information Needed]
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
196
-
197
- ## Model Card Contact
198
-
199
- [More Information Needed]
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ datasets:
5
+ - tiiuae/falcon-refinedweb
6
+ - HuggingFaceFW/fineweb-edu
7
+ license: other
8
+ license_name: falcon-mamba-7b-license
9
+ license_link: https://falconllm.tii.ae/falcon-mamba-7b-terms-and-conditions.html
10
  ---
11
 
12
+ <img src="https://huggingface.co/datasets/tiiuae/documentation-images/resolve/main/falcon_mamba/thumbnail.png" alt="drawing" width="800"/>
13
 
14
+ # Table of Contents
15
 
16
+ 0. [TL;DR](#TL;DR)
17
+ 1. [Model Details](#model-details)
18
+ 2. [Usage](#usage)
19
+ 3. [Training Details](#training-details)
20
+ 4. [Evaluation](#evaluation)
21
 
22
+ Falcon Mamba 7B - pre-decay checkpoint for continuous pretraining.
23
 
24
+ # TL;DR
25
 
26
+ # Model Details
27
 
28
+ ## Model Description
29
 
30
+ - **Developed by:** [https://www.tii.ae](https://www.tii.ae)
31
+ - **Model type:** Causal decoder-only
32
+ - **Architecture:** Mamba
33
+ - **Language(s) (NLP):** Mainly English
34
+ - **License:** TII Falcon-Mamba License 2.0
35
 
36
+ <br>
 
 
 
 
 
 
37
 
38
+ # Usage
39
 
40
+ 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):
41
 
42
+ ## Using the Pytorch model
 
 
43
 
44
+ ### Running the model on a CPU
45
 
46
+ <details>
47
+ <summary> Click to expand </summary>
48
 
49
+ ```python
50
+ from transformers import AutoTokenizer, AutoModelForCausalLM
51
 
52
+ tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay")
53
+ model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay")
54
 
55
+ input_text = "Question: How many hours in one day? Answer: "
56
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids
57
 
58
+ outputs = model.generate(input_ids)
59
+ print(tokenizer.decode(outputs[0]))
60
+ ```
61
 
62
+ </details>
63
 
64
+ ### Running the model on a GPU
65
 
66
+ <details>
67
+ <summary> Click to expand </summary>
68
 
69
+ ```python
70
+ # pip install accelerate
71
+ from transformers import AutoTokenizer, AutoModelForCausalLM
72
 
73
+ tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay")
74
+ model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay", device_map="auto")
75
 
76
+ input_text = "Question: How many hours in one day? Answer: "
77
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
78
 
79
+ outputs = model.generate(input_ids)
80
+ print(tokenizer.decode(outputs[0]))
81
+ ```
82
 
83
+ </details>
84
 
85
+ ### Running the model on a GPU using `torch.compile`
86
 
87
+ <details>
88
+ <summary> Click to expand </summary>
89
 
90
+ ```python
91
+ import torch
92
+ from transformers import AutoTokenizer, AutoModelForCausalLM
93
 
94
+ tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay")
95
+ model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay", torch_dtype=torch.bfloat16).to(0)
96
 
97
+ model = torch.compile(model)
98
 
99
+ input_text = "Question: How many hours in one day? Answer: "
100
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
101
 
102
+ outputs = model.generate(input_ids)
103
+ print(tokenizer.decode(outputs[0]))
104
+ ```
105
 
106
+ </details>
107
 
 
108
 
109
+ ### Running the model on a GPU using different precisions
110
 
111
+ #### FP16
112
 
113
+ <details>
114
+ <summary> Click to expand </summary>
115
 
116
+ ```python
117
+ # pip install accelerate
118
+ import torch
119
+ from transformers import AutoTokenizer, AutoModelForCausalLM
120
 
121
+ tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay")
122
+ model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay", device_map="auto", torch_dtype=torch.float16)
123
 
124
+ input_text = "Question: How many hours in one day? Answer: "
125
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
126
 
127
+ outputs = model.generate(input_ids)
128
+ print(tokenizer.decode(outputs[0]))
129
+ ```
130
 
131
+ </details>
132
 
133
+ #### 4-bit
134
 
135
+ <details>
136
+ <summary> Click to expand </summary>
137
 
138
+ ```python
139
+ # pip install bitsandbytes accelerate
140
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
141
 
142
+ tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay")
143
+ model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-pre-decay", device_map="auto", quantization_config=BitsAndBytesConfig(load_in_4bit=True))
144
 
145
+ input_text = "Question: How many hours in one day? Answer: "
146
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
147
 
148
+ outputs = model.generate(input_ids)
149
+ print(tokenizer.decode(outputs[0]))
150
+ ```
151
 
152
+ </details>
153
 
154
+ <br>
155
 
156
+ # Training Details
157
 
158
+ ## Training Data
159
 
160
+ Falcon-Mamba has been trained with ~ 5,500 GT mainly coming from [Refined-Web](https://huggingface.co/datasets/tiiuae/falcon-refinedweb), a large volume web-only dataset filtered and deduplicated.
161
+ Similar to the others [Falcon](https://huggingface.co/tiiuae/falcon-11B) suite models, Falcon-Mamba has been trained leveraging a multi-stage training strategy to increase the context-length from 2,048 to 8,192.
162
+ Moreover, inspired by the concept of Curriculum Learning, we carefully selected data mixtures throughout the training stages, considering both data diversity and complexity.
163
+ Note that at inference the context-length is not relevant as the Mamba architecture has no limit on long range dependency.
164
+ At the last training stage, small portion of high-quality curated data was used to further enhance performance.
165
 
166
+ Overall, the data sources included RefinedWeb-English, high quality technical data, code data and math data extracted from public sources.
167
+ In particular, we used samples coming from [Fineweb-edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) during our last training stage.
168
 
169
+ The data was tokenized with the Falcon-[7B](https://huggingface.co/tiiuae/falcon-7B)/[11B](https://huggingface.co/tiiuae/falcon-11B) tokenizer.
170
 
171
+ ## Training Procedure
172
+ 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.
173
 
174
+ ### Training Hyperparameters
175
 
176
+ | **Hyperparameter** | **Value** | **Comment** |
177
+ |--------------------|------------|-------------------------------------------|
178
+ | Precision | `bfloat16` | |
179
+ | Optimizer | AdamW | |
180
+ | Max learning rate | 6.4e-4 | Following a WSD (warmup-stable-decay) learning rate schedule |
181
+ | Weight decay | 1e-1 | |
182
+ | Batch size | 2048 | |
183
 
 
184
 
185
+ 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.
186
+ 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.
187
+ 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.
188
 
189
+ ### Speeds, Sizes, Times
190
 
191
+ The model training took roughly two months.
192
 
193
+ <br>
194
 
195
+ # Evaluation
196
 
197
+ ## Benchmarks
198
 
199
+ 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.
200
 
 
201
 
202
+ | `model name` |`IFEval`| `BBH` |`MATH LvL5`| `GPQA`| `MUSR`|`MMLU-PRO`|`Average`|
203
+ |:--------------------------|:------:|:-----:|:---------:|:-----:|:-----:|:--------:|:-------:|
204
+ | ***Pure SSM models*** | | | | | | | |
205
+ | `FalconMamba-7B` | 33.36 | 19.88 | 3.63 |8.05 |10.86 | 14.47 |**15.04**|
206
+ | `TRI-ML/mamba-7b-rw`<sup>*</sup>| 22.46 | 6.71 | 0.45 | 1.12 | 5.51 | 1.69 | 6.25 |
207
+ |***Hybrid SSM-attention models*** | | | | | | |
208
+ |`recurrentgemma-9b` | 30.76 | 14.80 | 4.83 | 4.70 | 6.60 | 17.88 | 13.20 |
209
+ | `Zyphra/Zamba-7B-v1`<sup>*</sup> | 24.06 | 21.12 | 3.32 | 3.03 | 7.74 | 16.02 | 12.55 |
210
+ |***Transformer models*** | | | | | | | |
211
+ | `Falcon2-11B` | 32.61 | 21.94 | 2.34 | 2.80 | 7.53 | 15.44 | 13.78 |
212
+ | `Meta-Llama-3-8B` | 14.55 | 24.50 | 3.25 | 7.38 | 6.24 | 24.55 | 13.41 |
213
+ | `Meta-Llama-3.1-8B` | 12.70 | 25.29 | 4.61 | 6.15 | 8.98 | 24.95 | 13.78 |
214
+ | `Mistral-7B-v0.1` | 23.86 | 22.02 | 2.49 | 5.59 | 10.68 | 22.36 | 14.50 |
215
+ | `Mistral-Nemo-Base-2407 (12B)` | 16.83 | 29.37 | 4.98 | 5.82 | 6.52 | 27.46 | 15.08 |
216
+ | `gemma-7B` | 26.59 | 21.12 | 6.42 | 4.92 | 10.98 | 21.64 |**15.28**|
217
+ |***RWKV models*** | | | | | | | |
218
+ | `RWKV-v6-Finch-7B`<sup>*</sup> | 27.65 | 9.04 | 1.11 | 2.81 | 2.25 | 5.85 | 8.12 |
219
+ | `RWKV-v6-Finch-14B`<sup>*</sup> | 29.81 | 12.89 | 1.13 | 5.01 | 3.16 | 11.3 | 10.55 |
220
 
221
+ Also, we evaluate our model on the benchmarks of the first leaderboard using `lighteval`.
 
 
 
 
222
 
 
223
 
224
+ | `model name` |`ARC`|`HellaSwag` |`MMLU` |`Winogrande`|`TruthfulQA`|`GSM8K`|`Average` |
225
+ |:-----------------------------|:------:|:---------:|:-----:|:----------:|:----------:|:-----:|:----------------:|
226
+ | ***Pure SSM models*** | | | | | | | |
227
+ | `FalconMamba-7B`<sup>*</sup> | 62.03 | 80.82 | 62.11 | 73.64 | 53.42 | 52.54 | **64.09** |
228
+ | `TRI-ML/mamba-7b-rw`<sup>*</sup> | 51.25 | 80.85 | 33.41 | 71.11 | 32.08 | 4.70 | 45.52 |
229
+ |***Hybrid SSM-attention models***| | | | | | | |
230
+ | `recurrentgemma-9b`<sup>**</sup> |52.00 | 80.40 | 60.50 | 73.60 | 38.60 | 42.60 | 57.95 |
231
+ | `Zyphra/Zamba-7B-v1`<sup>*</sup> | 56.14 | 82.23 | 58.11 | 79.87 | 52.88 | 30.78 | 60.00 |
232
+ |***Transformer models*** | | | | | | | |
233
+ | `Falcon2-11B` | 59.73 | 82.91 | 58.37 | 78.30 | 52.56 | 53.83 | **64.28** |
234
+ | `Meta-Llama-3-8B` | 60.24 | 82.23 | 66.70 | 78.45 | 42.93 | 45.19 | 62.62 |
235
+ | `Meta-Llama-3.1-8B` | 58.53 | 82.13 | 66.43 | 74.35 | 44.29 | 47.92 | 62.28 |
236
+ | `Mistral-7B-v0.1` | 59.98 | 83.31 | 64.16 | 78.37 | 42.15 | 37.83 | 60.97 |
237
+ | `Mistral-Nemo-Base-2407 (12B)`<sup>*</sup> | 57.94 | 82.82 | 64.43 | 73.72 | 49.14 | 55.27 | 63.89 |
238
+ | `gemma-7B` | 61.09 | 82.20 | 64.56 | 79.01 | 44.79 | 50.87 | 63.75 |
239
+ |***RWKV models*** | | | | | | | |
240
+ | `RWKV-v6-Finch-7B`<sup>*</sup> | 43.86 | 75.19 | 41.69 | 68.27 | 42.19 | 19.64 | 48.47 |
241
+ | `RWKV-v6-Finch-14B`<sup>*</sup> | 47.44 | 78.86 | 52.33 | 71.27 | 45.45 | 38.06 | 55.57 |
242
 
243
+ 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.
244
 
245
+ ## Throughput
246
 
247
+ 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:
248
 
249
+ ```bash
250
+ pip install "causal-conv1d>=1.4.0" mamba-ssm
251
+ ```
252
 
253
+ Refer to our [FalconMamba blogpost](https://huggingface.co/blog/falconmamba) for more details about performance evaluation.
254
 
 
255
 
256
+ <br>
257
 
258
+ # Technical Specifications
259
 
260
+ ## Model Architecture and Objective
261
 
262
+ Falcon-Mamba-7B is a causal decoder-only model trained on a causal language modeling task (i.e., predict the next token).
263
 
264
+ The model is based on the Mamba architecture ([Gu et al., 2023](https://arxiv.org/abs/2312.00752)).
265
 
266
+ | **Hyperparameter** | **Value** | **Comment** |
267
+ |--------------------|-----------|----------------------------------------|
268
+ | Layers | 64 | Number of layers |
269
+ | `d_model` | 4096 | Hidden dimension |
270
+ | `d_state` | 16 | The SSM state dimension |
271
+ | Vocabulary | 65024 | Vocabulary Size |
272
+ | Sequence length | 8192 | During the last training stages |
273
 
274
+ ## Compute Infrastructure
275
 
276
+ ### Hardware
277
 
278
+ Falcon-Mamba-7B was trained on AWS SageMaker, using on average 256 H100 80GB GPUs in 32 p5 instances.
279
 
280
+ ### Software
281
 
282
+ 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.
283
 
284
+ <br>
285
 
286
+ # Citation
287
 
288
+ *Paper coming soon* 😊. In the meanwhile, you can use the following information to cite:
289
+ ```
290
+ @article{falconmamba,
291
+ title={Falcon Mamba: The First Competitive Attention-free 7B Language Model},
292
+ author={Zuo, Jingwei and Velikanov, Maksim and Rhaiem, Dhia Eddine and Chahed, Ilyas and Belkada, Younes and Kunsch, Guillaume and Hacid, Hakim},
293
+ year={2024}
294
+ }
295
+ ```