michaelfeil commited on
Commit
33a981f
·
1 Parent(s): 7d10bda

Upload tiiuae/falcon-7b-instruct ctranslate fp16 weights

Browse files
README.md ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - ctranslate2
4
+ - int8
5
+ - float16
6
+
7
+ datasets:
8
+ - tiiuae/falcon-refinedweb
9
+ language:
10
+ - en
11
+ inference: true
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-instruct](https://huggingface.co/tiiuae/falcon-7b-instruct)
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-instruct --output_dir /home/michael/tmp-ct2fast-falcon-7b-instruct --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-instruct"
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-instruct")
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-Instruct
59
+
60
+ **Falcon-7B-Instruct is a 7B parameters causal decoder-only model built by [TII](https://www.tii.ae) based on [Falcon-7B](https://huggingface.co/tiiuae/falcon-7b) and finetuned on a mixture of chat/instruct datasets. It is made available under the Apache 2.0 license.**
61
+
62
+ *Paper coming soon 😊.*
63
+
64
+ ## Why use Falcon-7B-Instruct?
65
+
66
+ * **You are looking for a ready-to-use chat/instruct model based on [Falcon-7B](https://huggingface.co/tiiuae/falcon-7b).**
67
+ * **Falcon-7B is a strong base model, outperforming 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).
68
+ * **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)).
69
+
70
+ 💬 **This is an instruct model, which may not be ideal for further finetuning.** If you are interested in building your own instruct/chat model, we recommend starting from [Falcon-7B](https://huggingface.co/tiiuae/falcon-7b).
71
+
72
+ 🔥 **Looking for an even more powerful model?** [Falcon-40B-Instruct](https://huggingface.co/tiiuae/falcon-40b-instruct) is Falcon-7B-Instruct's big brother!
73
+
74
+ ```python
75
+ from transformers import AutoTokenizer, AutoModelForCausalLM
76
+ import transformers
77
+ import torch
78
+
79
+ model = "tiiuae/falcon-7b-instruct"
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-Instruct
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
+ - **Finetuned from model:** [Falcon-7B](https://huggingface.co/tiiuae/falcon-7b).
117
+
118
+ ### Model Source
119
+
120
+ - **Paper:** *coming soon*.
121
+
122
+ ## Uses
123
+
124
+ ### Direct Use
125
+
126
+ Falcon-7B-Instruct has been finetuned on a mixture of instruct and chat datasets.
127
+
128
+ ### Out-of-Scope Use
129
+
130
+ Production use without adequate assessment of risks and mitigation; any use cases which may be considered irresponsible or harmful.
131
+
132
+ ## Bias, Risks, and Limitations
133
+
134
+ Falcon-7B-Instruct is mostly trained on English data, 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.
135
+
136
+ ### Recommendations
137
+
138
+ We recommend users of Falcon-7B-Instruct to develop guardrails and to take appropriate precautions for any production use.
139
+
140
+ ## How to Get Started with the Model
141
+
142
+
143
+ ```python
144
+ from transformers import AutoTokenizer, AutoModelForCausalLM
145
+ import transformers
146
+ import torch
147
+
148
+ model = "tiiuae/falcon-7b-instruct"
149
+
150
+ tokenizer = AutoTokenizer.from_pretrained(model)
151
+ pipeline = transformers.pipeline(
152
+ "text-generation",
153
+ model=model,
154
+ tokenizer=tokenizer,
155
+ torch_dtype=torch.bfloat16,
156
+ trust_remote_code=True,
157
+ device_map="auto",
158
+ )
159
+ sequences = pipeline(
160
+ "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:",
161
+ max_length=200,
162
+ do_sample=True,
163
+ top_k=10,
164
+ num_return_sequences=1,
165
+ eos_token_id=tokenizer.eos_token_id,
166
+ )
167
+ for seq in sequences:
168
+ print(f"Result: {seq['generated_text']}")
169
+
170
+ ```
171
+
172
+ ## Training Details
173
+
174
+ ### Training Data
175
+
176
+ Falcon-7B-Instruct was finetuned on a 250M tokens mixture of instruct/chat datasets.
177
+
178
+ | **Data source** | **Fraction** | **Tokens** | **Description** |
179
+ |--------------------|--------------|------------|-----------------------------------|
180
+ | [Bai ze](https://github.com/project-baize/baize-chatbot) | 65% | 164M | chat |
181
+ | [GPT4All](https://github.com/nomic-ai/gpt4all) | 25% | 62M | instruct |
182
+ | [GPTeacher](https://github.com/teknium1/GPTeacher) | 5% | 11M | instruct |
183
+ | [RefinedWeb-English](https://huggingface.co/datasets/tiiuae/falcon-refinedweb) | 5% | 13M | massive web crawl |
184
+
185
+
186
+ The data was tokenized with the Falcon-[7B](https://huggingface.co/tiiuae/falcon-7b)/[40B](https://huggingface.co/tiiuae/falcon-40b) tokenizer.
187
+
188
+
189
+ ## Evaluation
190
+
191
+ *Paper coming soon.*
192
+
193
+ See the [OpenLLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard) for early results.
194
+
195
+ Note that this model variant is not optimized for NLP benchmarks.
196
+
197
+
198
+ ## Technical Specifications
199
+
200
+ For more information about pretraining, see [Falcon-7B](https://huggingface.co/tiiuae/falcon-7b).
201
+
202
+ ### Model Architecture and Objective
203
+
204
+ Falcon-7B is a causal decoder-only model trained on a causal language modeling task (i.e., predict the next token).
205
+
206
+ The architecture is broadly adapted from the GPT-3 paper ([Brown et al., 2020](https://arxiv.org/abs/2005.14165)), with the following differences:
207
+
208
+ * **Positionnal embeddings:** rotary ([Su et al., 2021](https://arxiv.org/abs/2104.09864));
209
+ * **Attention:** multiquery ([Shazeer et al., 2019](https://arxiv.org/abs/1911.02150)) and FlashAttention ([Dao et al., 2022](https://arxiv.org/abs/2205.14135));
210
+ * **Decoder-block:** parallel attention/MLP with a single layer norm.
211
+
212
+ | **Hyperparameter** | **Value** | **Comment** |
213
+ |--------------------|-----------|----------------------------------------|
214
+ | Layers | 32 | |
215
+ | `d_model` | 4544 | Increased to compensate for multiquery |
216
+ | `head_dim` | 64 | Reduced to optimise for FlashAttention |
217
+ | Vocabulary | 65024 | |
218
+ | Sequence length | 2048 | |
219
+
220
+ ### Compute Infrastructure
221
+
222
+ #### Hardware
223
+
224
+ Falcon-7B-Instruct was trained on AWS SageMaker, on 32 A100 40GB GPUs in P4d instances.
225
+
226
+ #### Software
227
+
228
+ Falcon-7B-Instruct was trained a custom distributed training codebase, Gigatron. It uses a 3D parallelism approach combined with ZeRO and high-performance Triton kernels (FlashAttention, etc.)
229
+
230
+
231
+ ## Citation
232
+
233
+ *Paper coming soon* 😊. In the meanwhile, you can use the following information to cite:
234
+ ```
235
+ @article{falcon40b,
236
+ title={{Falcon-40B}: an open large language model with state-of-the-art performance},
237
+ 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},
238
+ year={2023}
239
+ }
240
+ ```
241
+
242
+ To learn more about the pretraining dataset, see the 📓 [RefinedWeb paper](https://arxiv.org/abs/2306.01116).
243
+
244
+ ```
245
+ @article{refinedweb,
246
+ title={The {R}efined{W}eb dataset for {F}alcon {LLM}: outperforming curated corpora with web data, and web data only},
247
+ 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},
248
+ journal={arXiv preprint arXiv:2306.01116},
249
+ eprint={2306.01116},
250
+ eprinttype = {arXiv},
251
+ url={https://arxiv.org/abs/2306.01116},
252
+ year={2023}
253
+ }
254
+ ```
255
+
256
+
257
+ ## License
258
+
259
+ Falcon-7B-Instruct is made available under the Apache 2.0 license.
260
+
261
+ ## Contact
262
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:3f18407937173d51d0b039e48080fc923b5f0871b86329e8629274ed5f27e18e
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