Text Generation
Transformers
Safetensors
mistral
conversational
text-generation-inference
4-bit precision
awq
TheBloke commited on
Commit
71a00a0
1 Parent(s): aed9efe

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +616 -0
README.md ADDED
@@ -0,0 +1,616 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: jondurbin/bagel-7b-v0.1
3
+ datasets:
4
+ - ai2_arc
5
+ - unalignment/spicy-3.1
6
+ - codeparrot/apps
7
+ - facebook/belebele
8
+ - boolq
9
+ - jondurbin/cinematika-v0.1
10
+ - drop
11
+ - lmsys/lmsys-chat-1m
12
+ - TIGER-Lab/MathInstruct
13
+ - cais/mmlu
14
+ - Muennighoff/natural-instructions
15
+ - openbookqa
16
+ - piqa
17
+ - Vezora/Tested-22k-Python-Alpaca
18
+ - cakiki/rosetta-code
19
+ - Open-Orca/SlimOrca
20
+ - spider
21
+ - squad_v2
22
+ - migtissera/Synthia-v1.3
23
+ - datasets/winogrande
24
+ inference: false
25
+ license: apache-2.0
26
+ model_creator: Jon Durbin
27
+ model_name: Bagel 7B v0.1
28
+ model_type: mistral
29
+ prompt_template: 'Below is an instruction that describes a task. Write a response
30
+ that appropriately completes the request.
31
+
32
+
33
+ ### Instruction:
34
+
35
+ {prompt}
36
+
37
+
38
+ ### Response:
39
+
40
+ '
41
+ quantized_by: TheBloke
42
+ ---
43
+ <!-- markdownlint-disable MD041 -->
44
+
45
+ <!-- header start -->
46
+ <!-- 200823 -->
47
+ <div style="width: auto; margin-left: auto; margin-right: auto">
48
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
49
+ </div>
50
+ <div style="display: flex; justify-content: space-between; width: 100%;">
51
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
52
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
53
+ </div>
54
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
55
+ <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>
56
+ </div>
57
+ </div>
58
+ <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>
59
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
60
+ <!-- header end -->
61
+
62
+ # Bagel 7B v0.1 - AWQ
63
+ - Model creator: [Jon Durbin](https://huggingface.co/jondurbin)
64
+ - Original model: [Bagel 7B v0.1](https://huggingface.co/jondurbin/bagel-7b-v0.1)
65
+
66
+ <!-- description start -->
67
+ ## Description
68
+
69
+ This repo contains AWQ model files for [Jon Durbin's Bagel 7B v0.1](https://huggingface.co/jondurbin/bagel-7b-v0.1).
70
+
71
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
72
+
73
+
74
+ ### About AWQ
75
+
76
+ AWQ is an efficient, accurate and blazing-fast low-bit weight quantization method, currently supporting 4-bit quantization. Compared to GPTQ, it offers faster Transformers-based inference with equivalent or better quality compared to the most commonly used GPTQ settings.
77
+
78
+ AWQ models are currently supported on Linux and Windows, with NVidia GPUs only. macOS users: please use GGUF models instead.
79
+
80
+ It is supported by:
81
+
82
+ - [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
83
+ - [vLLM](https://github.com/vllm-project/vllm) - version 0.2.2 or later for support for all model types.
84
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
85
+ - [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later, from any code or client that supports Transformers
86
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
87
+
88
+ <!-- description end -->
89
+ <!-- repositories-available start -->
90
+ ## Repositories available
91
+
92
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/bagel-7B-v0.1-AWQ)
93
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/bagel-7B-v0.1-GPTQ)
94
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/bagel-7B-v0.1-GGUF)
95
+ * [Jon Durbin's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/jondurbin/bagel-7b-v0.1)
96
+ <!-- repositories-available end -->
97
+
98
+ <!-- prompt-template start -->
99
+ ## Prompt template: Alpaca
100
+
101
+ ```
102
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
103
+
104
+ ### Instruction:
105
+ {prompt}
106
+
107
+ ### Response:
108
+
109
+ ```
110
+
111
+ <!-- prompt-template end -->
112
+
113
+
114
+ <!-- README_AWQ.md-provided-files start -->
115
+ ## Provided files, and AWQ parameters
116
+
117
+ I currently release 128g GEMM models only. The addition of group_size 32 models, and GEMV kernel models, is being actively considered.
118
+
119
+ Models are released as sharded safetensors files.
120
+
121
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
122
+ | ------ | ---- | -- | ----------- | ------- | ---- |
123
+ | [main](https://huggingface.co/TheBloke/bagel-7B-v0.1-AWQ/tree/main) | 4 | 128 | [VMware Open Instruct](https://huggingface.co/datasets/VMware/open-instruct/viewer/) | 4096 | 4.15 GB
124
+
125
+ <!-- README_AWQ.md-provided-files end -->
126
+
127
+ <!-- README_AWQ.md-text-generation-webui start -->
128
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
129
+
130
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
131
+
132
+ 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.
133
+
134
+ 1. Click the **Model tab**.
135
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/bagel-7B-v0.1-AWQ`.
136
+ 3. Click **Download**.
137
+ 4. The model will start downloading. Once it's finished it will say "Done".
138
+ 5. In the top left, click the refresh icon next to **Model**.
139
+ 6. In the **Model** dropdown, choose the model you just downloaded: `bagel-7B-v0.1-AWQ`
140
+ 7. Select **Loader: AutoAWQ**.
141
+ 8. Click Load, and the model will load and is now ready for use.
142
+ 9. 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.
143
+ 10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
144
+ <!-- README_AWQ.md-text-generation-webui end -->
145
+
146
+ <!-- README_AWQ.md-use-from-vllm start -->
147
+ ## Multi-user inference server: vLLM
148
+
149
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
150
+
151
+ - Please ensure you are using vLLM version 0.2 or later.
152
+ - When using vLLM as a server, pass the `--quantization awq` parameter.
153
+
154
+ For example:
155
+
156
+ ```shell
157
+ python3 -m vllm.entrypoints.api_server --model TheBloke/bagel-7B-v0.1-AWQ --quantization awq --dtype auto
158
+ ```
159
+
160
+ - When using vLLM from Python code, again set `quantization=awq`.
161
+
162
+ For example:
163
+
164
+ ```python
165
+ from vllm import LLM, SamplingParams
166
+
167
+ prompts = [
168
+ "Tell me about AI",
169
+ "Write a story about llamas",
170
+ "What is 291 - 150?",
171
+ "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
172
+ ]
173
+ prompt_template=f'''Below is an instruction that describes a task. Write a response that appropriately completes the request.
174
+
175
+ ### Instruction:
176
+ {prompt}
177
+
178
+ ### Response:
179
+ '''
180
+
181
+ prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
182
+
183
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
184
+
185
+ llm = LLM(model="TheBloke/bagel-7B-v0.1-AWQ", quantization="awq", dtype="auto")
186
+
187
+ outputs = llm.generate(prompts, sampling_params)
188
+
189
+ # Print the outputs.
190
+ for output in outputs:
191
+ prompt = output.prompt
192
+ generated_text = output.outputs[0].text
193
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
194
+ ```
195
+ <!-- README_AWQ.md-use-from-vllm start -->
196
+
197
+ <!-- README_AWQ.md-use-from-tgi start -->
198
+ ## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
199
+
200
+ Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
201
+
202
+ Example Docker parameters:
203
+
204
+ ```shell
205
+ --model-id TheBloke/bagel-7B-v0.1-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
206
+ ```
207
+
208
+ Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
209
+
210
+ ```shell
211
+ pip3 install huggingface-hub
212
+ ```
213
+
214
+ ```python
215
+ from huggingface_hub import InferenceClient
216
+
217
+ endpoint_url = "https://your-endpoint-url-here"
218
+
219
+ prompt = "Tell me about AI"
220
+ prompt_template=f'''Below is an instruction that describes a task. Write a response that appropriately completes the request.
221
+
222
+ ### Instruction:
223
+ {prompt}
224
+
225
+ ### Response:
226
+ '''
227
+
228
+ client = InferenceClient(endpoint_url)
229
+ response = client.text_generation(prompt,
230
+ max_new_tokens=128,
231
+ do_sample=True,
232
+ temperature=0.7,
233
+ top_p=0.95,
234
+ top_k=40,
235
+ repetition_penalty=1.1)
236
+
237
+ print(f"Model output: ", response)
238
+ ```
239
+ <!-- README_AWQ.md-use-from-tgi end -->
240
+
241
+ <!-- README_AWQ.md-use-from-python start -->
242
+ ## Inference from Python code using Transformers
243
+
244
+ ### Install the necessary packages
245
+
246
+ - Requires: [Transformers](https://huggingface.co/docs/transformers) 4.35.0 or later.
247
+ - Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.6 or later.
248
+
249
+ ```shell
250
+ pip3 install --upgrade "autoawq>=0.1.6" "transformers>=4.35.0"
251
+ ```
252
+
253
+ Note that if you are using PyTorch 2.0.1, the above AutoAWQ command will automatically upgrade you to PyTorch 2.1.0.
254
+
255
+ If you are using CUDA 11.8 and wish to continue using PyTorch 2.0.1, instead run this command:
256
+
257
+ ```shell
258
+ pip3 install https://github.com/casper-hansen/AutoAWQ/releases/download/v0.1.6/autoawq-0.1.6+cu118-cp310-cp310-linux_x86_64.whl
259
+ ```
260
+
261
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
262
+
263
+ ```shell
264
+ pip3 uninstall -y autoawq
265
+ git clone https://github.com/casper-hansen/AutoAWQ
266
+ cd AutoAWQ
267
+ pip3 install .
268
+ ```
269
+
270
+ ### Transformers example code (requires Transformers 4.35.0 and later)
271
+
272
+ ```python
273
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
274
+
275
+ model_name_or_path = "TheBloke/bagel-7B-v0.1-AWQ"
276
+
277
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
278
+ model = AutoModelForCausalLM.from_pretrained(
279
+ model_name_or_path,
280
+ low_cpu_mem_usage=True,
281
+ device_map="cuda:0"
282
+ )
283
+
284
+ # Using the text streamer to stream output one token at a time
285
+ streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
286
+
287
+ prompt = "Tell me about AI"
288
+ prompt_template=f'''Below is an instruction that describes a task. Write a response that appropriately completes the request.
289
+
290
+ ### Instruction:
291
+ {prompt}
292
+
293
+ ### Response:
294
+ '''
295
+
296
+ # Convert prompt to tokens
297
+ tokens = tokenizer(
298
+ prompt_template,
299
+ return_tensors='pt'
300
+ ).input_ids.cuda()
301
+
302
+ generation_params = {
303
+ "do_sample": True,
304
+ "temperature": 0.7,
305
+ "top_p": 0.95,
306
+ "top_k": 40,
307
+ "max_new_tokens": 512,
308
+ "repetition_penalty": 1.1
309
+ }
310
+
311
+ # Generate streamed output, visible one token at a time
312
+ generation_output = model.generate(
313
+ tokens,
314
+ streamer=streamer,
315
+ **generation_params
316
+ )
317
+
318
+ # Generation without a streamer, which will include the prompt in the output
319
+ generation_output = model.generate(
320
+ tokens,
321
+ **generation_params
322
+ )
323
+
324
+ # Get the tokens from the output, decode them, print them
325
+ token_output = generation_output[0]
326
+ text_output = tokenizer.decode(token_output)
327
+ print("model.generate output: ", text_output)
328
+
329
+ # Inference is also possible via Transformers' pipeline
330
+ from transformers import pipeline
331
+
332
+ pipe = pipeline(
333
+ "text-generation",
334
+ model=model,
335
+ tokenizer=tokenizer,
336
+ **generation_params
337
+ )
338
+
339
+ pipe_output = pipe(prompt_template)[0]['generated_text']
340
+ print("pipeline output: ", pipe_output)
341
+
342
+ ```
343
+ <!-- README_AWQ.md-use-from-python end -->
344
+
345
+ <!-- README_AWQ.md-compatibility start -->
346
+ ## Compatibility
347
+
348
+ The files provided are tested to work with:
349
+
350
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
351
+ - [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
352
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
353
+ - [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later.
354
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
355
+
356
+ <!-- README_AWQ.md-compatibility end -->
357
+
358
+ <!-- footer start -->
359
+ <!-- 200823 -->
360
+ ## Discord
361
+
362
+ For further support, and discussions on these models and AI in general, join us at:
363
+
364
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
365
+
366
+ ## Thanks, and how to contribute
367
+
368
+ Thanks to the [chirper.ai](https://chirper.ai) team!
369
+
370
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
371
+
372
+ 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.
373
+
374
+ 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.
375
+
376
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
377
+
378
+ * Patreon: https://patreon.com/TheBlokeAI
379
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
380
+
381
+ **Special thanks to**: Aemon Algiz.
382
+
383
+ **Patreon special mentions**: Michael Levine, 阿明, Trailburnt, Nikolai Manek, John Detwiler, Randy H, Will Dee, Sebastain Graf, NimbleBox.ai, Eugene Pentland, Emad Mostaque, Ai Maven, Jim Angel, Jeff Scroggin, Michael Davis, Manuel Alberto Morcote, Stephen Murray, Robert, Justin Joy, Luke @flexchar, Brandon Frisco, Elijah Stavena, S_X, Dan Guido, Undi ., Komninos Chatzipapas, Shadi, theTransient, Lone Striker, Raven Klaugh, jjj, Cap'n Zoog, Michel-Marie MAUDET (LINAGORA), Matthew Berman, David, Fen Risland, Omer Bin Jawed, Luke Pendergrass, Kalila, OG, Erik Bjäreholt, Rooh Singh, Joseph William Delisle, Dan Lewis, TL, John Villwock, AzureBlack, Brad, Pedro Madruga, Caitlyn Gatomon, K, jinyuan sun, Mano Prime, Alex, Jeffrey Morgan, Alicia Loh, Illia Dulskyi, Chadd, transmissions 11, fincy, Rainer Wilmers, ReadyPlayerEmma, knownsqashed, Mandus, biorpg, Deo Leter, Brandon Phillips, SuperWojo, Sean Connelly, Iucharbius, Jack West, Harry Royden McLaughlin, Nicholas, terasurfer, Vitor Caleffi, Duane Dunston, Johann-Peter Hartmann, David Ziegler, Olakabola, Ken Nordquist, Trenton Dambrowitz, Tom X Nguyen, Vadim, Ajan Kanaga, Leonard Tan, Clay Pascal, Alexandros Triantafyllidis, JM33133, Xule, vamX, ya boyyy, subjectnull, Talal Aujan, Alps Aficionado, wassieverse, Ari Malik, James Bentley, Woland, Spencer Kim, Michael Dempsey, Fred von Graf, Elle, zynix, William Richards, Stanislav Ovsiannikov, Edmond Seymore, Jonathan Leane, Martin Kemka, usrbinkat, Enrico Ros
384
+
385
+
386
+ Thank you to all my generous patrons and donaters!
387
+
388
+ And thank you again to a16z for their generous grant.
389
+
390
+ <!-- footer end -->
391
+
392
+ # Original model card: Jon Durbin's Bagel 7B v0.1
393
+
394
+
395
+ # A bagel, with everything (except DPO)
396
+
397
+ ![bagel](bagel.png)
398
+
399
+ ## Overview
400
+
401
+ This is the pre-DPO version of the mistral-7b model fine-tuned with https://github.com/jondurbin/bagel
402
+
403
+ You probably want the higher performing model that underwent DPO: https://huggingface.co/jondurbin/bagel-dpo-7b-v0.1
404
+
405
+ The only benefit to this model is that it is less "truthful", for roleplaying and other types of scenarios that may benefit more from the SFT-only tune.
406
+
407
+ ## Data selection.
408
+
409
+ The first step in the process is creating a dataset.
410
+ In this case, we're actually creating a composite dataset, consisting of both supervised fine-tuning data (SFT) and direct preference optimization (DPO) data.
411
+
412
+ All instruction data, that is, data that is not plain text (like project Gutenberg and items from Cinematika) or DPO, is converted into ShareGPT format so it's easier to work with.
413
+
414
+ See the corresponding code in `bagel/data_sources/*.py` in the repo linked above for full implementation for each data source.
415
+
416
+ Deduplication is done by creating a uuid v5 of the instruction/text, then only adding items not previously seen (where datasets are loaded in order of the confidence score I assign them).
417
+ This means that if an instruction is in data source "Foo" with confidence 4 as well as in data source "Bar" with confidence score 2, only the entry from "Foo" will be taken.
418
+
419
+ ### SFT data sources
420
+
421
+ *Yes, you will see benchmark names in the list, but this only uses the train splits, and a decontamination by cosine similarity is performed at the end as a sanity check*
422
+
423
+ - [ai2_arc](https://huggingface.co/datasets/ai2_arc)
424
+ - Abstraction and reasoning dataset, useful in measuring "intelligence" to a certain extent.
425
+ - [airoboros](https://huggingface.co/datasets/unalignment/spicy-3.1)
426
+ - Variety of categories of synthetic instructions generated by gpt-4.
427
+ - [apps](https://huggingface.co/datasets/codeparrot/apps)
428
+ - Python coding dataset with 10k problems.
429
+ - [belebele](https://huggingface.co/datasets/facebook/belebele)
430
+ - Multi-lingual reading comprehension dataset.
431
+ - [boolq](https://huggingface.co/datasets/boolq)
432
+ - Corpus of yes/no questions (which can be surprisingly difficult for AI to answer apparently?)
433
+ - [cinematika](https://huggingface.co/datasets/jondurbin/cinematika-v0.1) (instruction and plain text)
434
+ - RP-style data synthesized from movie scripts so the model isn't quite as boring as it otherwise would be.
435
+ - [drop](https://huggingface.co/datasets/drop)
436
+ - More reading comprehension.
437
+ - [gutenberg](https://www.gutenberg.org/) (plain text)
438
+ - Books/plain text, again to make the model less boring, only a handful of examples supported by [chapterize](https://github.com/JonathanReeve/chapterize)
439
+ - [lmsys_chat_1m](https://huggingface.co/datasets/lmsys/lmsys-chat-1m) (only gpt-4 items, also used for DPO)
440
+ - Chats collected by the lmsys chat arena, containing a wide variety of chats with various models.
441
+ - [mathinstruct](https://huggingface.co/datasets/TIGER-Lab/MathInstruct)
442
+ - Composite dataset with a variety of math-related tasks and problem/question formats.
443
+ - [mmlu](https://huggingface.co/datasets/cais/mmlu)
444
+ - Massive Multitask Language Understanding - a wide variety of questions about various subject matters.
445
+ - [natural_instructions](https://huggingface.co/datasets/Muennighoff/natural-instructions)
446
+ - Millions of instructions from 1600+ task categories (sampled down substantially, stratified by task type)
447
+ - [openbookqa](https://huggingface.co/datasets/openbookqa)
448
+ - Question answering dataset.
449
+ - [piqa](https://huggingface.co/datasets/piqa)
450
+ - Phyiscal interaction question answering.
451
+ - [python_alpaca](https://huggingface.co/datasets/Vezora/Tested-22k-Python-Alpaca)
452
+ - Python instruction response pairs, validated as functional.
453
+ - [rosetta_code](https://huggingface.co/datasets/cakiki/rosetta-code)
454
+ - Code problems and solutions in a variety of programming languages taken from rosettacode.org.
455
+ - [slimorca](https://huggingface.co/datasets/Open-Orca/SlimOrca)
456
+ - Collection of ~500k gpt-4 verified chats from OpenOrca.
457
+ - [spider](https://huggingface.co/datasets/spider)
458
+ - SQL-targeted dataset.
459
+ - [squad_v2](https://huggingface.co/datasets/squad_v2)
460
+ - Contextual question answering (RAG).
461
+ - [synthia](https://huggingface.co/datasets/migtissera/Synthia-v1.3)
462
+ - GPT-4 generated data using advanced prompting from Migel Tissera.
463
+ - [winogrande](https://huggingface.co/datasets/winogrande)
464
+ - Fill in the blank style prompts.
465
+
466
+ Only the train splits were used (if a split was provided), and an additional pass of decontamination is performed using approximate nearest neighbor search (via faiss).
467
+
468
+ ## Prompt formatting
469
+
470
+ In sticking with the theme of the bagel, I didn't want to use a single prompt format, so I used 4 - vicuna, llama-2, alpaca, and chat-ml (sorta).
471
+ I also didn't want to randomly select a single prompt format for each item (hoping each instruction would generalize more when used in a variety of prompt formats), so each instruction is actually converted into every prompt format.
472
+
473
+ This means each epoch of our fine-tune is really basically 4 epochs. So, for the fine-tunes, I would recommend only doing 1 epoch (or 0.75 epochs). I am testing with a single epoch using a relatively low learning rate.
474
+
475
+ ### Alpaca (sort of)
476
+
477
+ ```
478
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
479
+
480
+ ### Instruction:
481
+ {system prompt, if provided}
482
+ {instruction}
483
+
484
+ ### Response:
485
+ ```
486
+
487
+ The main difference here is that because of the dataset formatting and variety of data sources, it would have been much to tedious to add an `### Input:` block, so the inputs are just in the instruction section.
488
+
489
+ ### Vicuna
490
+
491
+ ```
492
+ {system prompt, if provided, randomly defaulting to "A chat between a user and an unbiased, uncensored assistant."}
493
+ USER: {instruction}
494
+ ASSISTANT:
495
+ ```
496
+
497
+ ### ChatML (sort of)
498
+
499
+ I don't really understand the point of having special tokens for `<|im_start|>` and `<|im_end|>`, because in practice they just act as BOS and EOS tokens (but, please correct me if I'm wrong).
500
+
501
+ So, instead of:
502
+ ```text
503
+ {bos}<|im_start|>{role}
504
+ {text}
505
+ <|im_end|>{eos}
506
+ ```
507
+
508
+ I just changed it to:
509
+ ```text
510
+ {bos}{role}
511
+ {text}
512
+ {eos}
513
+ ```
514
+
515
+ In practice, this would mean tokenization code like such:
516
+ ```python
517
+ tokenizer = AutoTokenizer.from_pretrained('mistralai/mistral-7b-v0.1')
518
+
519
+ input_str = f"""system
520
+ You are a goat.
521
+ {tokenizer.eos_token}
522
+ {tokenizer.bos_token}user
523
+ Tell me how to fry an egg.
524
+ {tokenizer.eos_token}
525
+ {tokenizer.bos_token}assistant
526
+ """
527
+
528
+ inputs = tokenizer(input_str, return_tensors="pt")
529
+ ```
530
+
531
+ If you *really* want to use `<|im_start|>` and `<|im_end|>`, just update your `tokenizer_config.json` to use `<|im_start|>` instead of `<s>` and `<|im_end|>` instead of `</s>` and when tokenizing. And if you still don't like what I've done to this chat-ml-ish format, feel free to cry into your pillow or fork the code and do a new fine-tune.
532
+
533
+ ### Llama-2 chat
534
+
535
+ ```
536
+ [INST] <<SYS>>
537
+ {system}
538
+ <</SYS>>
539
+
540
+ {instruction} [/INST]
541
+ ```
542
+
543
+ ### Fine-tune
544
+
545
+ *Note: I actually used my fork of [qlora](https://github.com/jondurbin/qlora)'s `train.py` for this, but I'm porting it to a minified version here, not tested yet!*
546
+
547
+ *More notes: I stopped the fine-tune around 50% because of budget constraints - it's a lot of data...*
548
+
549
+ ```bash
550
+ export BASE_DIR=/workspace
551
+ export WANDB_API_KEY=[redacted]
552
+ export WANDB_PROJECT=bagel-7b-v0.1
553
+
554
+ # Run the pretraining.
555
+ accelerate launch bagel/tune/sft.py \
556
+ --model_name_or_path $BASE_DIR/mistral-7b \
557
+ --final_output_dir $BASE_DIR/$WANDB_PROJECT \
558
+ --output_dir $BASE_DIR/$WANDB_PROJECT-workdir \
559
+ --num_train_epochs 1 \
560
+ --logging_steps 1 \
561
+ --save_strategy steps \
562
+ --save_steps 200 \
563
+ --save_total_limit 5 \
564
+ --data_seed 42 \
565
+ --evaluation_strategy steps \
566
+ --eval_dataset_size 0.0006 \
567
+ --eval_steps 200 \
568
+ --max_new_tokens 4096 \
569
+ --dataloader_num_workers 3 \
570
+ --logging_strategy steps \
571
+ --remove_unused_columns False \
572
+ --do_train \
573
+ --full_finetune \
574
+ --bf16 \
575
+ --bits 16 \
576
+ --optim adamw_torch \
577
+ --lr_scheduler_type linear \
578
+ --dataset $BASE_DIR/bagel/bagel-input-output-v0.1.parquet \
579
+ --dataset_format input-output \
580
+ --model_max_len 4096 \
581
+ --per_device_train_batch_size 8 \
582
+ --learning_rate 3.5e-7 \
583
+ --warmup_ratio 0.005 \
584
+ --adam_beta2 0.999 \
585
+ --max_grad_norm 0.3 \
586
+ --weight_decay 0.001 \
587
+ --seed 42 \
588
+ --report_to wandb \
589
+ --gradient_checkpointing True \
590
+ --gradient_accumulation_steps 4 \
591
+ --skip_excess_length False \
592
+ --ddp_find_unused_parameters False \
593
+ --use_flash_attention_2 \
594
+ --deepspeed deepspeed.json
595
+ ```
596
+
597
+ Deepspeed configuration:
598
+ ```json
599
+ {
600
+ "gradient_accumulation_steps": "auto",
601
+ "gradient_clipping": "auto",
602
+ "train_batch_size": "auto",
603
+ "train_micro_batch_size_per_gpu": "auto",
604
+ "bf16": {
605
+ "enabled": true
606
+ },
607
+ "zero_optimization": {
608
+ "stage": 2,
609
+ "contiguous_gradients": true,
610
+ "overlap_comm": true,
611
+ "reduce_scatter": true,
612
+ "reduce_bucket_size": 5e8,
613
+ "allgather_bucket_size": 5e8
614
+ }
615
+ }
616
+ ```