TheBloke commited on
Commit
d555f2c
1 Parent(s): 385f81b

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +708 -0
README.md ADDED
@@ -0,0 +1,708 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: jondurbin/airoboros-180b-2.2.1
3
+ datasets:
4
+ - jondurbin/airoboros-2.2.1
5
+ inference: false
6
+ license: other
7
+ license_link: https://huggingface.co/tiiuae/falcon-180B/raw/main/LICENSE.txt
8
+ license_name: falcon-180b-tii-license-1.0
9
+ model_creator: Jon Durbin
10
+ model_name: Airoboros 180B 2.2.1
11
+ model_type: falcon
12
+ prompt_template: "A chat.\nUSER: {prompt}\nASSISTANT: \n"
13
+ quantized_by: TheBloke
14
+ ---
15
+ <!-- markdownlint-disable MD041 -->
16
+
17
+ <!-- header start -->
18
+ <!-- 200823 -->
19
+ <div style="width: auto; margin-left: auto; margin-right: auto">
20
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
21
+ </div>
22
+ <div style="display: flex; justify-content: space-between; width: 100%;">
23
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
24
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
25
+ </div>
26
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
27
+ <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>
28
+ </div>
29
+ </div>
30
+ <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>
31
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
32
+ <!-- header end -->
33
+
34
+ # Airoboros 180B 2.2.1 - AWQ
35
+ - Model creator: [Jon Durbin](https://huggingface.co/jondurbin)
36
+ - Original model: [Airoboros 180B 2.2.1](https://huggingface.co/jondurbin/airoboros-180b-2.2.1)
37
+
38
+ <!-- description start -->
39
+ ## Description
40
+
41
+ This repo contains AWQ model files for [Jon Durbin's Airoboros 180B 2.2.1](https://huggingface.co/jondurbin/airoboros-180b-2.2.1).
42
+
43
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
44
+
45
+
46
+ ### About AWQ
47
+
48
+ 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.
49
+
50
+ It is supported by:
51
+
52
+ - [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
53
+ - [vLLM](https://github.com/vllm-project/vllm) - Llama and Mistral models only
54
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
55
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
56
+
57
+ <!-- description end -->
58
+ <!-- repositories-available start -->
59
+ ## Repositories available
60
+
61
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/Airoboros-180B-2.2.1-AWQ)
62
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Airoboros-180B-2.2.1-GGUF)
63
+ * [Jon Durbin's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/jondurbin/airoboros-180b-2.2.1)
64
+ <!-- repositories-available end -->
65
+
66
+ <!-- prompt-template start -->
67
+ ## Prompt template: Chat
68
+
69
+ ```
70
+ A chat.
71
+ USER: {prompt}
72
+ ASSISTANT:
73
+
74
+ ```
75
+
76
+ <!-- prompt-template end -->
77
+
78
+
79
+ <!-- README_AWQ.md-provided-files start -->
80
+ ## Provided files, and AWQ parameters
81
+
82
+ For my first release of AWQ models, I am releasing 128g models only. I will consider adding 32g as well if there is interest, and once I have done perplexity and evaluation comparisons, but at this time 32g models are still not fully tested with AutoAWQ and vLLM.
83
+
84
+ Models are released as sharded safetensors files.
85
+
86
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
87
+ | ------ | ---- | -- | ----------- | ------- | ---- |
88
+ | [main](https://huggingface.co/TheBloke/Airoboros-180B-2.2.1-AWQ/tree/main) | 4 | 128 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-v1/test) | 4096 | 96.13 GB
89
+
90
+ <!-- README_AWQ.md-provided-files end -->
91
+
92
+ <!-- README_AWQ.md-text-generation-webui start -->
93
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
94
+
95
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
96
+
97
+ 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.
98
+
99
+ 1. Click the **Model tab**.
100
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/Airoboros-180B-2.2.1-AWQ`.
101
+ 3. Click **Download**.
102
+ 4. The model will start downloading. Once it's finished it will say "Done".
103
+ 5. In the top left, click the refresh icon next to **Model**.
104
+ 6. In the **Model** dropdown, choose the model you just downloaded: `Airoboros-180B-2.2.1-AWQ`
105
+ 7. Select **Loader: AutoAWQ**.
106
+ 8. Click Load, and the model will load and is now ready for use.
107
+ 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.
108
+ 10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
109
+ <!-- README_AWQ.md-text-generation-webui end -->
110
+
111
+ <!-- README_AWQ.md-use-from-vllm start -->
112
+ ## Multi-user inference server: vLLM
113
+
114
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
115
+
116
+ - Please ensure you are using vLLM version 0.2 or later.
117
+ - When using vLLM as a server, pass the `--quantization awq` parameter.
118
+
119
+ For example:
120
+
121
+ ```shell
122
+ python3 python -m vllm.entrypoints.api_server --model TheBloke/Airoboros-180B-2.2.1-AWQ --quantization awq
123
+ ```
124
+
125
+ - When using vLLM from Python code, again set `quantization=awq`.
126
+
127
+ For example:
128
+
129
+ ```python
130
+ from vllm import LLM, SamplingParams
131
+
132
+ prompts = [
133
+ "Tell me about AI",
134
+ "Write a story about llamas",
135
+ "What is 291 - 150?",
136
+ "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
137
+ ]
138
+ prompt_template=f'''A chat.
139
+ USER: {prompt}
140
+ ASSISTANT:
141
+ '''
142
+
143
+ prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
144
+
145
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
146
+
147
+ llm = LLM(model="TheBloke/Airoboros-180B-2.2.1-AWQ", quantization="awq", dtype="auto")
148
+
149
+ outputs = llm.generate(prompts, sampling_params)
150
+
151
+ # Print the outputs.
152
+ for output in outputs:
153
+ prompt = output.prompt
154
+ generated_text = output.outputs[0].text
155
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
156
+ ```
157
+ <!-- README_AWQ.md-use-from-vllm start -->
158
+
159
+ <!-- README_AWQ.md-use-from-tgi start -->
160
+ ## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
161
+
162
+ Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
163
+
164
+ Example Docker parameters:
165
+
166
+ ```shell
167
+ --model-id TheBloke/Airoboros-180B-2.2.1-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
168
+ ```
169
+
170
+ Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
171
+
172
+ ```shell
173
+ pip3 install huggingface-hub
174
+ ```
175
+
176
+ ```python
177
+ from huggingface_hub import InferenceClient
178
+
179
+ endpoint_url = "https://your-endpoint-url-here"
180
+
181
+ prompt = "Tell me about AI"
182
+ prompt_template=f'''A chat.
183
+ USER: {prompt}
184
+ ASSISTANT:
185
+ '''
186
+
187
+ client = InferenceClient(endpoint_url)
188
+ response = client.text_generation(prompt,
189
+ max_new_tokens=128,
190
+ do_sample=True,
191
+ temperature=0.7,
192
+ top_p=0.95,
193
+ top_k=40,
194
+ repetition_penalty=1.1)
195
+
196
+ print(f"Model output: ", response)
197
+ ```
198
+ <!-- README_AWQ.md-use-from-tgi end -->
199
+
200
+ <!-- README_AWQ.md-use-from-python start -->
201
+ ## Inference from Python code using AutoAWQ
202
+
203
+ ### Install the AutoAWQ package
204
+
205
+ Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.1 or later.
206
+
207
+ ```shell
208
+ pip3 install autoawq
209
+ ```
210
+
211
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
212
+
213
+ ```shell
214
+ pip3 uninstall -y autoawq
215
+ git clone https://github.com/casper-hansen/AutoAWQ
216
+ cd AutoAWQ
217
+ pip3 install .
218
+ ```
219
+
220
+ ### AutoAWQ example code
221
+
222
+ ```python
223
+ from awq import AutoAWQForCausalLM
224
+ from transformers import AutoTokenizer
225
+
226
+ model_name_or_path = "TheBloke/Airoboros-180B-2.2.1-AWQ"
227
+
228
+ # Load tokenizer
229
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True)
230
+ # Load model
231
+ model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
232
+ trust_remote_code=True, safetensors=True)
233
+
234
+ prompt = "Tell me about AI"
235
+ prompt_template=f'''A chat.
236
+ USER: {prompt}
237
+ ASSISTANT:
238
+ '''
239
+
240
+ print("*** Running model.generate:")
241
+
242
+ token_input = tokenizer(
243
+ prompt_template,
244
+ return_tensors='pt'
245
+ ).input_ids.cuda()
246
+
247
+ # Generate output
248
+ generation_output = model.generate(
249
+ token_input,
250
+ do_sample=True,
251
+ temperature=0.7,
252
+ top_p=0.95,
253
+ top_k=40,
254
+ max_new_tokens=512
255
+ )
256
+
257
+ # Get the tokens from the output, decode them, print them
258
+ token_output = generation_output[0]
259
+ text_output = tokenizer.decode(token_output)
260
+ print("LLM output: ", text_output)
261
+
262
+ """
263
+ # Inference should be possible with transformers pipeline as well in future
264
+ # But currently this is not yet supported by AutoAWQ (correct as of September 25th 2023)
265
+ from transformers import pipeline
266
+
267
+ print("*** Pipeline:")
268
+ pipe = pipeline(
269
+ "text-generation",
270
+ model=model,
271
+ tokenizer=tokenizer,
272
+ max_new_tokens=512,
273
+ do_sample=True,
274
+ temperature=0.7,
275
+ top_p=0.95,
276
+ top_k=40,
277
+ repetition_penalty=1.1
278
+ )
279
+
280
+ print(pipe(prompt_template)[0]['generated_text'])
281
+ """
282
+ ```
283
+ <!-- README_AWQ.md-use-from-python end -->
284
+
285
+ <!-- README_AWQ.md-compatibility start -->
286
+ ## Compatibility
287
+
288
+ The files provided are tested to work with:
289
+
290
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
291
+ - [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
292
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
293
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
294
+
295
+ <!-- README_AWQ.md-compatibility end -->
296
+
297
+ <!-- footer start -->
298
+ <!-- 200823 -->
299
+ ## Discord
300
+
301
+ For further support, and discussions on these models and AI in general, join us at:
302
+
303
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
304
+
305
+ ## Thanks, and how to contribute
306
+
307
+ Thanks to the [chirper.ai](https://chirper.ai) team!
308
+
309
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
310
+
311
+ 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.
312
+
313
+ 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.
314
+
315
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
316
+
317
+ * Patreon: https://patreon.com/TheBlokeAI
318
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
319
+
320
+ **Special thanks to**: Aemon Algiz.
321
+
322
+ **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
323
+
324
+
325
+ Thank you to all my generous patrons and donaters!
326
+
327
+ And thank you again to a16z for their generous grant.
328
+
329
+ <!-- footer end -->
330
+
331
+ # Original model card: Jon Durbin's Airoboros 180B 2.2.1
332
+
333
+
334
+ ### Overview
335
+
336
+ Another experimental model, using mostly sythetic data generated by [airoboros](https://github.com/jondurbin/airoboros)
337
+
338
+ This is a fine-tune of the falcon-180b model, bumped to 4k context via rope scaling, on the [airoboros-2.2.1 dataset](https://hf.co/datasets/jondurbin/airoboros-2.2.1)
339
+
340
+ Base model link: https://huggingface.co/tiiuae/falcon-180B
341
+
342
+ The base model has a custom license: https://huggingface.co/tiiuae/falcon-180B/raw/main/LICENSE.txt
343
+
344
+ __*Q4_0 quantization will likely not work due to quantized/unquantized (recommended) merge method!*__
345
+
346
+ This is a fairly general purpose model, but focuses heavily on instruction following, rather than casual chat/roleplay.
347
+
348
+ Huge thank you to the folks over at [a16z](https://a16z.com/) for sponsoring the costs associated with building models and associated tools!
349
+
350
+ ### Prompt format
351
+
352
+ The prompt format:
353
+
354
+ ```
355
+ A chat.
356
+ USER: {prompt}
357
+ ASSISTANT:
358
+ ```
359
+
360
+ The default system prompt ("A chat.") was used for most of the prompts, however it also included a wide sampling of responses with other prompts, particularly in "stylized\_response", "rp", "gtkm", etc.
361
+
362
+ Here's another example:
363
+ ```
364
+ A chat between Bob (aka USER) and Tom (aka ASSISTANT). Tom is an extremely intelligent 18th century bookkeeper, who speaks loquaciously.
365
+ USER: {prompt}
366
+ ASSISTANT:
367
+ ```
368
+
369
+ And chat scenario that wouldn't require USER/ASSISTANT (but should use stopping criteria to prevent the model from speaking on your behalf).
370
+ ```
371
+ A chat between old friends: Timmy and Tommy.
372
+ {description of characters}
373
+
374
+ {setting for the chat}
375
+ Timmy: *takes a big sip from his coffee* "Ah, sweet, delicious, magical coffee."
376
+ Tommy:
377
+ ```
378
+
379
+ __*I strongly suggest adding stopping criteria/early inference stopping on "USER:", and/or whatever names you specify in the system prompt.*__
380
+
381
+ ### Fine tuning info
382
+
383
+ https://wandb.ai/jondurbin/airoboros-l2-70b-2.2.1/runs/f91zmwuz?workspace=user-jondurbin
384
+
385
+ ### Helpful usage tips
386
+
387
+ *The prompts shown here are are just the text that would be included after USER: and before ASSISTANT: in the full prompt format above, the system prompt and USER:/ASSISTANT: have been omited for readability.*
388
+
389
+ #### Context obedient question answering
390
+
391
+ By obedient, I mean the model was trained to ignore what it thinks it knows, and uses the context to answer the question. The model was also tuned to limit the values to the provided context as much as possible to reduce hallucinations.
392
+
393
+ The format for a closed-context prompt is as follows:
394
+ ```
395
+ BEGININPUT
396
+ BEGINCONTEXT
397
+ [key0: value0]
398
+ [key1: value1]
399
+ ... other metdata ...
400
+ ENDCONTEXT
401
+ [insert your text blocks here]
402
+ ENDINPUT
403
+ [add as many other blocks, in the exact same format]
404
+ BEGININSTRUCTION
405
+ [insert your instruction(s). The model was tuned with single questions, paragraph format, lists, etc.]
406
+ ENDINSTRUCTION
407
+ ```
408
+
409
+ It's also helpful to add "Don't make up answers if you don't know." to your instruction block to make sure if the context is completely unrelated it doesn't make something up.
410
+
411
+ *The __only__ prompts that need this closed context formating are closed-context instructions. Normal questions/instructions do not!*
412
+
413
+ I know it's a bit verbose and annoying, but after much trial and error, using these explicit delimiters helps the model understand where to find the responses and how to associate specific sources with it.
414
+ - `BEGININPUT` - denotes a new input block
415
+ - `BEGINCONTEXT` - denotes the block of context (metadata key/value pairs) to associate with the current input block
416
+ - `ENDCONTEXT` - denotes the end of the metadata block for the current input
417
+ - [text] - Insert whatever text you want for the input block, as many paragraphs as can fit in the context.
418
+ - `ENDINPUT` - denotes the end of the current input block
419
+ - [repeat as many input blocks in this format as you want]
420
+ - `BEGININSTRUCTION` - denotes the start of the list (or one) instruction(s) to respond to for all of the input blocks above.
421
+ - [instruction(s)]
422
+ - `ENDINSTRUCTION` - denotes the end of instruction set
423
+
424
+ It sometimes works without `ENDINSTRUCTION`, but by explicitly including that in the prompt, the model better understands that all of the instructions in the block should be responded to.
425
+
426
+ Here's a trivial, but important example to prove the point:
427
+ ```
428
+ BEGININPUT
429
+ BEGINCONTEXT
430
+ date: 2021-01-01
431
+ url: https://web.site/123
432
+ ENDCONTEXT
433
+ In a shocking turn of events, blueberries are now green, but will be sticking with the same name.
434
+ ENDINPUT
435
+ BEGININSTRUCTION
436
+ What color are bluberries? Source?
437
+ ENDINSTRUCTION
438
+ ```
439
+
440
+ And the response:
441
+ ```
442
+ Blueberries are now green.
443
+ Source:
444
+ date: 2021-01-01
445
+ url: https://web.site/123
446
+ ```
447
+
448
+ #### Summarization
449
+
450
+ 500 samples have been included from [this dataset](https://huggingface.co/datasets/mattpscott/airoboros-summarization), using the same format as contextual question answering, for example:
451
+
452
+ ```
453
+ BEGININPUT
454
+ {text to summarize}
455
+ ENDINPUT
456
+ BEGININSTRUCTION
457
+ Summarize the input in around 130 words.
458
+ ENDINSTRUCTION
459
+ ```
460
+
461
+ #### Getting longer responses
462
+
463
+ You can use a few techniques to get longer responses.
464
+
465
+ Detailed prompts, with explicit instruction for word count:
466
+ ```
467
+ Please compose a narrative set in the heart of an ancient library, steeped in the scent of old parchment and ink. The protagonist should be a young scholar who is dedicated to studying the art of storytelling and its evolution throughout history. In her pursuit of knowledge, she stumbles upon a forgotten tome that seems to possess an unusual aura. This book has the ability to bring stories to life, literally manifesting characters and scenarios from within its pages into reality.
468
+
469
+ The main character must navigate through various epochs of storytelling - from oral traditions of tribal societies, through medieval minstrels' tales, to modern-day digital narratives - as they come alive around her. Each era presents its unique challenges and lessons about the power and impact of stories on human civilization.
470
+
471
+ One such character could be a sentient quill pen, who was once used by renowned authors of yesteryears and now holds their wisdom and experiences. It becomes her mentor, guiding her through this journey with witty remarks and insightful commentary.
472
+
473
+ Ensure that your tale encapsulates the thrill of adventure, the beauty of learning, and the profound connection between humans and their stories. All characters involved should be non-human entities. Feel free to explore creative liberties but maintain the mentioned elements.
474
+
475
+ Your response should be approximately 2300 words.
476
+ ```
477
+
478
+ Or, a simpler example:
479
+ ```
480
+ Please create a long, detailed story about a dragon in an old growth forest who, for some reason, begins speaking the words of the source code of linux.
481
+ ```
482
+
483
+ #### Coding
484
+
485
+ You can ask for fairly complex coding instructions with multiple criteria, e.g.:
486
+
487
+ ```
488
+ Create a python application with the following requirements:
489
+ - Asyncio FastAPI webserver
490
+ - ping endpoint that returns the current date in JSON format
491
+ - file upload endpoint, which calculates the file's sha256 checksum, and checks postgres to deduplicate
492
+ ```
493
+
494
+ Or inline criteria:
495
+
496
+ ```
497
+ Write a multi-threaded TCP server in C that accepts a "GET [key]" input and "SET [key] [value]" input, and uses a binary tree to get and store the input values.
498
+ ```
499
+
500
+ You can also optionally add a single space and "PLAINFORMAT" at the end of your prompt to avoid backticks, explanations, etc. and just print the code, e.g.:
501
+
502
+ ```
503
+ Write a websocket application in node.js. PLAINFORMAT
504
+ ```
505
+
506
+ #### Agent/function calling
507
+
508
+ The dataset includes many examples of function/args generation based on input criteria. This is somewhat similar to the OpenAI function calling, but the output is either JSON or YAML.
509
+
510
+ Example prompt:
511
+ ```
512
+ As an AI assistant, please select the most suitable function and parameters from the list of available functions below, based on the user's input. Provide your response in JSON format.
513
+
514
+ Input: I want to know how many times 'Python' is mentioned in my text file.
515
+
516
+ Available functions:
517
+ file_analytics:
518
+ description: This tool performs various operations on a text file.
519
+ params:
520
+ action: The operation we want to perform on the data, such as "count_occurrences", "find_line", etc.
521
+ filters:
522
+ keyword: The word or phrase we want to search for.
523
+ ```
524
+
525
+ Response:
526
+ ```json
527
+ {
528
+ "function": "file_analytics",
529
+ "params": {
530
+ "action": "count_occurrences",
531
+ "filters": {
532
+ "keyword": "Python"
533
+ }
534
+ }
535
+ }
536
+ ```
537
+
538
+ #### Chain-of-thought
539
+
540
+ You can ask for several possible responses to a given problem, with a ranking and final answer selection.
541
+
542
+ Example prompt:
543
+
544
+ ```
545
+ A group of people decide to play a round-robin tournament where every player plays every other player exactly once. If a total of 45 games were played, how many players participated in the tournament? Offer several potential answers, rank them according to mathematical logic, and pick the most feasible one.
546
+ ```
547
+
548
+ Example response:
549
+ ```
550
+ Solution 1:
551
+ In a round-robin tournament, each player plays every other player exactly once. This means that the total number of games played is equal to the combination of all players taken two at a time (since a game involves two players).
552
+
553
+ The formula for combinations is nC2 = n(n-1)/2, where n is the total number of players. We know that nC2 equals 45 (the total number of games), so we can set up the equation as follows:
554
+
555
+ n(n-1)/2 = 45
556
+
557
+ Solving this equation gives us n=10.
558
+
559
+ Final answer: There were 10 players in the tournament.
560
+
561
+ Solution 2:
562
+ Another way to approach this problem is by using the concept of triangular numbers. Triangular numbers are a sequence of numbers where each number can be represented as a triangle with dots. The nth triangular number is given by the sum of the first n natural numbers.
563
+
564
+ If we consider each game as a dot and each player as a side of the triangle, then the total number of games (45) would correspond to the 9th triangular number because 1+2+3+4+5+6+7+8+9=45. However, since each side of the triangle represents a player, and there's one more player than sides in our model (because the last player has no one left to play against), we need to add one more to get the total number of players.
565
+
566
+ Final answer: There were 10 players in the tournament.
567
+
568
+ Solution 3:
569
+ We could also use trial and error to solve this problem. Starting from a small number of players, we calculate how many games would be played in a round-robin tournament until we reach 45 games. For example, with 2 players, only 1 game is played; with 3 players, 3 games are played; with 4 players, 6 games are played, and so on. Continuing this process, we find that with 10 players, 45 games are played.
570
+
571
+ Final answer: There were 10 players in the tournament.
572
+
573
+ Ranking of solutions from best to worst:
574
+ 1. Solution 1: This solution uses direct mathematical reasoning based on the properties of a round-robin tournament and solves an equation to find the answer.
575
+ 2. Solution 2: This solution uses the concept of triangular numbers which requires additional steps and knowledge beyond the immediate problem context, but still arrives at the correct answer.
576
+ 3. Solution 3: This solution relies on trial and error, which is less efficient and reliable than the other methods, but it eventually gets to the right answer.
577
+
578
+ Best and final answer: There were 10 players in the tournament.
579
+ ```
580
+
581
+ #### reWOO style execution planning
582
+
583
+ The model now supports execution planning for complex instructions that would require making use of several tools. The output is just the plan, you must implement a mechanism to parse the output and actually call the functions!
584
+
585
+ Example prompt:
586
+ ```
587
+ Please construct a systematic plan to generate an optimal response to the user instruction, utilizing a set of provided tools. Each plan will correspond to an evidence value, which will be the output of one of the available functions given an input string
588
+ that could be the user's question, one or more prior evidence values, or a combination of both.
589
+
590
+ Here are the tools available to be called:
591
+ DuckDuckGo[input]: Tool that enables the user to search for information using the DuckDuckGo search engine. This tool is helpful in locating a suitable list of sites that may contain the answer to the user's query. It does not directly answer the question but finds a list of sites that might have the answer.
592
+ TextScraper[input]: Load one or more websites from the input string containing newline delimited links, where input is one or more links, and produces plain text output containing the content of the links.
593
+ HyperlinkExtractor[input]: Extract links from plain text and produces a plain text, newline delimited response of links.
594
+ KnowledgeModel[input]: Question answering language model, particularly useful in answering questions based on an input passage of text. The input must be a text question that references an :evidence[n]: variable, e.g. What color is the cat, given :evidence1:?
595
+
596
+ The output should be in format:
597
+ Plan: [first action to take based on input question]
598
+ :evidence0: = [function to call with input parameter]
599
+ Plan: [next action to take, based on result of :evidence0:]
600
+ :evidence1: = [next function to call and input parameter, which may include reference to previous evidence, e.g. "Given context :evidence0"]
601
+ ...
602
+ Answer: [:evidence[n]: containing the final answer.]
603
+
604
+ Question: Who won the Nobel Prize in Literature in 2020 and what is their most famous work?
605
+ ```
606
+
607
+ Response:
608
+ ```
609
+ Plan: Begin by conducting a web search to find out who won the Nobel Prize in Literature in 2020.
610
+ :evidence0: = DuckDuckGo[Nobel Prize in Literature 2020 winner]
611
+ Plan: Utilize the KnowledgeModel to interpret the search results and find the name of the laureate.
612
+ :evidence1: = KnowledgeModel[Who won the Nobel Prize in Literature in 2020, given :evidence0:?]
613
+ Plan: Conduct another web search to find the most famous work of the identified laureate.
614
+ :evidence2: = DuckDuckGo[Most famous work of :evidence1:]
615
+ Plan: Extract the relevant links from the DuckDuckGo search results for a more focused search.
616
+ :evidence3: = HyperlinkExtractor[:evidence2:]
617
+ Plan: Use the TextScraper tool to extract information from the relevant links.
618
+ :evidence4: = TextScraper[:evidence3:]
619
+ Plan: Finally, utilize the KnowledgeModel to identify and summarize the most famous work of the laureate from the extracted information.
620
+ :evidence5: = KnowledgeModel[What is the most famous work of :evidence1:, given :evidence4:?]
621
+ Answer: :evidence5:
622
+ ```
623
+
624
+ For this to be useful, you'd have to parse the output plan text, and implement/call each of the functions. This is just pseudo-code, completely untested off the top of my head, and obviously would requiring full implementation + hardening:
625
+
626
+ ```python
627
+ import re
628
+ import requests
629
+
630
+ def inject_context(input_text, **context):
631
+ for ref in set(re.findall(r"(:evidence[0-9]+:)", input_text, re.I)):
632
+ input_text = input_text.replace(ref, context.get(ref, ""))
633
+ return input_text
634
+
635
+ def duckduckgo(input_text, **context):
636
+ search_string = inject_context(input_text, **context)
637
+ ... search via duck duck go using search_string
638
+ ... return text content
639
+
640
+ def link_extractor(input_text, **context):
641
+ input_text = inject_context(input_text, **context)
642
+ return "\n".join(list(set(re.findall(r"(https?://[^\s]+?\.?)", input_text, re.I))))
643
+
644
+ def scrape(input_text, **context):
645
+ input_text = inject_context(input_text, **context)
646
+ text = []
647
+ for link in input_text.splitlines():
648
+ text.append(requests.get(link).text)
649
+ return "\n".join(text)
650
+
651
+ def infer(input_text, **context)
652
+ prompt = inject_context(input_text, **context)
653
+ ... call model with prompt, return output
654
+
655
+ def parse_plan(plan):
656
+ method_map = {
657
+ "DuckDuckGo": duckduckgo,
658
+ "HyperlinkExtractor": link_extractor,
659
+ "KnowledgeModel": infer,
660
+ "TextScraper": scrape,
661
+ }
662
+ context = {}
663
+ for line in plan.strip().splitlines():
664
+ if line.startswith("Plan:"):
665
+ print(line)
666
+ continue
667
+ parts = re.match("^(:evidence[0-9]+:)\s*=\s*([^\[]+])(\[.*\])\s$", line, re.I)
668
+ if not parts:
669
+ if line.startswith("Answer: "):
670
+ return context.get(line.split(" ")[-1].strip(), "Answer couldn't be generated...")
671
+ raise RuntimeError("bad format: " + line)
672
+ context[parts.group(1)] = method_map[parts.group(2)](parts.group(3), **context)
673
+ ```
674
+
675
+ ### Contribute
676
+
677
+ If you're interested in new functionality, particularly a new "instructor" type to generate a specific type of training data,
678
+ take a look at the dataset generation tool repo: https://github.com/jondurbin/airoboros and either make a PR or open an issue with details.
679
+
680
+ To help me with the OpenAI/compute costs:
681
+
682
+ - https://bmc.link/jondurbin
683
+ - ETH 0xce914eAFC2fe52FdceE59565Dd92c06f776fcb11
684
+ - BTC bc1qdwuth4vlg8x37ggntlxu5cjfwgmdy5zaa7pswf
685
+
686
+ ### Licence and usage restrictions
687
+
688
+ The airoboros 2.2 models with `l2` in the name are built on top of llama-2/codellama.
689
+
690
+ The llama-2 base model has a custom Meta license:
691
+ - See the [meta-license/LICENSE.txt](meta-license/LICENSE.txt) file attached for the original license provided by Meta.
692
+ - See also [meta-license/USE_POLICY.md](meta-license/USE_POLICY.md) and [meta-license/Responsible-Use-Guide.pdf](meta-license/Responsible-Use-Guide.pdf), also provided by Meta.
693
+
694
+ The fine-tuning data was mostly generated by OpenAI API calls to gpt-4, via [airoboros](https://github.com/jondurbin/airoboros)
695
+
696
+ The ToS for OpenAI API usage has a clause preventing the output from being used to train a model that __competes__ with OpenAI
697
+
698
+ - what does *compete* actually mean here?
699
+ - these small open source models will not produce output anywhere near the quality of gpt-4, or even gpt-3.5, so I can't imagine this could credibly be considered competing in the first place
700
+ - if someone else uses the dataset to do the same, they wouldn't necessarily be violating the ToS because they didn't call the API, so I don't know how that works
701
+ - the training data used in essentially all large language models includes a significant amount of copyrighted or otherwise non-permissive licensing in the first place
702
+ - other work using the self-instruct method, e.g. the original here: https://github.com/yizhongw/self-instruct released the data and model as apache-2
703
+
704
+ I am purposingly leaving this license ambiguous (other than the fact you must comply with the Meta original license for llama-2) because I am not a lawyer and refuse to attempt to interpret all of the terms accordingly.
705
+
706
+ Your best bet is probably to avoid using this commercially due to the OpenAI API usage.
707
+
708
+ Either way, by using this model, you agree to completely indemnify me.