psinger commited on
Commit
06cc4a3
โ€ข
1 Parent(s): 106cbc4

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +245 -0
README.md ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - tiiuae/falcon-refinedweb
4
+ language:
5
+ - en
6
+ inference: false
7
+ license: apache-2.0
8
+ ---
9
+
10
+ # Fixes
11
+
12
+ โš ๏ธ **This is an unofficial fork of the original [Falcon-7B](https://huggingface.co/tiiuae/falcon-7b) model.**
13
+
14
+ The following changes have been made:
15
+ - Fixing generation configuration setting
16
+ - 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.
17
+
18
+
19
+ # ๐Ÿš€ Falcon-7B
20
+
21
+ **Falcon-7B is a 7B parameters causal decoder-only model built by [TII](https://www.tii.ae) and trained on 1,500B tokens of [RefinedWeb](https://huggingface.co/datasets/tiiuae/falcon-refinedweb) enhanced with curated corpora. It is made available under the Apache 2.0 license.**
22
+
23
+ *Paper coming soon* ๐Ÿ˜Š.
24
+
25
+ ๐Ÿค— To get started with Falcon (inference, finetuning, quantization, etc.), we recommend reading [this great blogpost fron HF](https://huggingface.co/blog/falcon)!
26
+
27
+
28
+ ## Why use Falcon-7B?
29
+
30
+ * **It outperforms comparable open-source models** (e.g., [MPT-7B](https://huggingface.co/mosaicml/mpt-7b), [StableLM](https://github.com/Stability-AI/StableLM), [RedPajama](https://huggingface.co/togethercomputer/RedPajama-INCITE-Base-7B-v0.1) etc.), thanks to being trained on 1,500B tokens of [RefinedWeb](https://huggingface.co/datasets/tiiuae/falcon-refinedweb) enhanced with curated corpora. See the [OpenLLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard).
31
+ * **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)).
32
+ * **It is made available under a permissive Apache 2.0 license allowing for commercial use**, without any royalties or restrictions.
33
+
34
+ โš ๏ธ **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-7B-Instruct](https://huggingface.co/tiiuae/falcon-7b-instruct).
35
+
36
+ ๐Ÿ”ฅ **Looking for an even more powerful model?** [Falcon-40B](https://huggingface.co/tiiuae/falcon-40b) is Falcon-7B's big brother!
37
+
38
+ ```python
39
+ from transformers import AutoTokenizer, AutoModelForCausalLM
40
+ import transformers
41
+ import torch
42
+
43
+ model = "tiiuae/falcon-7b"
44
+
45
+ tokenizer = AutoTokenizer.from_pretrained(model)
46
+ pipeline = transformers.pipeline(
47
+ "text-generation",
48
+ model=model,
49
+ tokenizer=tokenizer,
50
+ torch_dtype=torch.bfloat16,
51
+ trust_remote_code=True,
52
+ device_map="auto",
53
+ )
54
+ sequences = pipeline(
55
+ "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:",
56
+ max_length=200,
57
+ do_sample=True,
58
+ top_k=10,
59
+ num_return_sequences=1,
60
+ eos_token_id=tokenizer.eos_token_id,
61
+ )
62
+ for seq in sequences:
63
+ print(f"Result: {seq['generated_text']}")
64
+
65
+ ```
66
+
67
+ ๐Ÿ’ฅ **Falcon LLMs require PyTorch 2.0 for use with `transformers`!**
68
+
69
+ 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).
70
+
71
+ You will need **at least 16GB of memory** to swiftly run inference with Falcon-7B.
72
+
73
+ # Model Card for Falcon-7B
74
+
75
+ ## Model Details
76
+
77
+ ### Model Description
78
+
79
+ - **Developed by:** [https://www.tii.ae](https://www.tii.ae);
80
+ - **Model type:** Causal decoder-only;
81
+ - **Language(s) (NLP):** English and French;
82
+ - **License:** Apache 2.0.
83
+
84
+ ### Model Source
85
+
86
+ - **Paper:** *coming soon*.
87
+
88
+ ## Uses
89
+
90
+ ### Direct Use
91
+
92
+ Research on large language models; as a foundation for further specialization and finetuning for specific usecases (e.g., summarization, text generation, chatbot, etc.)
93
+
94
+ ### Out-of-Scope Use
95
+
96
+ Production use without adequate assessment of risks and mitigation; any use cases which may be considered irresponsible or harmful.
97
+
98
+ ## Bias, Risks, and Limitations
99
+
100
+ Falcon-7B is trained on English and French data only, and 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.
101
+
102
+ ### Recommendations
103
+
104
+ We recommend users of Falcon-7B 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.
105
+
106
+ ## How to Get Started with the Model
107
+
108
+
109
+ ```python
110
+ from transformers import AutoTokenizer, AutoModelForCausalLM
111
+ import transformers
112
+ import torch
113
+
114
+ model = "tiiuae/falcon-7b"
115
+
116
+ tokenizer = AutoTokenizer.from_pretrained(model)
117
+ pipeline = transformers.pipeline(
118
+ "text-generation",
119
+ model=model,
120
+ tokenizer=tokenizer,
121
+ torch_dtype=torch.bfloat16,
122
+ trust_remote_code=True,
123
+ device_map="auto",
124
+ )
125
+ sequences = pipeline(
126
+ "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:",
127
+ max_length=200,
128
+ do_sample=True,
129
+ top_k=10,
130
+ num_return_sequences=1,
131
+ eos_token_id=tokenizer.eos_token_id,
132
+ )
133
+ for seq in sequences:
134
+ print(f"Result: {seq['generated_text']}")
135
+
136
+ ```
137
+
138
+ ## Training Details
139
+
140
+ ### Training Data
141
+
142
+ Falcon-7B was trained on 1,500B 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)).
143
+
144
+ | **Data source** | **Fraction** | **Tokens** | **Sources** |
145
+ |--------------------|--------------|------------|-----------------------------------|
146
+ | [RefinedWeb-English](https://huggingface.co/datasets/tiiuae/falcon-refinedweb) | 79% | 1,185B | massive web crawl |
147
+ | Books | 7% | 110B | |
148
+ | Conversations | 6% | 85B | Reddit, StackOverflow, HackerNews |
149
+ | Code | 3% | 45B | |
150
+ | RefinedWeb-French | 3% | 45B | massive web crawl |
151
+ | Technical | 2% | 30B | arXiv, PubMed, USPTO, etc. |
152
+
153
+
154
+ The data was tokenized with the Falcon-[7B](https://huggingface.co/tiiuae/falcon-7b)/[40B](https://huggingface.co/tiiuae/falcon-40b) tokenizer.
155
+
156
+ ### Training Procedure
157
+
158
+ Falcon-7B was trained on 384 A100 40GB GPUs, using a 2D parallelism strategy (PP=2, DP=192) combined with ZeRO.
159
+
160
+ #### Training Hyperparameters
161
+
162
+ | **Hyperparameter** | **Value** | **Comment** |
163
+ |--------------------|------------|-------------------------------------------|
164
+ | Precision | `bfloat16` | |
165
+ | Optimizer | AdamW | |
166
+ | Learning rate | 6e-4 | 4B tokens warm-up, cosine decay to 1.2e-5 |
167
+ | Weight decay | 1e-1 | |
168
+ | Z-loss | 1e-4 | |
169
+ | Batch size | 2304 | 30B tokens ramp-up |
170
+
171
+
172
+ #### Speeds, Sizes, Times
173
+
174
+ Training happened in early March 2023 and took about two weeks.
175
+
176
+
177
+ ## Evaluation
178
+
179
+ *Paper coming soon*.
180
+
181
+ See the [OpenLLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard) for early results.
182
+
183
+
184
+ ## Technical Specifications
185
+
186
+ ### Model Architecture and Objective
187
+
188
+ Falcon-7B is a causal decoder-only model trained on a causal language modeling task (i.e., predict the next token).
189
+
190
+ The architecture is broadly adapted from the GPT-3 paper ([Brown et al., 2020](https://arxiv.org/abs/2005.14165)), with the following differences:
191
+
192
+ * **Positionnal embeddings:** rotary ([Su et al., 2021](https://arxiv.org/abs/2104.09864));
193
+ * **Attention:** multiquery ([Shazeer et al., 2019](https://arxiv.org/abs/1911.02150)) and FlashAttention ([Dao et al., 2022](https://arxiv.org/abs/2205.14135));
194
+ * **Decoder-block:** parallel attention/MLP with a single layer norm.
195
+
196
+ | **Hyperparameter** | **Value** | **Comment** |
197
+ |--------------------|-----------|----------------------------------------|
198
+ | Layers | 32 | |
199
+ | `d_model` | 4544 | Increased to compensate for multiquery |
200
+ | `head_dim` | 64 | Reduced to optimise for FlashAttention |
201
+ | Vocabulary | 65024 | |
202
+ | Sequence length | 2048 | |
203
+
204
+ ### Compute Infrastructure
205
+
206
+ #### Hardware
207
+
208
+ Falcon-7B was trained on AWS SageMaker, on 384 A100 40GB GPUs in P4d instances.
209
+
210
+ #### Software
211
+
212
+ Falcon-7B was trained a custom distributed training codebase, Gigatron. It uses a 3D parallelism approach combined with ZeRO and high-performance Triton kernels (FlashAttention, etc.)
213
+
214
+
215
+ ## Citation
216
+
217
+ *Paper coming soon* ๐Ÿ˜Š. In the meanwhile, you can use the following information to cite:
218
+ ```
219
+ @article{falcon40b,
220
+ title={{Falcon-40B}: an open large language model with state-of-the-art performance},
221
+ 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},
222
+ year={2023}
223
+ }
224
+ ```
225
+
226
+ To learn more about the pretraining dataset, see the ๐Ÿ““ [RefinedWeb paper](https://arxiv.org/abs/2306.01116).
227
+
228
+ ```
229
+ @article{refinedweb,
230
+ title={The {R}efined{W}eb dataset for {F}alcon {LLM}: outperforming curated corpora with web data, and web data only},
231
+ 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},
232
+ journal={arXiv preprint arXiv:2306.01116},
233
+ eprint={2306.01116},
234
+ eprinttype = {arXiv},
235
+ url={https://arxiv.org/abs/2306.01116},
236
+ year={2023}
237
+ }
238
+ ```
239
+
240
+ ## License
241
+
242
+ Falcon-7B is made available under the Apache 2.0 license.
243
+
244
+ ## Contact
245
+ falconllm@tii.ae