TheBloke commited on
Commit
2028cf1
1 Parent(s): 7f327eb

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +613 -0
README.md ADDED
@@ -0,0 +1,613 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: https://huggingface.co/jondurbin/airoboros-l2-7b-2.2.1
3
+ datasets:
4
+ - jondurbin/airoboros-2.2.1
5
+ inference: false
6
+ license: llama2
7
+ model_creator: Jon Durbin
8
+ model_name: Airoboros L2 7B 2.2.1
9
+ model_type: llama
10
+ prompt_template: "A chat.\nUSER: {prompt}\nASSISTANT: \n"
11
+ quantized_by: TheBloke
12
+ ---
13
+
14
+ <!-- header start -->
15
+ <!-- 200823 -->
16
+ <div style="width: auto; margin-left: auto; margin-right: auto">
17
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
18
+ </div>
19
+ <div style="display: flex; justify-content: space-between; width: 100%;">
20
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
21
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
22
+ </div>
23
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
24
+ <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>
25
+ </div>
26
+ </div>
27
+ <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>
28
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
29
+ <!-- header end -->
30
+
31
+ # Airoboros L2 7B 2.2.1 - AWQ
32
+ - Model creator: [Jon Durbin](https://huggingface.co/jondurbin)
33
+ - Original model: [Airoboros L2 7B 2.2.1](https://huggingface.co/jondurbin/airoboros-l2-7b-2.2.1)
34
+
35
+ <!-- description start -->
36
+ ## Description
37
+
38
+ This repo contains AWQ model files for [Jon Durbin's Airoboros L2 7B 2.2.1](https://huggingface.co/jondurbin/airoboros-l2-7b-2.2.1).
39
+
40
+
41
+ ### About AWQ
42
+
43
+ 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.
44
+
45
+ It is also now supported by continuous batching server [vLLM](https://github.com/vllm-project/vllm), allowing use of AWQ models for high-throughput concurrent inference in multi-user server scenarios. Note that, at the time of writing, overall throughput is still lower than running vLLM with unquantised models, however using AWQ enables using much smaller GPUs which can lead to easier deployment and overall cost savings. For example, a 70B model can be run on 1 x 48GB GPU instead of 2 x 80GB.
46
+ <!-- description end -->
47
+ <!-- repositories-available start -->
48
+ ## Repositories available
49
+
50
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/airoboros-l2-7B-2.2.1-AWQ)
51
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/airoboros-l2-7B-2.2.1-GPTQ)
52
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/airoboros-l2-7B-2.2.1-GGUF)
53
+ * [Jon Durbin's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/jondurbin/airoboros-l2-7b-2.2.1)
54
+ <!-- repositories-available end -->
55
+
56
+ <!-- prompt-template start -->
57
+ ## Prompt template: Chat
58
+
59
+ ```
60
+ A chat.
61
+ USER: {prompt}
62
+ ASSISTANT:
63
+
64
+ ```
65
+
66
+ <!-- prompt-template end -->
67
+
68
+
69
+ <!-- README_AWQ.md-provided-files start -->
70
+ ## Provided files and AWQ parameters
71
+
72
+ 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.
73
+
74
+ Models are released as sharded safetensors files.
75
+
76
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
77
+ | ------ | ---- | -- | ----------- | ------- | ---- |
78
+ | [main](https://huggingface.co/TheBloke/airoboros-l2-7B-2.2.1-AWQ/tree/main) | 4 | 128 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-v1/test) | 4096 | 3.89 GB
79
+
80
+ <!-- README_AWQ.md-provided-files end -->
81
+
82
+ <!-- README_AWQ.md-use-from-vllm start -->
83
+ ## Serving this model from vLLM
84
+
85
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
86
+
87
+ - When using vLLM as a server, pass the `--quantization awq` parameter, for example:
88
+
89
+ ```shell
90
+ python3 python -m vllm.entrypoints.api_server --model TheBloke/airoboros-l2-7B-2.2.1-AWQ --quantization awq --dtype half
91
+ ```
92
+
93
+ When using vLLM from Python code, pass the `quantization=awq` parameter, for example:
94
+
95
+ ```python
96
+ from vllm import LLM, SamplingParams
97
+
98
+ prompts = [
99
+ "Hello, my name is",
100
+ "The president of the United States is",
101
+ "The capital of France is",
102
+ "The future of AI is",
103
+ ]
104
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
105
+
106
+ llm = LLM(model="TheBloke/airoboros-l2-7B-2.2.1-AWQ", quantization="awq", dtype="half")
107
+
108
+ outputs = llm.generate(prompts, sampling_params)
109
+
110
+ # Print the outputs.
111
+ for output in outputs:
112
+ prompt = output.prompt
113
+ generated_text = output.outputs[0].text
114
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
115
+ ```
116
+ <!-- README_AWQ.md-use-from-vllm start -->
117
+
118
+ <!-- README_AWQ.md-use-from-python start -->
119
+ ## How to use this AWQ model from Python code
120
+
121
+ ### Install the necessary packages
122
+
123
+ Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.0.2 or later
124
+
125
+ ```shell
126
+ pip3 install autoawq
127
+ ```
128
+
129
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
130
+
131
+ ```shell
132
+ pip3 uninstall -y autoawq
133
+ git clone https://github.com/casper-hansen/AutoAWQ
134
+ cd AutoAWQ
135
+ pip3 install .
136
+ ```
137
+
138
+ ### You can then try the following example code
139
+
140
+ ```python
141
+ from awq import AutoAWQForCausalLM
142
+ from transformers import AutoTokenizer
143
+
144
+ model_name_or_path = "TheBloke/airoboros-l2-7B-2.2.1-AWQ"
145
+
146
+ # Load model
147
+ model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
148
+ trust_remote_code=False, safetensors=True)
149
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=False)
150
+
151
+ prompt = "Tell me about AI"
152
+ prompt_template=f'''A chat.
153
+ USER: {prompt}
154
+ ASSISTANT:
155
+
156
+ '''
157
+
158
+ print("\n\n*** Generate:")
159
+
160
+ tokens = tokenizer(
161
+ prompt_template,
162
+ return_tensors='pt'
163
+ ).input_ids.cuda()
164
+
165
+ # Generate output
166
+ generation_output = model.generate(
167
+ tokens,
168
+ do_sample=True,
169
+ temperature=0.7,
170
+ top_p=0.95,
171
+ top_k=40,
172
+ max_new_tokens=512
173
+ )
174
+
175
+ print("Output: ", tokenizer.decode(generation_output[0]))
176
+
177
+ # Inference can also be done using transformers' pipeline
178
+ from transformers import pipeline
179
+
180
+ print("*** Pipeline:")
181
+ pipe = pipeline(
182
+ "text-generation",
183
+ model=model,
184
+ tokenizer=tokenizer,
185
+ max_new_tokens=512,
186
+ do_sample=True,
187
+ temperature=0.7,
188
+ top_p=0.95,
189
+ top_k=40,
190
+ repetition_penalty=1.1
191
+ )
192
+
193
+ print(pipe(prompt_template)[0]['generated_text'])
194
+ ```
195
+ <!-- README_AWQ.md-use-from-python end -->
196
+
197
+ <!-- README_AWQ.md-compatibility start -->
198
+ ## Compatibility
199
+
200
+ The files provided are tested to work with [AutoAWQ](https://github.com/casper-hansen/AutoAWQ), and [vLLM](https://github.com/vllm-project/vllm).
201
+
202
+ [Huggingface Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) is not yet compatible with AWQ, but a PR is open which should bring support soon: [TGI PR #781](https://github.com/huggingface/text-generation-inference/issues/781).
203
+ <!-- README_AWQ.md-compatibility end -->
204
+
205
+ <!-- footer start -->
206
+ <!-- 200823 -->
207
+ ## Discord
208
+
209
+ For further support, and discussions on these models and AI in general, join us at:
210
+
211
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
212
+
213
+ ## Thanks, and how to contribute
214
+
215
+ Thanks to the [chirper.ai](https://chirper.ai) team!
216
+
217
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
218
+
219
+ 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.
220
+
221
+ 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.
222
+
223
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
224
+
225
+ * Patreon: https://patreon.com/TheBlokeAI
226
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
227
+
228
+ **Special thanks to**: Aemon Algiz.
229
+
230
+ **Patreon special mentions**: Alicia Loh, Stephen Murray, K, Ajan Kanaga, RoA, Magnesian, Deo Leter, Olakabola, Eugene Pentland, zynix, Deep Realms, Raymond Fosdick, Elijah Stavena, Iucharbius, Erik Bjäreholt, Luis Javier Navarrete Lozano, Nicholas, theTransient, John Detwiler, alfie_i, knownsqashed, Mano Prime, Willem Michiel, Enrico Ros, LangChain4j, OG, Michael Dempsey, Pierre Kircher, Pedro Madruga, James Bentley, Thomas Belote, Luke @flexchar, Leonard Tan, Johann-Peter Hartmann, Illia Dulskyi, Fen Risland, Chadd, S_X, Jeff Scroggin, Ken Nordquist, Sean Connelly, Artur Olbinski, Swaroop Kallakuri, Jack West, Ai Maven, David Ziegler, Russ Johnson, transmissions 11, John Villwock, Alps Aficionado, Clay Pascal, Viktor Bowallius, Subspace Studios, Rainer Wilmers, Trenton Dambrowitz, vamX, Michael Levine, 준교 김, Brandon Frisco, Kalila, Trailburnt, Randy H, Talal Aujan, Nathan Dryer, Vadim, 阿明, ReadyPlayerEmma, Tiffany J. Kim, George Stoitzev, Spencer Kim, Jerry Meng, Gabriel Tamborski, Cory Kujawski, Jeffrey Morgan, Spiking Neurons AB, Edmond Seymore, Alexandros Triantafyllidis, Lone Striker, Cap'n Zoog, Nikolai Manek, danny, ya boyyy, Derek Yates, usrbinkat, Mandus, TL, Nathan LeClaire, subjectnull, Imad Khwaja, webtim, Raven Klaugh, Asp the Wyvern, Gabriel Puliatti, Caitlyn Gatomon, Joseph William Delisle, Jonathan Leane, Luke Pendergrass, SuperWojo, Sebastain Graf, Will Dee, Fred von Graf, Andrey, Dan Guido, Daniel P. Andersen, Nitin Borwankar, Elle, Vitor Caleffi, biorpg, jjj, NimbleBox.ai, Pieter, Matthew Berman, terasurfer, Michael Davis, Alex, Stanislav Ovsiannikov
231
+
232
+
233
+ Thank you to all my generous patrons and donaters!
234
+
235
+ And thank you again to a16z for their generous grant.
236
+
237
+ <!-- footer end -->
238
+
239
+ # Original model card: Jon Durbin's Airoboros L2 7B 2.2.1
240
+
241
+
242
+ ### Overview
243
+
244
+ Another experimental model, using mostly sythetic data generated by [airoboros](https://github.com/jondurbin/airoboros)
245
+
246
+ This is essentially a minor "fix" branch of [airoboros-l2-7b-2.2](https://hf.co/jondurbin/airoboros-l2-7b-2.2) with a updates, primarily:
247
+ - [re-generated writing responses](https://huggingface.co/datasets/jondurbin/airoboros-2.2.1#re-generated-writing-responses)
248
+ - [longer contextual blocks](https://huggingface.co/datasets/jondurbin/airoboros-2.2.1#longer-contextual-blocks)
249
+ - [removal of "rp" data](https://huggingface.co/datasets/jondurbin/airoboros-2.2.1#rp-category-removed)
250
+
251
+ This is a fairly general purpose model, but focuses heavily on instruction following, rather than casual chat/roleplay.
252
+
253
+ Huge thank you to the folks over at [a16z](https://a16z.com/) for sponsoring the costs associated with building models and associated tools!
254
+
255
+ ### Prompt format
256
+
257
+ The prompt format:
258
+
259
+ ```
260
+ A chat.
261
+ USER: {prompt}
262
+ ASSISTANT:
263
+ ```
264
+
265
+ 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.
266
+
267
+ Here's another example:
268
+ ```
269
+ A chat between Bob (aka USER) and Tom (aka ASSISTANT). Tom is an extremely intelligent 18th century bookkeeper, who speaks loquaciously.
270
+ USER: {prompt}
271
+ ASSISTANT:
272
+ ```
273
+
274
+ And chat scenario that wouldn't require USER/ASSISTANT (but should use stopping criteria to prevent the model from speaking on your behalf).
275
+ ```
276
+ A chat between old friends: Timmy and Tommy.
277
+ {description of characters}
278
+
279
+ {setting for the chat}
280
+ Timmy: *takes a big sip from his coffee* "Ah, sweet, delicious, magical coffee."
281
+ Tommy:
282
+ ```
283
+
284
+ __*I strongly suggest adding stopping criteria/early inference stopping on "USER:", and/or whatever names you specify in the system prompt.*__
285
+
286
+ ### Fine tuning info
287
+
288
+ https://wandb.ai/jondurbin/airoboros-l2-7b-2.2.1/runs/ka6jlcj7?workspace=user-jondurbin
289
+
290
+ ### Helpful usage tips
291
+
292
+ *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.*
293
+
294
+ #### Context obedient question answering
295
+
296
+ 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.
297
+
298
+ The format for a closed-context prompt is as follows:
299
+ ```
300
+ BEGININPUT
301
+ BEGINCONTEXT
302
+ [key0: value0]
303
+ [key1: value1]
304
+ ... other metdata ...
305
+ ENDCONTEXT
306
+ [insert your text blocks here]
307
+ ENDINPUT
308
+ [add as many other blocks, in the exact same format]
309
+ BEGININSTRUCTION
310
+ [insert your instruction(s). The model was tuned with single questions, paragraph format, lists, etc.]
311
+ ENDINSTRUCTION
312
+ ```
313
+
314
+ 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.
315
+
316
+ *The __only__ prompts that need this closed context formating are closed-context instructions. Normal questions/instructions do not!*
317
+
318
+ 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.
319
+ - `BEGININPUT` - denotes a new input block
320
+ - `BEGINCONTEXT` - denotes the block of context (metadata key/value pairs) to associate with the current input block
321
+ - `ENDCONTEXT` - denotes the end of the metadata block for the current input
322
+ - [text] - Insert whatever text you want for the input block, as many paragraphs as can fit in the context.
323
+ - `ENDINPUT` - denotes the end of the current input block
324
+ - [repeat as many input blocks in this format as you want]
325
+ - `BEGININSTRUCTION` - denotes the start of the list (or one) instruction(s) to respond to for all of the input blocks above.
326
+ - [instruction(s)]
327
+ - `ENDINSTRUCTION` - denotes the end of instruction set
328
+
329
+ 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.
330
+
331
+ Here's a trivial, but important example to prove the point:
332
+ ```
333
+ BEGININPUT
334
+ BEGINCONTEXT
335
+ date: 2021-01-01
336
+ url: https://web.site/123
337
+ ENDCONTEXT
338
+ In a shocking turn of events, blueberries are now green, but will be sticking with the same name.
339
+ ENDINPUT
340
+ BEGININSTRUCTION
341
+ What color are bluberries? Source?
342
+ ENDINSTRUCTION
343
+ ```
344
+
345
+ And the response:
346
+ ```
347
+ Blueberries are now green.
348
+ Source:
349
+ date: 2021-01-01
350
+ url: https://web.site/123
351
+ ```
352
+
353
+ #### Summarization
354
+
355
+ 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:
356
+
357
+ ```
358
+ BEGININPUT
359
+ {text to summarize}
360
+ ENDINPUT
361
+ BEGININSTRUCTION
362
+ Summarize the input in around 130 words.
363
+ ENDINSTRUCTION
364
+ ```
365
+
366
+ #### Getting longer responses
367
+
368
+ You can use a few techniques to get longer responses.
369
+
370
+ Detailed prompts, with explicit instruction for word count:
371
+ ```
372
+ 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.
373
+
374
+ 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.
375
+
376
+ 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.
377
+
378
+ 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.
379
+
380
+ Your response should be approximately 2300 words.
381
+ ```
382
+
383
+ Or, a simpler example:
384
+ ```
385
+ 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.
386
+ ```
387
+
388
+ #### Coding
389
+
390
+ You can ask for fairly complex coding instructions with multiple criteria, e.g.:
391
+
392
+ ```
393
+ Create a python application with the following requirements:
394
+ - Asyncio FastAPI webserver
395
+ - ping endpoint that returns the current date in JSON format
396
+ - file upload endpoint, which calculates the file's sha256 checksum, and checks postgres to deduplicate
397
+ ```
398
+
399
+ Or inline criteria:
400
+
401
+ ```
402
+ 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.
403
+ ```
404
+
405
+ 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.:
406
+
407
+ ```
408
+ Write a websocket application in node.js. PLAINFORMAT
409
+ ```
410
+
411
+ #### Agent/function calling
412
+
413
+ 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.
414
+
415
+ Example prompt:
416
+ ```
417
+ 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.
418
+
419
+ Input: I want to know how many times 'Python' is mentioned in my text file.
420
+
421
+ Available functions:
422
+ file_analytics:
423
+ description: This tool performs various operations on a text file.
424
+ params:
425
+ action: The operation we want to perform on the data, such as "count_occurrences", "find_line", etc.
426
+ filters:
427
+ keyword: The word or phrase we want to search for.
428
+ ```
429
+
430
+ Response:
431
+ ```json
432
+ {
433
+ "function": "file_analytics",
434
+ "params": {
435
+ "action": "count_occurrences",
436
+ "filters": {
437
+ "keyword": "Python"
438
+ }
439
+ }
440
+ }
441
+ ```
442
+
443
+ #### Chain-of-thought
444
+
445
+ You can ask for several possible responses to a given problem, with a ranking and final answer selection.
446
+
447
+ Example prompt:
448
+
449
+ ```
450
+ 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.
451
+ ```
452
+
453
+ Example response:
454
+ ```
455
+ Solution 1:
456
+ 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).
457
+
458
+ 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:
459
+
460
+ n(n-1)/2 = 45
461
+
462
+ Solving this equation gives us n=10.
463
+
464
+ Final answer: There were 10 players in the tournament.
465
+
466
+ Solution 2:
467
+ 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.
468
+
469
+ 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.
470
+
471
+ Final answer: There were 10 players in the tournament.
472
+
473
+ Solution 3:
474
+ 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.
475
+
476
+ Final answer: There were 10 players in the tournament.
477
+
478
+ Ranking of solutions from best to worst:
479
+ 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.
480
+ 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.
481
+ 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.
482
+
483
+ Best and final answer: There were 10 players in the tournament.
484
+ ```
485
+
486
+ #### reWOO style execution planning
487
+
488
+ 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!
489
+
490
+ Example prompt:
491
+ ```
492
+ 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
493
+ that could be the user's question, one or more prior evidence values, or a combination of both.
494
+
495
+ Here are the tools available to be called:
496
+ 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.
497
+ 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.
498
+ HyperlinkExtractor[input]: Extract links from plain text and produces a plain text, newline delimited response of links.
499
+ 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:?
500
+
501
+ The output should be in format:
502
+ Plan: [first action to take based on input question]
503
+ :evidence0: = [function to call with input parameter]
504
+ Plan: [next action to take, based on result of :evidence0:]
505
+ :evidence1: = [next function to call and input parameter, which may include reference to previous evidence, e.g. "Given context :evidence0"]
506
+ ...
507
+ Answer: [:evidence[n]: containing the final answer.]
508
+
509
+ Question: Who won the Nobel Prize in Literature in 2020 and what is their most famous work?
510
+ ```
511
+
512
+ Response:
513
+ ```
514
+ Plan: Begin by conducting a web search to find out who won the Nobel Prize in Literature in 2020.
515
+ :evidence0: = DuckDuckGo[Nobel Prize in Literature 2020 winner]
516
+ Plan: Utilize the KnowledgeModel to interpret the search results and find the name of the laureate.
517
+ :evidence1: = KnowledgeModel[Who won the Nobel Prize in Literature in 2020, given :evidence0:?]
518
+ Plan: Conduct another web search to find the most famous work of the identified laureate.
519
+ :evidence2: = DuckDuckGo[Most famous work of :evidence1:]
520
+ Plan: Extract the relevant links from the DuckDuckGo search results for a more focused search.
521
+ :evidence3: = HyperlinkExtractor[:evidence2:]
522
+ Plan: Use the TextScraper tool to extract information from the relevant links.
523
+ :evidence4: = TextScraper[:evidence3:]
524
+ Plan: Finally, utilize the KnowledgeModel to identify and summarize the most famous work of the laureate from the extracted information.
525
+ :evidence5: = KnowledgeModel[What is the most famous work of :evidence1:, given :evidence4:?]
526
+ Answer: :evidence5:
527
+ ```
528
+
529
+ 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:
530
+
531
+ ```python
532
+ import re
533
+ import requests
534
+
535
+ def inject_context(input_text, **context):
536
+ for ref in set(re.findall(r"(:evidence[0-9]+:)", input_text, re.I)):
537
+ input_text = input_text.replace(ref, context.get(ref, ""))
538
+ return input_text
539
+
540
+ def duckduckgo(input_text, **context):
541
+ search_string = inject_context(input_text, **context)
542
+ ... search via duck duck go using search_string
543
+ ... return text content
544
+
545
+ def link_extractor(input_text, **context):
546
+ input_text = inject_context(input_text, **context)
547
+ return "\n".join(list(set(re.findall(r"(https?://[^\s]+?\.?)", input_text, re.I))))
548
+
549
+ def scrape(input_text, **context):
550
+ input_text = inject_context(input_text, **context)
551
+ text = []
552
+ for link in input_text.splitlines():
553
+ text.append(requests.get(link).text)
554
+ return "\n".join(text)
555
+
556
+ def infer(input_text, **context)
557
+ prompt = inject_context(input_text, **context)
558
+ ... call model with prompt, return output
559
+
560
+ def parse_plan(plan):
561
+ method_map = {
562
+ "DuckDuckGo": duckduckgo,
563
+ "HyperlinkExtractor": link_extractor,
564
+ "KnowledgeModel": infer,
565
+ "TextScraper": scrape,
566
+ }
567
+ context = {}
568
+ for line in plan.strip().splitlines():
569
+ if line.startswith("Plan:"):
570
+ print(line)
571
+ continue
572
+ parts = re.match("^(:evidence[0-9]+:)\s*=\s*([^\[]+])(\[.*\])\s$", line, re.I)
573
+ if not parts:
574
+ if line.startswith("Answer: "):
575
+ return context.get(line.split(" ")[-1].strip(), "Answer couldn't be generated...")
576
+ raise RuntimeError("bad format: " + line)
577
+ context[parts.group(1)] = method_map[parts.group(2)](parts.group(3), **context)
578
+ ```
579
+
580
+ ### Contribute
581
+
582
+ If you're interested in new functionality, particularly a new "instructor" type to generate a specific type of training data,
583
+ 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.
584
+
585
+ To help me with the OpenAI/compute costs:
586
+
587
+ - https://bmc.link/jondurbin
588
+ - ETH 0xce914eAFC2fe52FdceE59565Dd92c06f776fcb11
589
+ - BTC bc1qdwuth4vlg8x37ggntlxu5cjfwgmdy5zaa7pswf
590
+
591
+ ### Licence and usage restrictions
592
+
593
+ The airoboros 2.2 models are built on top of llama-2/codellama.
594
+
595
+ The llama-2 base model has a custom Meta license:
596
+ - See the [meta-license/LICENSE.txt](meta-license/LICENSE.txt) file attached for the original license provided by Meta.
597
+ - 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.
598
+
599
+ The fine-tuning data was mostly generated by OpenAI API calls to gpt-4, via [airoboros](https://github.com/jondurbin/airoboros)
600
+
601
+ The ToS for OpenAI API usage has a clause preventing the output from being used to train a model that __competes__ with OpenAI
602
+
603
+ - what does *compete* actually mean here?
604
+ - 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
605
+ - 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
606
+ - 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
607
+ - 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
608
+
609
+ 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.
610
+
611
+ Your best bet is probably to avoid using this commercially due to the OpenAI API usage.
612
+
613
+ Either way, by using this model, you agree to completely indemnify me.