michaelfeil commited on
Commit
04e59f4
1 Parent(s): 417c17b

Upload tiiuae/falcon-7b ctranslate fp16 weights

Browse files
README.md ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - ctranslate2
4
+ - int8
5
+ - float16
6
+
7
+ datasets:
8
+ - tiiuae/falcon-refinedweb
9
+ language:
10
+ - en
11
+ inference: false
12
+ license: apache-2.0
13
+ ---
14
+ # # Fast-Inference with Ctranslate2
15
+ Speedup inference while reducing memory by 2x-4x using int8 inference in C++ on CPU or GPU.
16
+
17
+ quantized version of [tiiuae/falcon-7b](https://huggingface.co/tiiuae/falcon-7b)
18
+ ```bash
19
+ pip install hf-hub-ctranslate2>=2.0.8 ctranslate2>=3.14.0
20
+ ```
21
+ Converted on 2023-06-07 using
22
+ ```
23
+ ct2-transformers-converter --model tiiuae/falcon-7b --output_dir /home/michael/tmp-ct2fast-falcon-7b --force --copy_files tokenizer.json README.md tokenizer_config.json generation_config.json special_tokens_map.json .gitattributes --quantization int8_float16 --trust_remote_code
24
+ ```
25
+
26
+ Checkpoint compatible to [ctranslate2>=3.15.0](https://github.com/OpenNMT/CTranslate2)
27
+ and [hf-hub-ctranslate2>=2.0.8](https://github.com/michaelfeil/hf-hub-ctranslate2)
28
+ - `compute_type=int8_float16` for `device="cuda"`
29
+ - `compute_type=int8` for `device="cpu"`
30
+
31
+ ```python
32
+ from hf_hub_ctranslate2 import TranslatorCT2fromHfHub, GeneratorCT2fromHfHub
33
+ from transformers import AutoTokenizer
34
+
35
+ model_name = "michaelfeil/ct2fast-falcon-7b"
36
+ # use either TranslatorCT2fromHfHub or GeneratorCT2fromHfHub here, depending on model.
37
+ model = GeneratorCT2fromHfHub(
38
+ # load in int8 on CUDA
39
+ model_name_or_path=model_name,
40
+ device="cuda",
41
+ compute_type="int8_float16",
42
+ # tokenizer=AutoTokenizer.from_pretrained("tiiuae/falcon-7b")
43
+ )
44
+ outputs = model.generate(
45
+ text=["def fibonnaci(", "User: How are you doing? Bot:"],
46
+ max_length=64,
47
+ include_prompt_in_result=False
48
+ )
49
+ print(outputs)
50
+ ```
51
+
52
+ # Licence and other remarks:
53
+ This is just a quantized version. Licence conditions are intended to be idential to original huggingface repo.
54
+
55
+ # Original description
56
+
57
+
58
+ # 🚀 Falcon-7B
59
+
60
+ **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.**
61
+
62
+ *Paper coming soon* 😊.
63
+
64
+ ## Why use Falcon-7B?
65
+
66
+ * **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).
67
+ * **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)).
68
+ * **It is made available under a permissive Apache 2.0 license allowing for commercial use**, without any royalties or restrictions.
69
+
70
+ ⚠️ **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).
71
+
72
+ 🔥 **Looking for an even more powerful model?** [Falcon-40B](https://huggingface.co/tiiuae/falcon-40b) is Falcon-7B's big brother!
73
+
74
+ ```python
75
+ from transformers import AutoTokenizer, AutoModelForCausalLM
76
+ import transformers
77
+ import torch
78
+
79
+ model = "tiiuae/falcon-7b"
80
+
81
+ tokenizer = AutoTokenizer.from_pretrained(model)
82
+ pipeline = transformers.pipeline(
83
+ "text-generation",
84
+ model=model,
85
+ tokenizer=tokenizer,
86
+ torch_dtype=torch.bfloat16,
87
+ trust_remote_code=True,
88
+ device_map="auto",
89
+ )
90
+ sequences = pipeline(
91
+ "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:",
92
+ max_length=200,
93
+ do_sample=True,
94
+ top_k=10,
95
+ num_return_sequences=1,
96
+ eos_token_id=tokenizer.eos_token_id,
97
+ )
98
+ for seq in sequences:
99
+ print(f"Result: {seq['generated_text']}")
100
+
101
+ ```
102
+
103
+ 💥 **Falcon LLMs require PyTorch 2.0 for use with `transformers`!**
104
+
105
+
106
+ # Model Card for Falcon-7B
107
+
108
+ ## Model Details
109
+
110
+ ### Model Description
111
+
112
+ - **Developed by:** [https://www.tii.ae](https://www.tii.ae);
113
+ - **Model type:** Causal decoder-only;
114
+ - **Language(s) (NLP):** English and French;
115
+ - **License:** Apache 2.0.
116
+
117
+ ### Model Source
118
+
119
+ - **Paper:** *coming soon*.
120
+
121
+ ## Uses
122
+
123
+ ### Direct Use
124
+
125
+ Research on large language models; as a foundation for further specialization and finetuning for specific usecases (e.g., summarization, text generation, chatbot, etc.)
126
+
127
+ ### Out-of-Scope Use
128
+
129
+ Production use without adequate assessment of risks and mitigation; any use cases which may be considered irresponsible or harmful.
130
+
131
+ ## Bias, Risks, and Limitations
132
+
133
+ 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.
134
+
135
+ ### Recommendations
136
+
137
+ 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.
138
+
139
+ ## How to Get Started with the Model
140
+
141
+
142
+ ```python
143
+ from transformers import AutoTokenizer, AutoModelForCausalLM
144
+ import transformers
145
+ import torch
146
+
147
+ model = "tiiuae/falcon-7b"
148
+
149
+ tokenizer = AutoTokenizer.from_pretrained(model)
150
+ pipeline = transformers.pipeline(
151
+ "text-generation",
152
+ model=model,
153
+ tokenizer=tokenizer,
154
+ torch_dtype=torch.bfloat16,
155
+ trust_remote_code=True,
156
+ device_map="auto",
157
+ )
158
+ sequences = pipeline(
159
+ "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:",
160
+ max_length=200,
161
+ do_sample=True,
162
+ top_k=10,
163
+ num_return_sequences=1,
164
+ eos_token_id=tokenizer.eos_token_id,
165
+ )
166
+ for seq in sequences:
167
+ print(f"Result: {seq['generated_text']}")
168
+
169
+ ```
170
+
171
+ ## Training Details
172
+
173
+ ### Training Data
174
+
175
+ 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)).
176
+
177
+ | **Data source** | **Fraction** | **Tokens** | **Sources** |
178
+ |--------------------|--------------|------------|-----------------------------------|
179
+ | [RefinedWeb-English](https://huggingface.co/datasets/tiiuae/falcon-refinedweb) | 79% | 1,185B | massive web crawl |
180
+ | Books | 7% | 110B | |
181
+ | Conversations | 6% | 85B | Reddit, StackOverflow, HackerNews |
182
+ | Code | 3% | 45B | |
183
+ | RefinedWeb-French | 3% | 45B | massive web crawl |
184
+ | Technical | 2% | 30B | arXiv, PubMed, UPSTO, etc. |
185
+
186
+
187
+ The data was tokenized with the Falcon-[7B](https://huggingface.co/tiiuae/falcon-7b)/[40B](https://huggingface.co/tiiuae/falcon-40b) tokenizer.
188
+
189
+ ### Training Procedure
190
+
191
+ Falcon-7B was trained on 384 A100 40GB GPUs, using a 2D parallelism strategy (PP=2, DP=192) combined with ZeRO.
192
+
193
+ #### Training Hyperparameters
194
+
195
+ | **Hyperparameter** | **Value** | **Comment** |
196
+ |--------------------|------------|-------------------------------------------|
197
+ | Precision | `bfloat16` | |
198
+ | Optimizer | AdamW | |
199
+ | Learning rate | 6e-4 | 4B tokens warm-up, cosine decay to 1.2e-5 |
200
+ | Weight decay | 1e-1 | |
201
+ | Z-loss | 1e-4 | |
202
+ | Batch size | 2304 | 30B tokens ramp-up |
203
+
204
+
205
+ #### Speeds, Sizes, Times
206
+
207
+ Training happened in early March 2023 and took about two weeks.
208
+
209
+
210
+ ## Evaluation
211
+
212
+ *Paper coming soon*.
213
+
214
+ See the [OpenLLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard) for early results.
215
+
216
+
217
+ ## Technical Specifications
218
+
219
+ ### Model Architecture and Objective
220
+
221
+ Falcon-7B is a causal decoder-only model trained on a causal language modeling task (i.e., predict the next token).
222
+
223
+ The architecture is broadly adapted from the GPT-3 paper ([Brown et al., 2020](https://arxiv.org/abs/2005.14165)), with the following differences:
224
+
225
+ * **Positionnal embeddings:** rotary ([Su et al., 2021](https://arxiv.org/abs/2104.09864));
226
+ * **Attention:** multiquery ([Shazeer et al., 2019](https://arxiv.org/abs/1911.02150)) and FlashAttention ([Dao et al., 2022](https://arxiv.org/abs/2205.14135));
227
+ * **Decoder-block:** parallel attention/MLP with a single layer norm.
228
+
229
+ | **Hyperparameter** | **Value** | **Comment** |
230
+ |--------------------|-----------|----------------------------------------|
231
+ | Layers | 32 | |
232
+ | `d_model` | 4544 | Increased to compensate for multiquery |
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-7B was trained on AWS SageMaker, on 384 A100 40GB GPUs in P4d instances.
242
+
243
+ #### Software
244
+
245
+ 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.)
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
+ ## License
274
+
275
+ Falcon-7B is made available under the Apache 2.0 license.
276
+
277
+ ## Contact
278
+ falconllm@tii.ae
config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<|endoftext|>",
3
+ "eos_token": "<|endoftext|>",
4
+ "layer_norm_epsilon": null,
5
+ "unk_token": "<|endoftext|>"
6
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "transformers_version": "4.27.4"
6
+ }
model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3d6bdff77f55283dfab9dbdf3fcad65f991504f22303971bf475b64245e34397
3
+ size 6926392870
special_tokens_map.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ ">>TITLE<<",
4
+ ">>ABSTRACT<<",
5
+ ">>INTRODUCTION<<",
6
+ ">>SUMMARY<<",
7
+ ">>COMMENT<<",
8
+ ">>ANSWER<<",
9
+ ">>QUESTION<<",
10
+ ">>DOMAIN<<",
11
+ ">>PREFIX<<",
12
+ ">>SUFFIX<<",
13
+ ">>MIDDLE<<"
14
+ ],
15
+ "eos_token": "<|endoftext|>"
16
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "eos_token": "<|endoftext|>",
4
+ "model_max_length": 2048,
5
+ "name_or_path": "tiiuae/falcon_tokenizer",
6
+ "special_tokens_map_file": null,
7
+ "tokenizer_class": "PreTrainedTokenizerFast"
8
+ }
vocabulary.txt ADDED
The diff for this file is too large to render. See raw diff