psinger commited on
Commit
20f87e8
โ€ข
1 Parent(s): 761cf67

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +279 -0
README.md ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - tiiuae/falcon-refinedweb
4
+ language:
5
+ - en
6
+ - de
7
+ - es
8
+ - fr
9
+ inference: false
10
+ license: apache-2.0
11
+ ---
12
+
13
+ โš ๏ธ **This is an unofficial fork of the original [Falcon-40B](https://huggingface.co/tiiuae/falcon-40b) model.**
14
+
15
+ The following changes have been made:
16
+ - Fixing generation configuration setting
17
+ - Model now properly uses specified ```attention_mask``` when calling ```scaled_dot_product_attention``` - this also allows to specify custom attention masks and work with left-padded input.
18
+
19
+
20
+ # ๐Ÿš€ Falcon-40B
21
+
22
+ **Falcon-40B is a 40B parameters causal decoder-only model built by [TII](https://www.tii.ae) and trained on 1,000B tokens of [RefinedWeb](https://huggingface.co/datasets/tiiuae/falcon-refinedweb) enhanced with curated corpora. It is made available under the Apache 2.0 license.**
23
+
24
+ *Paper coming soon ๐Ÿ˜Š.*
25
+
26
+
27
+
28
+ # Call for Proposals : Falcon 40B - World's Top Ranked AI Model Empowers Exceptional Use Cases with Training Compute Power in Call for Proposals
29
+
30
+ We get it. AI is everywhere! Is it taking over?
31
+
32
+ Before we debate the scant likelihood of a cyborg assassin from the future terminating humanity, letโ€™s get to know the newbie that has soared to top-spot on the leaderboard โ€“ Falcon 40B.
33
+
34
+ Falcon 40B is the UAEโ€™s and the Middle Eastโ€™s first home-grown, open-source large language model (LLM) with 40 billion parameters trained on one trillion tokens. The brainchild of the Technology Innovation Institute (TII), Falcon 40B has generated a tremendous amount of global interest and intrigue, but what really sweetens the deal is its transparent, open-source feature.
35
+
36
+ TII is now calling for proposals from users worldwide to submit their most creative ideas for Falcon 40Bโ€™s deployment โ€“ allowing them to share their knowledge, enhance the software, and potentially transform their ideas into reality! Take that, ChatGPT!
37
+ Worth checking out? Give it a go and see for yourself!
38
+
39
+ Submit your proposal today! https://falconllm.tii.ae/call-for-proposal.php
40
+
41
+
42
+ ๐Ÿค— To get started with Falcon (inference, finetuning, quantization, etc.), we recommend reading [this great blogpost fron HF](https://huggingface.co/blog/falcon)!
43
+
44
+ ## Why use Falcon-40B?
45
+
46
+ * **It is the best open-source model currently available.** Falcon-40B outperforms [LLaMA](https://github.com/facebookresearch/llama), [StableLM](https://github.com/Stability-AI/StableLM), [RedPajama](https://huggingface.co/togethercomputer/RedPajama-INCITE-Base-7B-v0.1), [MPT](https://huggingface.co/mosaicml/mpt-7b), etc. See the [OpenLLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard).
47
+ * **It features an architecture optimized for inference**, with FlashAttention ([Dao et al., 2022](https://arxiv.org/abs/2205.14135)) and multiquery ([Shazeer et al., 2019](https://arxiv.org/abs/1911.02150)).
48
+ * **It is made available under a permissive Apache 2.0 license allowing for commercial use**, without any royalties or restrictions.
49
+ *
50
+ โš ๏ธ **This is a raw, pretrained model, which should be further finetuned for most usecases.** If you are looking for a version better suited to taking generic instructions in a chat format, we recommend taking a look at [Falcon-40B-Instruct](https://huggingface.co/tiiuae/falcon-40b-instruct).
51
+
52
+ ๐Ÿ’ธ **Looking for a smaller, less expensive model?** [Falcon-7B](https://huggingface.co/tiiuae/falcon-7b) is Falcon-40B's little brother!
53
+
54
+ ```python
55
+ from transformers import AutoTokenizer, AutoModelForCausalLM
56
+ import transformers
57
+ import torch
58
+
59
+ model = "tiiuae/falcon-40b"
60
+
61
+ tokenizer = AutoTokenizer.from_pretrained(model)
62
+ pipeline = transformers.pipeline(
63
+ "text-generation",
64
+ model=model,
65
+ tokenizer=tokenizer,
66
+ torch_dtype=torch.bfloat16,
67
+ trust_remote_code=True,
68
+ device_map="auto",
69
+ )
70
+ sequences = pipeline(
71
+ "Girafatron is obsessed with giraffes, the most glorious animal on the face of this Earth. Giraftron believes all other animals are irrelevant when compared to the glorious majesty of the giraffe.\nDaniel: Hello, Girafatron!\nGirafatron:",
72
+ max_length=200,
73
+ do_sample=True,
74
+ top_k=10,
75
+ num_return_sequences=1,
76
+ eos_token_id=tokenizer.eos_token_id,
77
+ )
78
+ for seq in sequences:
79
+ print(f"Result: {seq['generated_text']}")
80
+
81
+ ```
82
+
83
+ ๐Ÿ’ฅ **Falcon LLMs require PyTorch 2.0 for use with `transformers`!**
84
+
85
+ For fast inference with Falcon, check-out [Text Generation Inference](https://github.com/huggingface/text-generation-inference)! Read more in this [blogpost]((https://huggingface.co/blog/falcon).
86
+
87
+ You will need **at least 85-100GB of memory** to swiftly run inference with Falcon-40B.
88
+
89
+ # Model Card for Falcon-40B
90
+
91
+ ## Model Details
92
+
93
+ ### Model Description
94
+
95
+ - **Developed by:** [https://www.tii.ae](https://www.tii.ae);
96
+ - **Model type:** Causal decoder-only;
97
+ - **Language(s) (NLP):** English, German, Spanish, French (and limited capabilities in Italian, Portuguese, Polish, Dutch, Romanian, Czech, Swedish);
98
+ - **License:** Apache 2.0 license.
99
+
100
+ ### Model Source
101
+
102
+ - **Paper:** *coming soon*.
103
+
104
+ ## Uses
105
+
106
+ ### Direct Use
107
+
108
+ Research on large language models; as a foundation for further specialization and finetuning for specific usecases (e.g., summarization, text generation, chatbot, etc.)
109
+
110
+ ### Out-of-Scope Use
111
+
112
+ Production use without adequate assessment of risks and mitigation; any use cases which may be considered irresponsible or harmful.
113
+
114
+ ## Bias, Risks, and Limitations
115
+
116
+ Falcon-40B is trained mostly on English, German, Spanish, French, with limited capabilities also in in Italian, Portuguese, Polish, Dutch, Romanian, Czech, Swedish. It will not generalize appropriately to other languages. Furthermore, as it is trained on a large-scale corpora representative of the web, it will carry the stereotypes and biases commonly encountered online.
117
+
118
+ ### Recommendations
119
+
120
+ We recommend users of Falcon-40B to consider finetuning it for the specific set of tasks of interest, and for guardrails and appropriate precautions to be taken for any production use.
121
+
122
+ ## How to Get Started with the Model
123
+
124
+
125
+ ```python
126
+ from transformers import AutoTokenizer, AutoModelForCausalLM
127
+ import transformers
128
+ import torch
129
+
130
+ model = "tiiuae/falcon-40b"
131
+
132
+ tokenizer = AutoTokenizer.from_pretrained(model)
133
+ pipeline = transformers.pipeline(
134
+ "text-generation",
135
+ model=model,
136
+ tokenizer=tokenizer,
137
+ torch_dtype=torch.bfloat16,
138
+ trust_remote_code=True,
139
+ device_map="auto",
140
+ )
141
+ sequences = pipeline(
142
+ "Girafatron is obsessed with giraffes, the most glorious animal on the face of this Earth. Giraftron believes all other animals are irrelevant when compared to the glorious majesty of the giraffe.\nDaniel: Hello, Girafatron!\nGirafatron:",
143
+ max_length=200,
144
+ do_sample=True,
145
+ top_k=10,
146
+ num_return_sequences=1,
147
+ eos_token_id=tokenizer.eos_token_id,
148
+ )
149
+ for seq in sequences:
150
+ print(f"Result: {seq['generated_text']}")
151
+
152
+ ```
153
+
154
+ ## Training Details
155
+
156
+ ### Training Data
157
+
158
+ Falcon-40B was trained on 1,000B tokens of [RefinedWeb](https://huggingface.co/datasets/tiiuae/falcon-refinedweb), a high-quality filtered and deduplicated web dataset which we enhanced with curated corpora. Significant components from our curated copora were inspired by The Pile ([Gao et al., 2020](https://arxiv.org/abs/2101.00027)).
159
+
160
+ | **Data source** | **Fraction** | **Tokens** | **Sources** |
161
+ |--------------------|--------------|------------|-----------------------------------|
162
+ | [RefinedWeb-English](https://huggingface.co/datasets/tiiuae/falcon-refinedweb) | 75% | 750B | massive web crawl |
163
+ | RefinedWeb-Europe | 7% | 70B | European massive web crawl |
164
+ | Books | 6% | 60B | |
165
+ | Conversations | 5% | 50B | Reddit, StackOverflow, HackerNews |
166
+ | Code | 5% | 50B | |
167
+ | Technical | 2% | 20B | arXiv, PubMed, USPTO, etc. |
168
+
169
+ RefinedWeb-Europe is made of the following languages:
170
+
171
+ | **Language** | **Fraction of multilingual data** | **Tokens** |
172
+ |--------------|-----------------------------------|------------|
173
+ | German | 26% | 18B |
174
+ | Spanish | 24% | 17B |
175
+ | French | 23% | 16B |
176
+ | _Italian_ | 7% | 5B |
177
+ | _Portuguese_ | 4% | 3B |
178
+ | _Polish_ | 4% | 3B |
179
+ | _Dutch_ | 4% | 3B |
180
+ | _Romanian_ | 3% | 2B |
181
+ | _Czech_ | 3% | 2B |
182
+ | _Swedish_ | 2% | 1B |
183
+
184
+
185
+ The data was tokenized with the Falcon-[7B](https://huggingface.co/tiiuae/falcon-7b)/[40B](https://huggingface.co/tiiuae/falcon-40b) tokenizer.
186
+
187
+ ### Training Procedure
188
+
189
+ Falcon-40B was trained on 384 A100 40GB GPUs, using a 3D parallelism strategy (TP=8, PP=4, DP=12) combined with ZeRO.
190
+
191
+ #### Training Hyperparameters
192
+
193
+ | **Hyperparameter** | **Value** | **Comment** |
194
+ |--------------------|------------|-------------------------------------------|
195
+ | Precision | `bfloat16` | |
196
+ | Optimizer | AdamW | |
197
+ | Learning rate | 1.85e-4 | 4B tokens warm-up, cosine decay to 1.85e-5 |
198
+ | Weight decay | 1e-1 | |
199
+ | Z-loss | 1e-4 | |
200
+ | Batch size | 1152 | 100B tokens ramp-up |
201
+
202
+
203
+ #### Speeds, Sizes, Times
204
+
205
+ Training started in December 2022 and took two months.
206
+
207
+
208
+ ## Evaluation
209
+
210
+ *Paper coming soon.*
211
+
212
+ See the [OpenLLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard) for early results.
213
+
214
+
215
+ ## Technical Specifications
216
+
217
+ ### Model Architecture and Objective
218
+
219
+ Falcon-40B is a causal decoder-only model trained on a causal language modeling task (i.e., predict the next token).
220
+
221
+ The architecture is broadly adapted from the GPT-3 paper ([Brown et al., 2020](https://arxiv.org/abs/2005.14165)), with the following differences:
222
+
223
+ * **Positionnal embeddings:** rotary ([Su et al., 2021](https://arxiv.org/abs/2104.09864));
224
+ * **Attention:** multiquery ([Shazeer et al., 2019](https://arxiv.org/abs/1911.02150)) and FlashAttention ([Dao et al., 2022](https://arxiv.org/abs/2205.14135));
225
+ * **Decoder-block:** parallel attention/MLP with a two layer norms.
226
+
227
+ For multiquery, we are using an internal variant which uses independent key and values per tensor parallel degree.
228
+
229
+ | **Hyperparameter** | **Value** | **Comment** |
230
+ |--------------------|-----------|----------------------------------------|
231
+ | Layers | 60 | |
232
+ | `d_model` | 8192 | |
233
+ | `head_dim` | 64 | Reduced to optimise for FlashAttention |
234
+ | Vocabulary | 65024 | |
235
+ | Sequence length | 2048 | |
236
+
237
+ ### Compute Infrastructure
238
+
239
+ #### Hardware
240
+
241
+ Falcon-40B was trained on AWS SageMaker, on 384 A100 40GB GPUs in P4d instances.
242
+
243
+ #### Software
244
+
245
+ Falcon-40B was trained a custom distributed training codebase, Gigatron. It uses a 3D parallelism approach combined with ZeRO and high-performance Triton kernels (FlashAttention, etc.)
246
+
247
+
248
+ ## Citation
249
+
250
+ *Paper coming soon* ๐Ÿ˜Š. In the meanwhile, you can use the following information to cite:
251
+ ```
252
+ @article{falcon40b,
253
+ title={{Falcon-40B}: an open large language model with state-of-the-art performance},
254
+ author={Almazrouei, Ebtesam and Alobeidli, Hamza and Alshamsi, Abdulaziz and Cappelli, Alessandro and Cojocaru, Ruxandra and Debbah, Merouane and Goffinet, Etienne and Heslow, Daniel and Launay, Julien and Malartic, Quentin and Noune, Badreddine and Pannier, Baptiste and Penedo, Guilherme},
255
+ year={2023}
256
+ }
257
+ ```
258
+
259
+ To learn more about the pretraining dataset, see the ๐Ÿ““ [RefinedWeb paper](https://arxiv.org/abs/2306.01116).
260
+
261
+ ```
262
+ @article{refinedweb,
263
+ title={The {R}efined{W}eb dataset for {F}alcon {LLM}: outperforming curated corpora with web data, and web data only},
264
+ author={Guilherme Penedo and Quentin Malartic and Daniel Hesslow and Ruxandra Cojocaru and Alessandro Cappelli and Hamza Alobeidli and Baptiste Pannier and Ebtesam Almazrouei and Julien Launay},
265
+ journal={arXiv preprint arXiv:2306.01116},
266
+ eprint={2306.01116},
267
+ eprinttype = {arXiv},
268
+ url={https://arxiv.org/abs/2306.01116},
269
+ year={2023}
270
+ }
271
+ ```
272
+
273
+
274
+ ## License
275
+
276
+ Falcon-40B is made available under the Apache 2.0 license.
277
+
278
+ ## Contact
279
+ falconllm@tii.ae