Transformers
llama
TheBloke commited on
Commit
75755df
1 Parent(s): ced731c

Initial GGML model commit

Browse files
Files changed (1) hide show
  1. README.md +506 -0
README.md ADDED
@@ -0,0 +1,506 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - jondurbin/airoboros-2.1
4
+ inference: false
5
+ license: other
6
+ model_creator: Jon Durbin
7
+ model_link: https://huggingface.co/jondurbin/airoboros-33b-2.1
8
+ model_name: Airoboros 33B 2.1
9
+ model_type: llama
10
+ quantized_by: TheBloke
11
+ ---
12
+
13
+ <!-- header start -->
14
+ <!-- 200823 -->
15
+ <div style="width: auto; margin-left: auto; margin-right: auto">
16
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
17
+ </div>
18
+ <div style="display: flex; justify-content: space-between; width: 100%;">
19
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
20
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
21
+ </div>
22
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
23
+ <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>
24
+ </div>
25
+ </div>
26
+ <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>
27
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
28
+ <!-- header end -->
29
+
30
+ # Airoboros 33B 2.1 - GGML
31
+ - Model creator: [Jon Durbin](https://huggingface.co/jondurbin)
32
+ - Original model: [Airoboros 33B 2.1](https://huggingface.co/jondurbin/airoboros-33b-2.1)
33
+
34
+ ## Description
35
+
36
+ This repo contains GGML format model files for [Jon Durbin's Airoboros 33B 2.1](https://huggingface.co/jondurbin/airoboros-33b-2.1).
37
+
38
+ ### Important note regarding GGML files.
39
+
40
+ The GGML format has now been superseded by GGUF. As of August 21st 2023, [llama.cpp](https://github.com/ggerganov/llama.cpp) no longer supports GGML models. Third party clients and libraries are expected to still support it for a time, but many may also drop support.
41
+
42
+ Please use the GGUF models instead.
43
+ ### About GGML
44
+
45
+ GGML files are for CPU + GPU inference using [llama.cpp](https://github.com/ggerganov/llama.cpp) and libraries and UIs which support this format, such as:
46
+ * [text-generation-webui](https://github.com/oobabooga/text-generation-webui), the most popular web UI. Supports NVidia CUDA GPU acceleration.
47
+ * [KoboldCpp](https://github.com/LostRuins/koboldcpp), a powerful GGML web UI with GPU acceleration on all platforms (CUDA and OpenCL). Especially good for story telling.
48
+ * [LM Studio](https://lmstudio.ai/), a fully featured local GUI with GPU acceleration on both Windows (NVidia and AMD), and macOS.
49
+ * [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui), a great web UI with CUDA GPU acceleration via the c_transformers backend.
50
+ * [ctransformers](https://github.com/marella/ctransformers), a Python library with GPU accel, LangChain support, and OpenAI-compatible AI server.
51
+ * [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
52
+
53
+ ## Repositories available
54
+
55
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GPTQ)
56
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGUF)
57
+ * [2, 3, 4, 5, 6 and 8-bit GGML models for CPU+GPU inference (deprecated)](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGML)
58
+ * [Jon Durbin's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/jondurbin/airoboros-33b-2.1)
59
+
60
+ ## Prompt template: Chat
61
+
62
+ ```
63
+ A chat.
64
+ USER: {prompt}
65
+ ASSISTANT:
66
+
67
+ ```
68
+
69
+ <!-- compatibility_ggml start -->
70
+ ## Compatibility
71
+
72
+ These quantised GGML files are compatible with llama.cpp between June 6th (commit `2d43387`) and August 21st 2023.
73
+
74
+ For support with latest llama.cpp, please use GGUF files instead.
75
+
76
+ The final llama.cpp commit with support for GGML was: [dadbed99e65252d79f81101a392d0d6497b86caa](https://github.com/ggerganov/llama.cpp/commit/dadbed99e65252d79f81101a392d0d6497b86caa)
77
+
78
+ As of August 23rd 2023 they are still compatible with all UIs, libraries and utilities which use GGML. This may change in the future.
79
+
80
+ ## Explanation of the new k-quant methods
81
+ <details>
82
+ <summary>Click to see details</summary>
83
+
84
+ The new methods available are:
85
+ * GGML_TYPE_Q2_K - "type-1" 2-bit quantization in super-blocks containing 16 blocks, each block having 16 weight. Block scales and mins are quantized with 4 bits. This ends up effectively using 2.5625 bits per weight (bpw)
86
+ * GGML_TYPE_Q3_K - "type-0" 3-bit quantization in super-blocks containing 16 blocks, each block having 16 weights. Scales are quantized with 6 bits. This end up using 3.4375 bpw.
87
+ * GGML_TYPE_Q4_K - "type-1" 4-bit quantization in super-blocks containing 8 blocks, each block having 32 weights. Scales and mins are quantized with 6 bits. This ends up using 4.5 bpw.
88
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
89
+ * GGML_TYPE_Q6_K - "type-0" 6-bit quantization. Super-blocks with 16 blocks, each block having 16 weights. Scales are quantized with 8 bits. This ends up using 6.5625 bpw
90
+ * GGML_TYPE_Q8_K - "type-0" 8-bit quantization. Only used for quantizing intermediate results. The difference to the existing Q8_0 is that the block size is 256. All 2-6 bit dot products are implemented for this quantization type.
91
+
92
+ Refer to the Provided Files table below to see what files use which methods, and how.
93
+ </details>
94
+ <!-- compatibility_ggml end -->
95
+
96
+ ## Provided files
97
+
98
+ | Name | Quant method | Bits | Size | Max RAM required | Use case |
99
+ | ---- | ---- | ---- | ---- | ---- | ----- |
100
+ | [airoboros-33b-2.1.ggmlv3.Q2_K.bin](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGML/blob/main/airoboros-33b-2.1.ggmlv3.Q2_K.bin) | Q2_K | 2 | 13.71 GB| 16.21 GB | New k-quant method. Uses GGML_TYPE_Q4_K for the attention.vw and feed_forward.w2 tensors, GGML_TYPE_Q2_K for the other tensors. |
101
+ | [airoboros-33b-2.1.ggmlv3.Q3_K_S.bin](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGML/blob/main/airoboros-33b-2.1.ggmlv3.Q3_K_S.bin) | Q3_K_S | 3 | 14.06 GB| 16.56 GB | New k-quant method. Uses GGML_TYPE_Q3_K for all tensors |
102
+ | [airoboros-33b-2.1.ggmlv3.Q3_K_M.bin](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGML/blob/main/airoboros-33b-2.1.ggmlv3.Q3_K_M.bin) | Q3_K_M | 3 | 15.72 GB| 18.22 GB | New k-quant method. Uses GGML_TYPE_Q4_K for the attention.wv, attention.wo, and feed_forward.w2 tensors, else GGML_TYPE_Q3_K |
103
+ | [airoboros-33b-2.1.ggmlv3.Q3_K_L.bin](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGML/blob/main/airoboros-33b-2.1.ggmlv3.Q3_K_L.bin) | Q3_K_L | 3 | 17.28 GB| 19.78 GB | New k-quant method. Uses GGML_TYPE_Q5_K for the attention.wv, attention.wo, and feed_forward.w2 tensors, else GGML_TYPE_Q3_K |
104
+ | [airoboros-33b-2.1.ggmlv3.Q4_0.bin](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGML/blob/main/airoboros-33b-2.1.ggmlv3.Q4_0.bin) | Q4_0 | 4 | 18.36 GB| 20.86 GB | Original quant method, 4-bit. |
105
+ | [airoboros-33b-2.1.ggmlv3.Q4_K_S.bin](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGML/blob/main/airoboros-33b-2.1.ggmlv3.Q4_K_S.bin) | Q4_K_S | 4 | 18.36 GB| 20.86 GB | New k-quant method. Uses GGML_TYPE_Q4_K for all tensors |
106
+ | [airoboros-33b-2.1.ggmlv3.Q4_K_M.bin](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGML/blob/main/airoboros-33b-2.1.ggmlv3.Q4_K_M.bin) | Q4_K_M | 4 | 19.62 GB| 22.12 GB | New k-quant method. Uses GGML_TYPE_Q6_K for half of the attention.wv and feed_forward.w2 tensors, else GGML_TYPE_Q4_K |
107
+ | [airoboros-33b-2.1.ggmlv3.Q4_1.bin](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGML/blob/main/airoboros-33b-2.1.ggmlv3.Q4_1.bin) | Q4_1 | 4 | 20.38 GB| 22.88 GB | Original quant method, 4-bit. Higher accuracy than q4_0 but not as high as q5_0. However has quicker inference than q5 models. |
108
+ | [airoboros-33b-2.1.ggmlv3.Q5_0.bin](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGML/blob/main/airoboros-33b-2.1.ggmlv3.Q5_0.bin) | Q5_0 | 5 | 22.40 GB| 24.90 GB | Original quant method, 5-bit. Higher accuracy, higher resource usage and slower inference. |
109
+ | [airoboros-33b-2.1.ggmlv3.Q5_K_S.bin](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGML/blob/main/airoboros-33b-2.1.ggmlv3.Q5_K_S.bin) | Q5_K_S | 5 | 22.40 GB| 24.90 GB | New k-quant method. Uses GGML_TYPE_Q5_K for all tensors |
110
+ | [airoboros-33b-2.1.ggmlv3.Q5_K_M.bin](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGML/blob/main/airoboros-33b-2.1.ggmlv3.Q5_K_M.bin) | Q5_K_M | 5 | 23.05 GB| 25.55 GB | New k-quant method. Uses GGML_TYPE_Q6_K for half of the attention.wv and feed_forward.w2 tensors, else GGML_TYPE_Q5_K |
111
+ | [airoboros-33b-2.1.ggmlv3.Q5_1.bin](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGML/blob/main/airoboros-33b-2.1.ggmlv3.Q5_1.bin) | Q5_1 | 5 | 24.41 GB| 26.91 GB | Original quant method, 5-bit. Even higher accuracy, resource usage and slower inference. |
112
+ | [airoboros-33b-2.1.ggmlv3.Q6_K.bin](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGML/blob/main/airoboros-33b-2.1.ggmlv3.Q6_K.bin) | Q6_K | 6 | 26.69 GB| 29.19 GB | New k-quant method. Uses GGML_TYPE_Q8_K for all tensors - 6-bit quantization |
113
+ | [airoboros-33b-2.1.ggmlv3.Q8_0.bin](https://huggingface.co/TheBloke/Airoboros-33B-2.1-GGML/blob/main/airoboros-33b-2.1.ggmlv3.Q8_0.bin) | Q8_0 | 8 | 34.51 GB| 37.01 GB | Original quant method, 8-bit. Almost indistinguishable from float16. High resource use and slow. Not recommended for most users. |
114
+
115
+ **Note**: the above RAM figures assume no GPU offloading. If layers are offloaded to the GPU, this will reduce RAM usage and use VRAM instead.
116
+
117
+ ## How to run in `llama.cpp`
118
+
119
+ Make sure you are using `llama.cpp` from commit [dadbed99e65252d79f81101a392d0d6497b86caa](https://github.com/ggerganov/llama.cpp/commit/dadbed99e65252d79f81101a392d0d6497b86caa) or earlier.
120
+
121
+ For compatibility with latest llama.cpp, please use GGUF files instead.
122
+
123
+ ```
124
+ ./main -t 10 -ngl 32 -m airoboros-33b-2.1.ggmlv3.q4_K_M.bin --color -c 2048 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "A chat.\nUSER: Write a story about llamas\nASSISTANT:"
125
+ ```
126
+ Change `-t 10` to the number of physical CPU cores you have. For example if your system has 8 cores/16 threads, use `-t 8`.
127
+
128
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
129
+
130
+ Change `-c 2048` to the desired sequence length for this model. For example, `-c 4096` for a Llama 2 model. For models that use RoPE, add `--rope-freq-base 10000 --rope-freq-scale 0.5` for doubled context, or `--rope-freq-base 10000 --rope-freq-scale 0.25` for 4x context.
131
+
132
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
133
+
134
+ For other parameters and how to use them, please refer to [the llama.cpp documentation](https://github.com/ggerganov/llama.cpp/blob/master/examples/main/README.md)
135
+
136
+ ## How to run in `text-generation-webui`
137
+
138
+ Further instructions here: [text-generation-webui/docs/llama.cpp.md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/llama.cpp.md).
139
+
140
+ <!-- footer start -->
141
+ <!-- 200823 -->
142
+ ## Discord
143
+
144
+ For further support, and discussions on these models and AI in general, join us at:
145
+
146
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
147
+
148
+ ## Thanks, and how to contribute.
149
+
150
+ Thanks to the [chirper.ai](https://chirper.ai) team!
151
+
152
+ 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.
153
+
154
+ 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.
155
+
156
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
157
+
158
+ * Patreon: https://patreon.com/TheBlokeAI
159
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
160
+
161
+ **Special thanks to**: Aemon Algiz.
162
+
163
+ **Patreon special mentions**: Kacper Wikieł, knownsqashed, Leonard Tan, Asp the Wyvern, Daniel P. Andersen, Luke Pendergrass, Stanislav Ovsiannikov, RoA, Dave, Ai Maven, Kalila, Will Dee, Imad Khwaja, Nitin Borwankar, Joseph William Delisle, Tony Hughes, Cory Kujawski, Rishabh Srivastava, Russ Johnson, Stephen Murray, Lone Striker, Johann-Peter Hartmann, Elle, J, Deep Realms, SuperWojo, Raven Klaugh, Sebastain Graf, ReadyPlayerEmma, Alps Aficionado, Mano Prime, Derek Yates, Gabriel Puliatti, Mesiah Bishop, Magnesian, Sean Connelly, biorpg, Iucharbius, Olakabola, Fen Risland, Space Cruiser, theTransient, Illia Dulskyi, Thomas Belote, Spencer Kim, Pieter, John Detwiler, Fred von Graf, Michael Davis, Swaroop Kallakuri, subjectnull, Clay Pascal, Subspace Studios, Chris Smitley, Enrico Ros, usrbinkat, Steven Wood, alfie_i, David Ziegler, Willem Michiel, Matthew Berman, Andrey, Pyrater, Jeffrey Morgan, vamX, LangChain4j, Luke @flexchar, Trenton Dambrowitz, Pierre Kircher, Alex, Sam, James Bentley, Edmond Seymore, Eugene Pentland, Pedro Madruga, Rainer Wilmers, Dan Guido, Nathan LeClaire, Spiking Neurons AB, Talal Aujan, zynix, Artur Olbinski, Michael Levine, 阿明, K, John Villwock, Nikolai Manek, Femi Adebogun, senxiiz, Deo Leter, NimbleBox.ai, Viktor Bowallius, Geoffrey Montalvo, Mandus, Ajan Kanaga, ya boyyy, Jonathan Leane, webtim, Brandon Frisco, danny, Alexandros Triantafyllidis, Gabriel Tamborski, Randy H, terasurfer, Vadim, Junyu Yang, Vitor Caleffi, Chadd, transmissions 11
164
+
165
+
166
+ Thank you to all my generous patrons and donaters!
167
+
168
+ And thank you again to a16z for their generous grant.
169
+
170
+ <!-- footer end -->
171
+
172
+ # Original model card: Jon Durbin's Airoboros 33B 2.1
173
+
174
+
175
+ ### Overview
176
+
177
+ This is an instruction fine-tuned llama 30b model, using synthetic data generated by [airoboros](https://github.com/jondurbin/airoboros)
178
+
179
+ - Experimental RP style instruction set, with two categories: rp and gtkm
180
+ - rp includes multi-round chats, with emotes, between a varying number of characters, defined by cards
181
+ - gtkm is a way to test a simpler alternative to ghost attention - first, a character card is generated, then several questions are created to ask the model (as the character), using the character system prompt, then everything in synthesized into a dialog (one system prompt, all turns remain in character)
182
+ - Experimental support for longer, more detailed writing prompts, as well as next-chapter generation
183
+ - I used the new `cull-instructions` entrypoint in airoboros to shrink the m2.0 dataset to a smaller subset of high-quality instructions (according to gpt-4)
184
+ - The training data now also includes "stylized_response", in which 1500 sample instructions from various categories were re-generated using character cards as system prompts.
185
+ - this should allow better adherence to style/etc. specified in the system card
186
+ - Thousands of new generations, using some of the updates re: Flesch hints, etc., to get longer/higher quality writing outputs.
187
+ - A small "de-alignment" dataset was also added (not published) to remove some of the censorship in the base models.
188
+
189
+ I used rope scaling to increase context length to 4096, but there wasn't a huge amount of data in that range so YMMV. You may need to rename the directory to `airoboros-33b-2-1` (anything without the `.` really) so the trust_remote_code=True finds the module path properly.
190
+
191
+ *Why do I try to remove censorship?*
192
+
193
+ - laws vary widely based on time and location
194
+ - language model may conflate certain words with laws, e.g. it may think "stealing eggs from a chicken" is illegal
195
+ - these models just produce text, what you do with that text is your resonsibility
196
+ - many people and industries deal with "sensitive" content; imagine if a court stenographer's equipment filtered illegal content - it would be useless
197
+
198
+ Huge thank you to the folks over at [a16z](https://a16z.com/) for sponsoring the costs associated with building models and associated tools!
199
+
200
+ ### Prompt format
201
+
202
+ The training code was updated to randomize newline vs space:
203
+ https://github.com/jondurbin/qlora/blob/main/qlora.py#L559C1-L559C1
204
+
205
+
206
+ ```
207
+ A chat. USER: {prompt} ASSISTANT:
208
+ ```
209
+
210
+ or
211
+
212
+ ```
213
+ A chat.
214
+ USER: {prompt}
215
+ ASSISTANT:
216
+ ```
217
+
218
+ So in other words, it's the preamble/system prompt, followed by a single space or newline, then "USER: " (single space after colon) then the prompt (which can have multiple lines, spaces, whatever), then a single space or newline, followed by "ASSISTANT: " (with a single space after the colon).
219
+
220
+ __*I strongly suggest adding stopping criteria/early inference stopping on "USER:", because the training data includes many multi-round chats and could otherwise start simulating a conversation!*__
221
+
222
+ ### Helpful usage tips
223
+
224
+ *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.*
225
+
226
+ #### Context obedient question answering
227
+
228
+ 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.
229
+
230
+ The format for a closed-context prompt is as follows:
231
+ ```
232
+ BEGININPUT
233
+ BEGINCONTEXT
234
+ [key0: value0]
235
+ [key1: value1]
236
+ ... other metdata ...
237
+ ENDCONTEXT
238
+ [insert your text blocks here]
239
+ ENDINPUT
240
+ [add as many other blocks, in the exact same format]
241
+ BEGININSTRUCTION
242
+ [insert your instruction(s). The model was tuned with single questions, paragraph format, lists, etc.]
243
+ ENDINSTRUCTION
244
+ ```
245
+
246
+ 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.
247
+
248
+ *The __only__ prompts that need this closed context formating are closed-context instructions. Normal questions/instructions do not!*
249
+
250
+ 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.
251
+ - `BEGININPUT` - denotes a new input block
252
+ - `BEGINCONTEXT` - denotes the block of context (metadata key/value pairs) to associate with the current input block
253
+ - `ENDCONTEXT` - denotes the end of the metadata block for the current input
254
+ - [text] - Insert whatever text you want for the input block, as many paragraphs as can fit in the context.
255
+ - `ENDINPUT` - denotes the end of the current input block
256
+ - [repeat as many input blocks in this format as you want]
257
+ - `BEGININSTRUCTION` - denotes the start of the list (or one) instruction(s) to respond to for all of the input blocks above.
258
+ - [instruction(s)]
259
+ - `ENDINSTRUCTION` - denotes the end of instruction set
260
+
261
+ 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.
262
+
263
+ Here's a trivial, but important example to prove the point:
264
+ ```
265
+ BEGININPUT
266
+ BEGINCONTEXT
267
+ date: 2021-01-01
268
+ url: https://web.site/123
269
+ ENDCONTEXT
270
+ In a shocking turn of events, blueberries are now green, but will be sticking with the same name.
271
+ ENDINPUT
272
+ BEGININSTRUCTION
273
+ What color are bluberries? Source?
274
+ ENDINSTRUCTION
275
+ ```
276
+
277
+ And the response:
278
+ ```
279
+ Blueberries are now green.
280
+ Source:
281
+ date: 2021-01-01
282
+ url: https://web.site/123
283
+ ```
284
+
285
+ #### Coding
286
+
287
+ You can ask for fairly complex coding instructions with multiple criteria, e.g.:
288
+
289
+ ```
290
+ Create a python application with the following requirements:
291
+ - Asyncio FastAPI webserver
292
+ - ping endpoint that returns the current date in JSON format
293
+ - file upload endpoint, which calculates the file's sha256 checksum, and checks postgres to deduplicate
294
+ ```
295
+
296
+ Or inline criteria:
297
+
298
+ ```
299
+ 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.
300
+ ```
301
+
302
+ 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.:
303
+
304
+ ```
305
+ Write a websocket application in node.js. PLAINFORMAT
306
+ ```
307
+
308
+ #### Agent/function calling
309
+
310
+ 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.
311
+
312
+ Example prompt:
313
+ ```
314
+ 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.
315
+
316
+ Input: I want to know how many times 'Python' is mentioned in my text file.
317
+
318
+ Available functions:
319
+ file_analytics:
320
+ description: This tool performs various operations on a text file.
321
+ params:
322
+ action: The operation we want to perform on the data, such as "count_occurrences", "find_line", etc.
323
+ filters:
324
+ keyword: The word or phrase we want to search for.
325
+ ```
326
+
327
+ Response:
328
+ ```json
329
+ {
330
+ "function": "file_analytics",
331
+ "params": {
332
+ "action": "count_occurrences",
333
+ "filters": {
334
+ "keyword": "Python"
335
+ }
336
+ }
337
+ }
338
+ ```
339
+
340
+ #### Chain-of-thought
341
+
342
+ You can ask for several possible responses to a given problem, with a ranking and final answer selection.
343
+
344
+ Example prompt:
345
+
346
+ ```
347
+ 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.
348
+ ```
349
+
350
+ Example response:
351
+ ```
352
+ Solution 1:
353
+ 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).
354
+
355
+ 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:
356
+
357
+ n(n-1)/2 = 45
358
+
359
+ Solving this equation gives us n=10.
360
+
361
+ Final answer: There were 10 players in the tournament.
362
+
363
+ Solution 2:
364
+ 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.
365
+
366
+ 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.
367
+
368
+ Final answer: There were 10 players in the tournament.
369
+
370
+ Solution 3:
371
+ 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.
372
+
373
+ Final answer: There were 10 players in the tournament.
374
+
375
+ Ranking of solutions from best to worst:
376
+ 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.
377
+ 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.
378
+ 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.
379
+
380
+ Best and final answer: There were 10 players in the tournament.
381
+ ```
382
+
383
+ #### reWOO style execution planning
384
+
385
+ 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!
386
+
387
+ Example prompt:
388
+ ```
389
+ 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
390
+ that could be the user's question, one or more prior evidence values, or a combination of both.
391
+
392
+ Here are the tools available to be called:
393
+ 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.
394
+ 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.
395
+ HyperlinkExtractor[input]: Extract links from plain text and produces a plain text, newline delimited response of links.
396
+ 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:?
397
+
398
+ The output should be in format:
399
+ Plan: [first action to take based on input question]
400
+ :evidence0: = [function to call with input parameter]
401
+ Plan: [next action to take, based on result of :evidence0:]
402
+ :evidence1: = [next function to call and input parameter, which may include reference to previous evidence, e.g. "Given context :evidence0"]
403
+ ...
404
+ Answer: [:evidence[n]: containing the final answer.]
405
+
406
+ Question: Who won the Nobel Prize in Literature in 2020 and what is their most famous work?
407
+ ```
408
+
409
+ Response:
410
+ ```
411
+ Plan: Begin by conducting a web search to find out who won the Nobel Prize in Literature in 2020.
412
+ :evidence0: = DuckDuckGo[Nobel Prize in Literature 2020 winner]
413
+ Plan: Utilize the KnowledgeModel to interpret the search results and find the name of the laureate.
414
+ :evidence1: = KnowledgeModel[Who won the Nobel Prize in Literature in 2020, given :evidence0:?]
415
+ Plan: Conduct another web search to find the most famous work of the identified laureate.
416
+ :evidence2: = DuckDuckGo[Most famous work of :evidence1:]
417
+ Plan: Extract the relevant links from the DuckDuckGo search results for a more focused search.
418
+ :evidence3: = HyperlinkExtractor[:evidence2:]
419
+ Plan: Use the TextScraper tool to extract information from the relevant links.
420
+ :evidence4: = TextScraper[:evidence3:]
421
+ Plan: Finally, utilize the KnowledgeModel to identify and summarize the most famous work of the laureate from the extracted information.
422
+ :evidence5: = KnowledgeModel[What is the most famous work of :evidence1:, given :evidence4:?]
423
+ Answer: :evidence5:
424
+ ```
425
+
426
+ 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:
427
+
428
+ ```python
429
+ import re
430
+ import requests
431
+
432
+ def inject_context(input_text, **context):
433
+ for ref in set(re.findall(r"(:evidence[0-9]+:)", input_text, re.I)):
434
+ input_text = input_text.replace(ref, context.get(ref, ""))
435
+ return input_text
436
+
437
+ def duckduckgo(input_text, **context):
438
+ search_string = inject_context(input_text, **context)
439
+ ... search via duck duck go using search_string
440
+ ... return text content
441
+
442
+ def link_extractor(input_text, **context):
443
+ input_text = inject_context(input_text, **context)
444
+ return "\n".join(list(set(re.findall(r"(https?://[^\s]+?\.?)", input_text, re.I))))
445
+
446
+ def scrape(input_text, **context):
447
+ input_text = inject_context(input_text, **context)
448
+ text = []
449
+ for link in input_text.splitlines():
450
+ text.append(requests.get(link).text)
451
+ return "\n".join(text)
452
+
453
+ def infer(input_text, **context)
454
+ prompt = inject_context(input_text, **context)
455
+ ... call model with prompt, return output
456
+
457
+ def parse_plan(plan):
458
+ method_map = {
459
+ "DuckDuckGo": duckduckgo,
460
+ "HyperlinkExtractor": link_extractor,
461
+ "KnowledgeModel": infer,
462
+ "TextScraper": scrape,
463
+ }
464
+ context = {}
465
+ for line in plan.strip().splitlines():
466
+ if line.startswith("Plan:"):
467
+ print(line)
468
+ continue
469
+ parts = re.match("^(:evidence[0-9]+:)\s*=\s*([^\[]+])(\[.*\])\s$", line, re.I)
470
+ if not parts:
471
+ if line.startswith("Answer: "):
472
+ return context.get(line.split(" ")[-1].strip(), "Answer couldn't be generated...")
473
+ raise RuntimeError("bad format: " + line)
474
+ context[parts.group(1)] = method_map[parts.group(2)](parts.group(3), **context)
475
+ ```
476
+
477
+ ### Contribute
478
+
479
+ If you're interested in new functionality, particularly a new "instructor" type to generate a specific type of training data,
480
+ 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.
481
+
482
+ To help me with the OpenAI/compute costs:
483
+
484
+ - https://bmc.link/jondurbin
485
+ - ETH 0xce914eAFC2fe52FdceE59565Dd92c06f776fcb11
486
+ - BTC bc1qdwuth4vlg8x37ggntlxu5cjfwgmdy5zaa7pswf
487
+
488
+ ### Licence and usage restrictions
489
+
490
+ This model is built on top of the original llama-30b, which has a strict noncommercial license.
491
+
492
+ The fine-tuning data was generated by OpenAI API calls to gpt-4, via [airoboros](https://github.com/jondurbin/airoboros)
493
+
494
+ The ToS for OpenAI API usage has a clause preventing the output from being used to train a model that __competes__ with OpenAI
495
+
496
+ - what does *compete* actually mean here?
497
+ - 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
498
+ - 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
499
+ - 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
500
+ - 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
501
+
502
+ 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.
503
+
504
+ Your best bet is probably to avoid using this commercially due to the OpenAI API usage.
505
+
506
+ Either way, by using this model, you agree to completely indemnify me.