Text Generation
GGUF
English
Inference Endpoints
conversational
mav23 commited on
Commit
1988bd4
·
verified ·
1 Parent(s): b6741ac

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. .gitattributes +1 -0
  2. README.md +321 -0
  3. falcon-mamba-7b-instruct.Q4_0.gguf +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ falcon-mamba-7b-instruct.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - tiiuae/falcon-refinedweb
4
+ - HuggingFaceFW/fineweb-edu
5
+ language:
6
+ - en
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
+ base_model: tiiuae/falcon-mamba-7b
11
+ pipeline_tag: text-generation
12
+ inference: true
13
+ ---
14
+
15
+ <img src="https://huggingface.co/datasets/tiiuae/documentation-images/resolve/main/falcon_mamba/thumbnail.png" alt="drawing" width="800"/>
16
+
17
+ **Model card for FalconMamba Instruct model**
18
+
19
+ # Table of Contents
20
+
21
+ 0. [TL;DR](#TL;DR)
22
+ 1. [Model Details](#model-details)
23
+ 2. [Usage](#usage)
24
+ 3. [Training Details](#training-details)
25
+ 4. [Evaluation](#evaluation)
26
+
27
+
28
+ # TL;DR
29
+
30
+ # Model Details
31
+
32
+ ## Model Description
33
+
34
+ - **Developed by:** [https://www.tii.ae](https://www.tii.ae)
35
+ - **Model type:** Causal decoder-only
36
+ - **Architecture:** Mamba
37
+ - **Language(s) (NLP):** Mainly English
38
+ - **License:** TII Falcon-Mamba License 2.0
39
+
40
+ <br>
41
+
42
+ # Usage
43
+
44
+ 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):
45
+
46
+ ## Using the Pytorch model
47
+
48
+ ### Running the model on a CPU
49
+
50
+ <details>
51
+ <summary> Click to expand </summary>
52
+
53
+ ```python
54
+ from transformers import AutoTokenizer, AutoModelForCausalLM
55
+
56
+ tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-instruct")
57
+ model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-instruct")
58
+
59
+ # We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
60
+ messages = [
61
+ {"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
62
+ ]
63
+
64
+ input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
65
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids
66
+
67
+ outputs = model.generate(input_ids, max_new_tokens=30)
68
+ print(tokenizer.decode(outputs[0]))
69
+ ```
70
+
71
+ </details>
72
+
73
+ ### Running the model on a GPU
74
+
75
+ <details>
76
+ <summary> Click to expand </summary>
77
+
78
+ ```python
79
+ # pip install accelerate
80
+ from transformers import AutoTokenizer, AutoModelForCausalLM
81
+
82
+ tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-instruct")
83
+ model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-instruct", device_map="auto")
84
+
85
+ # We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
86
+ messages = [
87
+ {"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
88
+ ]
89
+
90
+ input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
91
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
92
+
93
+ outputs = model.generate(input_ids, max_new_tokens=30)
94
+ print(tokenizer.decode(outputs[0]))
95
+ ```
96
+
97
+ </details>
98
+
99
+ ### Running the model on a GPU using `torch.compile`
100
+
101
+ <details>
102
+ <summary> Click to expand </summary>
103
+
104
+ ```python
105
+ import torch
106
+ from transformers import AutoTokenizer, AutoModelForCausalLM
107
+
108
+ tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-instruct")
109
+ model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-instruct", torch_dtype=torch.bfloat16).to(0)
110
+
111
+ model = torch.compile(model)
112
+
113
+ # We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
114
+ messages = [
115
+ {"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
116
+ ]
117
+ input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
118
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
119
+
120
+ outputs = model.generate(input_ids, max_new_tokens=30)
121
+ print(tokenizer.decode(outputs[0]))
122
+ ```
123
+
124
+ </details>
125
+
126
+
127
+ ### Running the model on a GPU using different precisions
128
+
129
+ #### FP16
130
+
131
+ <details>
132
+ <summary> Click to expand </summary>
133
+
134
+ ```python
135
+ # pip install accelerate
136
+ import torch
137
+ from transformers import AutoTokenizer, AutoModelForCausalLM
138
+
139
+ tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-instruct")
140
+ model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-instruct", device_map="auto", torch_dtype=torch.float16)
141
+
142
+ # We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
143
+ messages = [
144
+ {"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
145
+ ]
146
+ input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
147
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
148
+
149
+ outputs = model.generate(input_ids, max_new_tokens=30)
150
+ print(tokenizer.decode(outputs[0]))
151
+ ```
152
+
153
+ </details>
154
+
155
+ #### 4-bit
156
+
157
+ <details>
158
+ <summary> Click to expand </summary>
159
+
160
+ ```python
161
+ # pip install bitsandbytes accelerate
162
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
163
+
164
+ tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-mamba-7b-instruct")
165
+ model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-mamba-7b-instruct", device_map="auto", quantization_config=BitsAndBytesConfig(load_in_4bit=True))
166
+
167
+ # We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
168
+ messages = [
169
+ {"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
170
+ ]
171
+ input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
172
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
173
+
174
+ outputs = model.generate(input_ids, max_new_tokens=30)
175
+ print(tokenizer.decode(outputs[0]))
176
+ ```
177
+
178
+ </details>
179
+
180
+ <br>
181
+
182
+ # Training Details
183
+
184
+ ## Training Data
185
+
186
+ 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.
187
+ 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.
188
+ Moreover, inspired by the concept of Curriculum Learning, we carefully selected data mixtures throughout the training stages, considering both data diversity and complexity.
189
+ Note that at inference the context-length is not relevant as the Mamba architecture has no limit on long range dependency.
190
+ At the last training stage, small portion of high-quality curated data was used to further enhance performance.
191
+
192
+ Overall, the data sources included RefinedWeb-English, high quality technical data, code data and math data extracted from public sources.
193
+ In particular, we used samples coming from [Fineweb-edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) during our last training stage.
194
+
195
+ The data was tokenized with the Falcon-[7B](https://huggingface.co/tiiuae/falcon-7B)/[11B](https://huggingface.co/tiiuae/falcon-11B) tokenizer.
196
+
197
+ After pre-training, the model has been further fine-tuned on instruction data.
198
+
199
+ ## Training Procedure
200
+ 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.
201
+
202
+ ### Training Hyperparameters
203
+
204
+ | **Hyperparameter** | **Value** | **Comment** |
205
+ |--------------------|------------|-------------------------------------------|
206
+ | Precision | `bfloat16` | |
207
+ | Optimizer | AdamW | |
208
+ | Max learning rate | 6.4e-4 | Following a WSD (warmup-stable-decay) learning rate schedule |
209
+ | Weight decay | 1e-1 | |
210
+ | Batch size | 2048 | |
211
+
212
+
213
+ 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.
214
+ 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.
215
+ 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.
216
+
217
+ ### Speeds, Sizes, Times
218
+
219
+ The model training took roughly two months.
220
+
221
+ <br>
222
+
223
+ # Evaluation
224
+
225
+ ## Benchmarks
226
+
227
+ 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.
228
+
229
+
230
+ | `model name` |`IFEval`| `BBH` |`MATH LvL5`| `GPQA`| `MUSR`|`MMLU-PRO`|`Average`|
231
+ |:--------------------------|:------:|:-----:|:---------:|:-----:|:-----:|:--------:|:-------:|
232
+ | ***Pure SSM models*** | | | | | | | |
233
+ | `FalconMamba-7B` | 33.36 | 19.88 | 3.63 |8.05 |10.86 | 14.47 |**15.04**|
234
+ | `TRI-ML/mamba-7b-rw`<sup>*</sup>| 22.46 | 6.71 | 0.45 | 1.12 | 5.51 | 1.69 | 6.25 |
235
+ |***Hybrid SSM-attention models*** | | | | | | |
236
+ |`recurrentgemma-9b` | 30.76 | 14.80 | 4.83 | 4.70 | 6.60 | 17.88 | 13.20 |
237
+ | `Zyphra/Zamba-7B-v1`<sup>*</sup> | 24.06 | 21.12 | 3.32 | 3.03 | 7.74 | 16.02 | 12.55 |
238
+ |***Transformer models*** | | | | | | | |
239
+ | `Falcon2-11B` | 32.61 | 21.94 | 2.34 | 2.80 | 7.53 | 15.44 | 13.78 |
240
+ | `Meta-Llama-3-8B` | 14.55 | 24.50 | 3.25 | 7.38 | 6.24 | 24.55 | 13.41 |
241
+ | `Meta-Llama-3.1-8B` | 12.70 | 25.29 | 4.61 | 6.15 | 8.98 | 24.95 | 13.78 |
242
+ | `Mistral-7B-v0.1` | 23.86 | 22.02 | 2.49 | 5.59 | 10.68 | 22.36 | 14.50 |
243
+ | `Mistral-Nemo-Base-2407 (12B)` | 16.83 | 29.37 | 4.98 | 5.82 | 6.52 | 27.46 | 15.08 |
244
+ | `gemma-7B` | 26.59 | 21.12 | 6.42 | 4.92 | 10.98 | 21.64 |**15.28**|
245
+
246
+
247
+ Also, we evaluate our model on the benchmarks of the first leaderboard using `lighteval`.
248
+
249
+
250
+ | `model name` |`ARC`|`HellaSwag` |`MMLU` |`Winogrande`|`TruthfulQA`|`GSM8K`|`Average` |
251
+ |:-----------------------------|:------:|:---------:|:-----:|:----------:|:----------:|:-----:|:----------------:|
252
+ | ***Pure SSM models*** | | | | | | | |
253
+ | `FalconMamba-7B`<sup>*</sup> | 62.03 | 80.82 | 62.11 | 73.64 | 53.42 | 52.54 | **64.09** |
254
+ | `TRI-ML/mamba-7b-rw`<sup>*</sup> | 51.25 | 80.85 | 33.41 | 71.11 | 32.08 | 4.70 | 45.52 |
255
+ |***Hybrid SSM-attention models***| | | | | | | |
256
+ | `recurrentgemma-9b`<sup>**</sup> |52.00 | 80.40 | 60.50 | 73.60 | 38.60 | 42.60 | 57.95 |
257
+ | `Zyphra/Zamba-7B-v1`<sup>*</sup> | 56.14 | 82.23 | 58.11 | 79.87 | 52.88 | 30.78 | 60.00 |
258
+ |***Transformer models*** | | | | | | | |
259
+ | `Falcon2-11B` | 59.73 | 82.91 | 58.37 | 78.30 | 52.56 | 53.83 | **64.28** |
260
+ | `Meta-Llama-3-8B` | 60.24 | 82.23 | 66.70 | 78.45 | 42.93 | 45.19 | 62.62 |
261
+ | `Meta-Llama-3.1-8B` | 58.53 | 82.13 | 66.43 | 74.35 | 44.29 | 47.92 | 62.28 |
262
+ | `Mistral-7B-v0.1` | 59.98 | 83.31 | 64.16 | 78.37 | 42.15 | 37.83 | 60.97 |
263
+ | `gemma-7B` | 61.09 | 82.20 | 64.56 | 79.01 | 44.79 | 50.87 | 63.75 |
264
+
265
+ 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.
266
+
267
+ ## Throughput
268
+
269
+ 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:
270
+
271
+ ```bash
272
+ pip install "causal-conv1d>=1.4.0" mamba-ssm
273
+ ```
274
+
275
+ Refer to our [FalconMamba blogpost](https://huggingface.co/blog/falconmamba) for more details about performance evaluation.
276
+
277
+
278
+ <br>
279
+
280
+ # Technical Specifications
281
+
282
+ ## Model Architecture and Objective
283
+
284
+ Falcon-Mamba-7B is a causal decoder-only model trained on a causal language modeling task (i.e., predict the next token).
285
+
286
+ The model is based on the Mamba architecture ([Gu et al., 2023](https://arxiv.org/abs/2312.00752)).
287
+
288
+ | **Hyperparameter** | **Value** | **Comment** |
289
+ |--------------------|-----------|----------------------------------------|
290
+ | Layers | 64 | Number of layers |
291
+ | `d_model` | 4096 | Hidden dimension |
292
+ | `d_state` | 16 | The SSM state dimension |
293
+ | Vocabulary | 65024 | Vocabulary Size |
294
+ | Sequence length | 8192 | During the last training stages |
295
+
296
+ ## Compute Infrastructure
297
+
298
+ ### Hardware
299
+
300
+ Falcon-Mamba-7B was trained on AWS SageMaker, using on average 256 H100 80GB GPUs in 32 p5 instances.
301
+
302
+ ### Software
303
+
304
+ 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.
305
+
306
+ <br>
307
+
308
+ # Citation
309
+
310
+ You can use the following bibtex citation:
311
+ ```
312
+ @misc{zuo2024falconmambacompetitiveattentionfree,
313
+ title={Falcon Mamba: The First Competitive Attention-free 7B Language Model},
314
+ author={Jingwei Zuo and Maksim Velikanov and Dhia Eddine Rhaiem and Ilyas Chahed and Younes Belkada and Guillaume Kunsch and Hakim Hacid},
315
+ year={2024},
316
+ eprint={2410.05355},
317
+ archivePrefix={arXiv},
318
+ primaryClass={cs.CL},
319
+ url={https://arxiv.org/abs/2410.05355},
320
+ }
321
+ ```
falcon-mamba-7b-instruct.Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:70e19c97ba28117d31eaf9238196c8d29fdbc5aae07d76873a4cc5cd43795a95
3
+ size 4204231104