TheBloke commited on
Commit
2797d43
1 Parent(s): e3149d2

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +590 -0
README.md ADDED
@@ -0,0 +1,590 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: lightonai/alfred-40b-1023
3
+ datasets:
4
+ - OpenAssistant/oasst1
5
+ - ehartford/dolphin
6
+ - tau/sled
7
+ - tiiuae/falcon-refinedweb
8
+ inference: false
9
+ language:
10
+ - en
11
+ - fr
12
+ - de
13
+ - es
14
+ - it
15
+ license: apache-2.0
16
+ model_creator: LightOn AI
17
+ model_name: Alfred 40B 1023
18
+ model_type: falcon
19
+ prompt_template: '<start_system>You are Alfred, a helpful assistant trained by LightOn.
20
+ Knowledge cutoff: November 2022. Current date: 16 November, 2023<end_message><start_user>{prompt}<end_message><start_assistant>
21
+
22
+ '
23
+ quantized_by: TheBloke
24
+ tags:
25
+ - falcon-40b
26
+ - long-context
27
+ - falcon
28
+ - NTK-YaRN
29
+ thumbnail: images/alfred-40b-1023.png
30
+ ---
31
+ <!-- markdownlint-disable MD041 -->
32
+
33
+ <!-- header start -->
34
+ <!-- 200823 -->
35
+ <div style="width: auto; margin-left: auto; margin-right: auto">
36
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
37
+ </div>
38
+ <div style="display: flex; justify-content: space-between; width: 100%;">
39
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
40
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
41
+ </div>
42
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
43
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
44
+ </div>
45
+ </div>
46
+ <div style="text-align:center; margin-top: 0em; margin-bottom: 0em"><p style="margin-top: 0.25em; margin-bottom: 0em;">TheBloke's LLM work is generously supported by a grant from <a href="https://a16z.com">andreessen horowitz (a16z)</a></p></div>
47
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
48
+ <!-- header end -->
49
+
50
+ # Alfred 40B 1023 - GPTQ
51
+ - Model creator: [LightOn AI](https://huggingface.co/lightonai)
52
+ - Original model: [Alfred 40B 1023](https://huggingface.co/lightonai/alfred-40b-1023)
53
+
54
+ <!-- description start -->
55
+ # Description
56
+
57
+ This repo contains GPTQ model files for [LightOn AI's Alfred 40B 1023](https://huggingface.co/lightonai/alfred-40b-1023).
58
+
59
+ Multiple GPTQ parameter permutations are provided; see Provided Files below for details of the options provided, their parameters, and the software used to create them.
60
+
61
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
62
+
63
+ <!-- description end -->
64
+ <!-- repositories-available start -->
65
+ ## Repositories available
66
+
67
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/alfred-40B-1023-AWQ)
68
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/alfred-40B-1023-GPTQ)
69
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/alfred-40B-1023-GGUF)
70
+ * [LightOn AI's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/lightonai/alfred-40b-1023)
71
+ <!-- repositories-available end -->
72
+
73
+ <!-- prompt-template start -->
74
+ ## Prompt template: Alfred
75
+
76
+ ```
77
+ <start_system>You are Alfred, a helpful assistant trained by LightOn. Knowledge cutoff: November 2022. Current date: 16 November, 2023<end_message><start_user>{prompt}<end_message><start_assistant>
78
+
79
+ ```
80
+
81
+ <!-- prompt-template end -->
82
+
83
+
84
+
85
+ <!-- README_GPTQ.md-compatible clients start -->
86
+ ## Known compatible clients / servers
87
+
88
+ These GPTQ models are known to work in the following inference servers/webuis.
89
+
90
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
91
+ - [KoboldAI United](https://github.com/henk717/koboldai)
92
+ - [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui)
93
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
94
+
95
+ This may not be a complete list; if you know of others, please let me know!
96
+ <!-- README_GPTQ.md-compatible clients end -->
97
+
98
+ <!-- README_GPTQ.md-provided-files start -->
99
+ ## Provided files, and GPTQ parameters
100
+
101
+ Multiple quantisation parameters are provided, to allow you to choose the best one for your hardware and requirements.
102
+
103
+ Each separate quant is in a different branch. See below for instructions on fetching from different branches.
104
+
105
+ Most GPTQ files are made with AutoGPTQ. Mistral models are currently made with Transformers.
106
+
107
+ <details>
108
+ <summary>Explanation of GPTQ parameters</summary>
109
+
110
+ - Bits: The bit size of the quantised model.
111
+ - GS: GPTQ group size. Higher numbers use less VRAM, but have lower quantisation accuracy. "None" is the lowest possible value.
112
+ - Act Order: True or False. Also known as `desc_act`. True results in better quantisation accuracy. Some GPTQ clients have had issues with models that use Act Order plus Group Size, but this is generally resolved now.
113
+ - Damp %: A GPTQ parameter that affects how samples are processed for quantisation. 0.01 is default, but 0.1 results in slightly better accuracy.
114
+ - GPTQ dataset: The calibration dataset used during quantisation. Using a dataset more appropriate to the model's training can improve quantisation accuracy. Note that the GPTQ calibration dataset is not the same as the dataset used to train the model - please refer to the original model repo for details of the training dataset(s).
115
+ - Sequence Length: The length of the dataset sequences used for quantisation. Ideally this is the same as the model sequence length. For some very long sequence models (16+K), a lower sequence length may have to be used. Note that a lower sequence length does not limit the sequence length of the quantised model. It only impacts the quantisation accuracy on longer inference sequences.
116
+ - ExLlama Compatibility: Whether this file can be loaded with ExLlama, which currently only supports Llama and Mistral models in 4-bit.
117
+
118
+ </details>
119
+
120
+ | Branch | Bits | GS | Act Order | Damp % | GPTQ Dataset | Seq Len | Size | ExLlama | Desc |
121
+ | ------ | ---- | -- | --------- | ------ | ------------ | ------- | ---- | ------- | ---- |
122
+ | [main](https://huggingface.co/TheBloke/alfred-40B-1023-GPTQ/tree/main) | 4 | None | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-raw-v1) | 8192 | 22.55 GB | No | 4-bit, with Act Order. No group size, to lower VRAM requirements. |
123
+ | [gptq-4bit-128g-actorder_True](https://huggingface.co/TheBloke/alfred-40B-1023-GPTQ/tree/gptq-4bit-128g-actorder_True) | 4 | 128 | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-raw-v1) | 8192 | 23.34 GB | No | 4-bit, with Act Order and group size 128g. Uses even less VRAM than 64g, but with slightly lower accuracy. |
124
+ | [gptq-4bit-32g-actorder_True](https://huggingface.co/TheBloke/alfred-40B-1023-GPTQ/tree/gptq-4bit-32g-actorder_True) | 4 | 32 | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-raw-v1) | 8192 | 25.72 GB | No | 4-bit, with Act Order and group size 32g. Gives highest possible inference quality, with maximum VRAM usage. |
125
+ | [gptq-3bit-128g-actorder_True](https://huggingface.co/TheBloke/alfred-40B-1023-GPTQ/tree/gptq-3bit-128g-actorder_True) | 3 | 128 | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-raw-v1) | 8192 | 18.20 GB | No | 3-bit, with group size 128g and act-order. Higher quality than 128g-False. |
126
+ | [gptq-8bit--1g-actorder_True](https://huggingface.co/TheBloke/alfred-40B-1023-GPTQ/tree/gptq-8bit--1g-actorder_True) | 8 | None | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-raw-v1) | 8192 | 42.93 GB | No | 8-bit, with Act Order. No group size, to lower VRAM requirements. |
127
+ | [gptq-3bit-32g-actorder_True](https://huggingface.co/TheBloke/alfred-40B-1023-GPTQ/tree/gptq-3bit-32g-actorder_True) | 3 | 32 | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-raw-v1) | 8192 | 20.47 GB | No | 3-bit, with group size 64g and act-order. Highest quality 3-bit option. |
128
+ | [gptq-8bit-128g-actorder_True](https://huggingface.co/TheBloke/alfred-40B-1023-GPTQ/tree/gptq-8bit-128g-actorder_True) | 8 | 128 | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-raw-v1) | 8192 | 43.88 GB | No | 8-bit, with group size 128g for higher inference quality and with Act Order for even higher accuracy. |
129
+
130
+ <!-- README_GPTQ.md-provided-files end -->
131
+
132
+ <!-- README_GPTQ.md-download-from-branches start -->
133
+ ## How to download, including from branches
134
+
135
+ ### In text-generation-webui
136
+
137
+ To download from the `main` branch, enter `TheBloke/alfred-40B-1023-GPTQ` in the "Download model" box.
138
+
139
+ To download from another branch, add `:branchname` to the end of the download name, eg `TheBloke/alfred-40B-1023-GPTQ:gptq-4bit-128g-actorder_True`
140
+
141
+ ### From the command line
142
+
143
+ I recommend using the `huggingface-hub` Python library:
144
+
145
+ ```shell
146
+ pip3 install huggingface-hub
147
+ ```
148
+
149
+ To download the `main` branch to a folder called `alfred-40B-1023-GPTQ`:
150
+
151
+ ```shell
152
+ mkdir alfred-40B-1023-GPTQ
153
+ huggingface-cli download TheBloke/alfred-40B-1023-GPTQ --local-dir alfred-40B-1023-GPTQ --local-dir-use-symlinks False
154
+ ```
155
+
156
+ To download from a different branch, add the `--revision` parameter:
157
+
158
+ ```shell
159
+ mkdir alfred-40B-1023-GPTQ
160
+ huggingface-cli download TheBloke/alfred-40B-1023-GPTQ --revision gptq-4bit-128g-actorder_True --local-dir alfred-40B-1023-GPTQ --local-dir-use-symlinks False
161
+ ```
162
+
163
+ <details>
164
+ <summary>More advanced huggingface-cli download usage</summary>
165
+
166
+ If you remove the `--local-dir-use-symlinks False` parameter, the files will instead be stored in the central Hugging Face cache directory (default location on Linux is: `~/.cache/huggingface`), and symlinks will be added to the specified `--local-dir`, pointing to their real location in the cache. This allows for interrupted downloads to be resumed, and allows you to quickly clone the repo to multiple places on disk without triggering a download again. The downside, and the reason why I don't list that as the default option, is that the files are then hidden away in a cache folder and it's harder to know where your disk space is being used, and to clear it up if/when you want to remove a download model.
167
+
168
+ The cache location can be changed with the `HF_HOME` environment variable, and/or the `--cache-dir` parameter to `huggingface-cli`.
169
+
170
+ For more documentation on downloading with `huggingface-cli`, please see: [HF -> Hub Python Library -> Download files -> Download from the CLI](https://huggingface.co/docs/huggingface_hub/guides/download#download-from-the-cli).
171
+
172
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
173
+
174
+ ```shell
175
+ pip3 install hf_transfer
176
+ ```
177
+
178
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
179
+
180
+ ```shell
181
+ mkdir alfred-40B-1023-GPTQ
182
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/alfred-40B-1023-GPTQ --local-dir alfred-40B-1023-GPTQ --local-dir-use-symlinks False
183
+ ```
184
+
185
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
186
+ </details>
187
+
188
+ ### With `git` (**not** recommended)
189
+
190
+ To clone a specific branch with `git`, use a command like this:
191
+
192
+ ```shell
193
+ git clone --single-branch --branch gptq-4bit-128g-actorder_True https://huggingface.co/TheBloke/alfred-40B-1023-GPTQ
194
+ ```
195
+
196
+ Note that using Git with HF repos is strongly discouraged. It will be much slower than using `huggingface-hub`, and will use twice as much disk space as it has to store the model files twice (it stores every byte both in the intended target folder, and again in the `.git` folder as a blob.)
197
+
198
+ <!-- README_GPTQ.md-download-from-branches end -->
199
+ <!-- README_GPTQ.md-text-generation-webui start -->
200
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
201
+
202
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
203
+
204
+ It is strongly recommended to use the text-generation-webui one-click-installers unless you're sure you know how to make a manual install.
205
+
206
+ 1. Click the **Model tab**.
207
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/alfred-40B-1023-GPTQ`.
208
+
209
+ - To download from a specific branch, enter for example `TheBloke/alfred-40B-1023-GPTQ:gptq-4bit-128g-actorder_True`
210
+ - see Provided Files above for the list of branches for each option.
211
+
212
+ 3. Click **Download**.
213
+ 4. The model will start downloading. Once it's finished it will say "Done".
214
+ 5. In the top left, click the refresh icon next to **Model**.
215
+ 6. In the **Model** dropdown, choose the model you just downloaded: `alfred-40B-1023-GPTQ`
216
+ 7. The model will automatically load, and is now ready for use!
217
+ 8. If you want any custom settings, set them and then click **Save settings for this model** followed by **Reload the Model** in the top right.
218
+
219
+ - Note that you do not need to and should not set manual GPTQ parameters any more. These are set automatically from the file `quantize_config.json`.
220
+
221
+ 9. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
222
+
223
+ <!-- README_GPTQ.md-text-generation-webui end -->
224
+
225
+ <!-- README_GPTQ.md-use-from-tgi start -->
226
+ ## Serving this model from Text Generation Inference (TGI)
227
+
228
+ It's recommended to use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
229
+
230
+ Example Docker parameters:
231
+
232
+ ```shell
233
+ --model-id TheBloke/alfred-40B-1023-GPTQ --port 3000 --quantize gptq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
234
+ ```
235
+
236
+ Example Python code for interfacing with TGI (requires huggingface-hub 0.17.0 or later):
237
+
238
+ ```shell
239
+ pip3 install huggingface-hub
240
+ ```
241
+
242
+ ```python
243
+ from huggingface_hub import InferenceClient
244
+
245
+ endpoint_url = "https://your-endpoint-url-here"
246
+
247
+ prompt = "Tell me about AI"
248
+ prompt_template=f'''<start_system>You are Alfred, a helpful assistant trained by LightOn. Knowledge cutoff: November 2022. Current date: 16 November, 2023<end_message><start_user>{prompt}<end_message><start_assistant>
249
+ '''
250
+
251
+ client = InferenceClient(endpoint_url)
252
+ response = client.text_generation(prompt,
253
+ max_new_tokens=128,
254
+ do_sample=True,
255
+ temperature=0.7,
256
+ top_p=0.95,
257
+ top_k=40,
258
+ repetition_penalty=1.1)
259
+
260
+ print(f"Model output: {response}")
261
+ ```
262
+ <!-- README_GPTQ.md-use-from-tgi end -->
263
+ <!-- README_GPTQ.md-use-from-python start -->
264
+ ## Python code example: inference from this GPTQ model
265
+
266
+ ### Install the necessary packages
267
+
268
+ Requires: Transformers 4.33.0 or later, Optimum 1.12.0 or later, and AutoGPTQ 0.4.2 or later.
269
+
270
+ ```shell
271
+ pip3 install --upgrade transformers optimum
272
+ # If using PyTorch 2.1 + CUDA 12.x:
273
+ pip3 install --upgrade auto-gptq
274
+ # or, if using PyTorch 2.1 + CUDA 11.x:
275
+ pip3 install --upgrade auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/
276
+ ```
277
+
278
+ If you are using PyTorch 2.0, you will need to install AutoGPTQ from source. Likewise if you have problems with the pre-built wheels, you should try building from source:
279
+
280
+ ```shell
281
+ pip3 uninstall -y auto-gptq
282
+ git clone https://github.com/PanQiWei/AutoGPTQ
283
+ cd AutoGPTQ
284
+ git checkout v0.5.1
285
+ pip3 install .
286
+ ```
287
+
288
+ ### Example Python code
289
+
290
+ ```python
291
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
292
+
293
+ model_name_or_path = "TheBloke/alfred-40B-1023-GPTQ"
294
+ # To use a different branch, change revision
295
+ # For example: revision="gptq-4bit-128g-actorder_True"
296
+ model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
297
+ device_map="auto",
298
+ trust_remote_code=True,
299
+ revision="main")
300
+
301
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
302
+
303
+ prompt = "Tell me about AI"
304
+ prompt_template=f'''<start_system>You are Alfred, a helpful assistant trained by LightOn. Knowledge cutoff: November 2022. Current date: 16 November, 2023<end_message><start_user>{prompt}<end_message><start_assistant>
305
+ '''
306
+
307
+ print("\n\n*** Generate:")
308
+
309
+ input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
310
+ output = model.generate(inputs=input_ids, temperature=0.7, do_sample=True, top_p=0.95, top_k=40, max_new_tokens=512)
311
+ print(tokenizer.decode(output[0]))
312
+
313
+ # Inference can also be done using transformers' pipeline
314
+
315
+ print("*** Pipeline:")
316
+ pipe = pipeline(
317
+ "text-generation",
318
+ model=model,
319
+ tokenizer=tokenizer,
320
+ max_new_tokens=512,
321
+ do_sample=True,
322
+ temperature=0.7,
323
+ top_p=0.95,
324
+ top_k=40,
325
+ repetition_penalty=1.1
326
+ )
327
+
328
+ print(pipe(prompt_template)[0]['generated_text'])
329
+ ```
330
+ <!-- README_GPTQ.md-use-from-python end -->
331
+
332
+ <!-- README_GPTQ.md-compatibility start -->
333
+ ## Compatibility
334
+
335
+ The files provided are tested to work with Transformers. For non-Mistral models, AutoGPTQ can also be used directly.
336
+
337
+ [ExLlama](https://github.com/turboderp/exllama) is compatible with Llama and Mistral models in 4-bit. Please see the Provided Files table above for per-file compatibility.
338
+
339
+ For a list of clients/servers, please see "Known compatible clients / servers", above.
340
+ <!-- README_GPTQ.md-compatibility end -->
341
+
342
+ <!-- footer start -->
343
+ <!-- 200823 -->
344
+ ## Discord
345
+
346
+ For further support, and discussions on these models and AI in general, join us at:
347
+
348
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
349
+
350
+ ## Thanks, and how to contribute
351
+
352
+ Thanks to the [chirper.ai](https://chirper.ai) team!
353
+
354
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
355
+
356
+ I've had a lot of people ask if they can contribute. I enjoy providing models and helping people, and would love to be able to spend even more time doing it, as well as expanding into new projects like fine tuning/training.
357
+
358
+ If you're able and willing to contribute it will be most gratefully received and will help me to keep providing more models, and to start work on new AI projects.
359
+
360
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
361
+
362
+ * Patreon: https://patreon.com/TheBlokeAI
363
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
364
+
365
+ **Special thanks to**: Aemon Algiz.
366
+
367
+ **Patreon special mentions**: Brandon Frisco, LangChain4j, Spiking Neurons AB, transmissions 11, Joseph William Delisle, Nitin Borwankar, Willem Michiel, Michael Dempsey, vamX, Jeffrey Morgan, zynix, jjj, Omer Bin Jawed, Sean Connelly, jinyuan sun, Jeromy Smith, Shadi, Pawan Osman, Chadd, Elijah Stavena, Illia Dulskyi, Sebastain Graf, Stephen Murray, terasurfer, Edmond Seymore, Celu Ramasamy, Mandus, Alex, biorpg, Ajan Kanaga, Clay Pascal, Raven Klaugh, 阿明, K, ya boyyy, usrbinkat, Alicia Loh, John Villwock, ReadyPlayerEmma, Chris Smitley, Cap'n Zoog, fincy, GodLy, S_X, sidney chen, Cory Kujawski, OG, Mano Prime, AzureBlack, Pieter, Kalila, Spencer Kim, Tom X Nguyen, Stanislav Ovsiannikov, Michael Levine, Andrey, Trailburnt, Vadim, Enrico Ros, Talal Aujan, Brandon Phillips, Jack West, Eugene Pentland, Michael Davis, Will Dee, webtim, Jonathan Leane, Alps Aficionado, Rooh Singh, Tiffany J. Kim, theTransient, Luke @flexchar, Elle, Caitlyn Gatomon, Ari Malik, subjectnull, Johann-Peter Hartmann, Trenton Dambrowitz, Imad Khwaja, Asp the Wyvern, Emad Mostaque, Rainer Wilmers, Alexandros Triantafyllidis, Nicholas, Pedro Madruga, SuperWojo, Harry Royden McLaughlin, James Bentley, Olakabola, David Ziegler, Ai Maven, Jeff Scroggin, Nikolai Manek, Deo Leter, Matthew Berman, Fen Risland, Ken Nordquist, Manuel Alberto Morcote, Luke Pendergrass, TL, Fred von Graf, Randy H, Dan Guido, NimbleBox.ai, Vitor Caleffi, Gabriel Tamborski, knownsqashed, Lone Striker, Erik Bjäreholt, John Detwiler, Leonard Tan, Iucharbius
368
+
369
+
370
+ Thank you to all my generous patrons and donaters!
371
+
372
+ And thank you again to a16z for their generous grant.
373
+
374
+ <!-- footer end -->
375
+
376
+ # Original model card: LightOn AI's Alfred 40B 1023
377
+
378
+ # Model Card for Alfred-40B-1023
379
+
380
+ ![a witty and elegant butler with a falcon on his shoulder, smile, flat illustration, simple shapes, colorful, lo-fi aesthetics](images/alfred-40b-1023.png)
381
+
382
+ `Alfred-40B-1023` is a finetuned version of [Falcon-40B](https://huggingface.co/tiiuae/falcon-40b), with an **extended context length of 8192 tokens**.
383
+ Finetuning was performed in October 2023. `Alfred-40B-1023` is made available under the Apache 2.0 License.
384
+
385
+ ## Model Details
386
+
387
+ ### Model Description
388
+
389
+ - **Developed by:** [LightOn](https://www.lighton.ai/)
390
+ * [Oskar Hallström](https://huggingface.co/ohallstrom) (project lead, training & modeling, internal long context data, evaluation)
391
+ * [Amélie Chatelain](https://huggingface.co/ameliechatelain) (internal data & long context data, data generation)
392
+ * [Clément Thiriet](https://huggingface.co/cthiriet) (data infrastructure, data generation, evaluation)
393
+ * [Julien Séailles](https://huggingface.co/Jseailleslighton) (data generation)
394
+ * [Adrien Cavaillès](https://huggingface.co/adcavail) (data generation)
395
+ * [Axel Marmet](https://huggingface.co/WeightsnWizardry)* (training 2K baseline)
396
+
397
+ `*` work done while at LightOn
398
+ - **Model type:** Causal decoder-only;
399
+ - **Language(s) (NLP):** English, German, Spanish, French (and limited capabilities in Italian, Portuguese, Polish, Dutch, Romanian, Czech, Swedish);
400
+ - **License:** Apache 2.0 license.
401
+ - **Finetuned from model:** [Falcon-40B](https://huggingface.co/tiiuae/falcon-40b)
402
+ - **Training date:** October 2023 (`1023`).
403
+
404
+ ## Uses
405
+
406
+ ### Direct Use
407
+
408
+ `Alfred-40B-1023` can be used as a chat model or as an instruct model.
409
+
410
+ For both instruct and chat mode, the model has been trained with chat tokens `<start_system>`, `<start_user>`, `<start_assistant>`, and `<end_message>`. These can be integrated into the prompt in the follwoing way:
411
+ ```
412
+ <start_system>You are Alfred, a helpful assistant trained by LightOn. Knowledge cutoff: November 2022. Current date: 16 November, 2023<end_message><start_user>{user query}<end_message><start_assistant>
413
+ ```
414
+
415
+ The stop word `<end_message>` should be used.
416
+
417
+ ### Out-of-Scope Use
418
+
419
+ Production use without adequate assessment of risks and mitigation; any use cases which may be considered irresponsible or harmful.
420
+
421
+ ## Bias, Risks, and Limitations
422
+
423
+ `Alfred-40B-1023` is a finetune of Falcon-40B. As such, it is trained mostly on English, German, Spanish, French, with limited capabilities also 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.
424
+
425
+ ### Recommendations
426
+
427
+ We recommend users of `Alfred-40B-1023` to implement appropriate guardrails and precautions in any production use.
428
+
429
+ ## How to Get Started with the Model
430
+
431
+ Use the code below to get started with the model.
432
+
433
+ ```
434
+ from transformers import AutoTokenizer, AutoModelForCausalLM
435
+ import transformers
436
+ import torch
437
+
438
+ model = "lightonai/alfred-40b-1023"
439
+ tokenizer = AutoTokenizer.from_pretrained("lightonai/alfred-0923-tokenizer")
440
+
441
+ pipeline = transformers.pipeline(
442
+ "text-generation",
443
+ model=model,
444
+ tokenizer=tokenizer,
445
+ torch_dtype=torch.bfloat16,
446
+ trust_remote_code=True,
447
+ device_map="auto",
448
+ )
449
+
450
+ sequences = pipeline(
451
+ "<start_system>You are Alfred, a helpful assistant trained by LightOn. Knowledge cutoff: November 2022. Current date: 16 November, 2023<end_message><start_user>Write me an email to my boss, explaining how the company could benefit by using LightOns platform for Large Language Models, Paradigm.<end_message><start_assistant>",
452
+ max_length=1000,
453
+ do_sample=True,
454
+ top_k=3,
455
+ num_return_sequences=1,
456
+ eos_token_id=tokenizer.eos_token_id,
457
+ )
458
+ for seq in sequences:
459
+ print(f"Result: {seq['generated_text']}")
460
+ ```
461
+
462
+ ## Training Details
463
+
464
+ ### Training Data
465
+
466
+ Alfred-40B-1023 was trained on a mixture of publicly available and in-house curated datasets. The training data is composed of 50 % short context tasks, 45 % long context tasks and 5 % RefinedWeb.
467
+
468
+ | **Short context sources** |
469
+ |--------------------|
470
+ | [oasst1](https://huggingface.co/datasets/OpenAssistant/oasst1) |
471
+ | [dolphin](https://huggingface.co/ehartford/dolphin) |
472
+ | [openai-critiques](https://openaipublic.blob.core.windows.net/critiques/README.md) |
473
+ | internal |
474
+ `internal` is a collection of synthetic and human-generated datasets created by Ligthon, tailored towards the use cases of our clients.
475
+
476
+ | **Long context sources** |
477
+ |--------------------|
478
+ | [sled](https://huggingface.co/datasets/tau/sled) |
479
+ | internal-long-context |
480
+
481
+ `internal-long-context` is a collection of synthetic datasets generated by LightOn, tailored towards the use cases of our clients.
482
+
483
+ During training, we apply regular language modeling loss for a partition of the prompts in the long context data.
484
+
485
+ | **Pretraining objective source** |
486
+ |--------------------|
487
+ | [RefinedWeb](https://huggingface.co/datasets/tiiuae/falcon-refinedweb) |
488
+
489
+ ### Training Procedure
490
+
491
+ `Alfred-40B-1023` was trained on 128 A100 40GB GPUs, using a 3D parallelism strategy (TP=8, PP=2, DP=8) combined with ZeRO. Alfred has been trained through supervised finetuning on 100 megatokens, with a learning rate decayed with a cosine schedule.
492
+
493
+ #### Preprocessing
494
+
495
+ All datasets have been filtered, up or downsampled, and adapted to our chat token format.
496
+
497
+ #### Context length extension
498
+
499
+ We extend the context length to 8K with a custom method that we name NTK-YaRN. As guessable from its name, our extension method draws inspiration from NTK-aware interpolation and YaRN.
500
+
501
+ During our context length extension efforts, we experimented with various methods suitable for RoPE embeddings. These include vanilla [positional interpolation](https://arxiv.org/abs/2306.15595), [NTK-aware interpolation](https://www.reddit.com/r/LocalLLaMA/comments/14lz7j5/ntkaware_scaled_rope_allows_llama_models_to_have/), [NTK-by-parts](https://github.com/jquesnelle/scaled-rope/pull/1), and lastly [YaRN](https://arxiv.org/abs/2309.00071).
502
+
503
+ YaRN looked very promising when applied at test-time, however finetuning with YaRN was not successful in our experiments. When extending the context length at training-time, NTK-aware interpolation was the most successful out of the already existing methods. Some of our results from trying different long context extension methods are shared in the Evaluation section below. We acknowledge that the same parameter values as proposed in the YaRN-paper have been used in our YaRN experiments, and that these potentially could have other optimal values for our particular setup.
504
+
505
+ ##### NTK-YaRN
506
+
507
+ Similarly to NTK-aware interpolation (`NTK`), NTK-YaRN involves increasing the base of the RoPE embeddings. In the original implementation of NTK-aware interpolation the new base `b'` is adapted according to the following formula:
508
+
509
+ $$ b' = b \times s^{\frac{|D|}{|D|-2}} $$
510
+
511
+ where `b` is the original base, `s` the scaling factor of the context length, and `|D|` the model's head dimension.
512
+
513
+ However, we find (similar to other actors) that increasing the base slightly more is even better. The value of `b'` could probably be optimized even further, but for these experiments we have settled with the following value:
514
+
515
+ $$ b' = b \times (s+1)^{\frac{|D|}{|D|-2}} $$
516
+
517
+ In the following parts of this model card, context length extension with this extended scaling of the base is referred to as `NTK-Margin`. For `NTK-YaRN`, the extended scaling of the base is combined with the modification of the computation of the attention weights made in YaRN, where the query and key matrices are scaled by the factor `m`.
518
+
519
+ $$ m = 1 + 0.1 \times \log(s) $$
520
+
521
+ Scaling the query and key matrices this way substantially reduces the initial grad norm when applying a context length extension method in our training runs.
522
+
523
+ To cite NTK-YaRN, please refer to the model bibtex in the bottom of this model card.
524
+
525
+ ## Evaluation
526
+
527
+ ### Context length extension strategies
528
+ #### Training losses
529
+
530
+ After experimenting on a 7B scale, we finally run a selected partition of the extension methods on a 40B scale. In the figure below, we display the resulting training losses when training a 40B model with the different extension methods, ceteris paribus.
531
+
532
+ ![Training loss curves for extension methods](images/training-loss-curves.png "Training loss curves for extension methods")
533
+
534
+ Initially, YaRN has the lowest training loss, which can be seen as a reflection of the fact that YaRN was the most successful extension method at test time. However all the other methods surpasse YaRN in terms of training loss already after a handful of megatokens. Comparing NTK-Margin vs NTK-YaRN, we can note that the scaling of Q and K matrices makes the training loss lower in the beginning, however NTK-YaRN's advantage over NTK-Margin decreases as the training goes on. Comparing NTK-Margin with NTK in turn, it seems like the larger value of the base in NTK-Margin gives an initial boost in training loss, however this advantage decreases as training goes on.
535
+
536
+ #### Performance on Long Context Benchmarks
537
+ We evaluate the context length extension methods on an own benchmark, consisting of four tasks.
538
+
539
+ * [Key-value retrieval UUID](https://arxiv.org/pdf/2307.03172.pdf)
540
+ * [Coarse-grained Topic Retrieval](https://lmsys.org/blog/2023-06-29-longchat/)
541
+ * [Fine-grained Line Retrieval](https://lmsys.org/blog/2023-06-29-longchat/)
542
+ * [Multi document retrieval data](https://nlp.stanford.edu/data/nfliu/lost-in-the-middle/nq-open-contriever-msmarco-retrieved-documents.jsonl.gz)
543
+
544
+ For each task, we have created 3 subtasks - one for each of the three context lengths 2K, 4K and 8K. In total, we thus have 12 subtasks.
545
+
546
+ In order to get an aggregated score that values each subtask equally, we normalize the scores for each subtask and then calculate the mean of the normalized scores for each extension method.
547
+
548
+ ![Aggregated scores on long context benchmarks](images/lc_benchmarks.png "Aggregated scores on long context benchmarks")
549
+
550
+ On these benchmarks, YaRN clearly lags behind. NTK-YaRN is the winning method, however NTK-Margin is so close that more extensive research is needed to verify that NTK-YaRN really is superior to NTK-Margin, especially when trained for longer.
551
+
552
+ ### Comparison to 2K baseline
553
+
554
+ In order to track any potential degradation on 2K context tasks due to the context length extension, we compare our 8K model against a 2K model trained in a similar setup for 100 megatokens. When training the 2K baseline, we don't include any long context data.
555
+
556
+ We conduct the comparison by evaluating the models on a selection of tasks from EleutherAI harness, as well as ranking model outputs internally.
557
+
558
+ ![Evaluation of 2K vs 8K version of alfred-40b-2023](images/2k_vs_8k.png "Evaluation of 2K vs 8K version of alfred-40b-2023")
559
+
560
+ Notably, our 8K model not only performs on par with our 2K model on most of our EleutherAI harness tasks, in fact it outperforms the 2K model on a majority of the tasks. Reading comprehension is the only subcategory for which our 8K model is outperformed by the 2K model.
561
+
562
+ We recognize that there is a discrepancy between performance on classical NLP benchmarks and how humans perceive the model quality. When model outputs (limited to 2K context lengths) are ranked by LightOn employees internally, the 2K and 8K have strikingly similar performance. However, a few rare failure modes have been noted for the 8K version, which are not seen when using the 2K model. These failure modes are likely to be fixable with better composition of the long context data.
563
+
564
+
565
+ ## Compute Infrastructure
566
+
567
+ ### Hardware
568
+
569
+ Alfred-40B-1023 was trained on AWS SageMaker, on 128 A100 40GB GPUs in P4d instances.
570
+
571
+ ### Software
572
+
573
+ Alfred-40B-1023 was trained with a custom codebase. Training leverages a 3D parallelism approach combined with ZeRO, as well as high-performance kernels such as FlashAttention.
574
+
575
+ ## Model Card Contact
576
+
577
+ Please open a Community Discussion for any support request related to using Alfred with HuggingFace transformers.
578
+
579
+ For any other inquiry: contact@lighton.ai
580
+
581
+ ## Citation
582
+
583
+ If you find the model useful in your work, please use the following bibtex when citing.
584
+ ```
585
+ @article{alfred-40b-1023,
586
+ title={Alfred-40B-1023},
587
+ author={Hallström, Oskar and Chatelain, Amélie and Thiriet, Clément and Séailles, Julien and Cavaillès, Adrien and Marmet, Axel},
588
+ year={2023}
589
+ }
590
+ ```