TheBloke commited on
Commit
b1917a7
·
1 Parent(s): fb78a74

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +581 -0
README.md ADDED
@@ -0,0 +1,581 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: jondurbin/bagel-7b-v0.1
3
+ datasets:
4
+ - ai2_arc
5
+ - unalignment/spicy-3.1
6
+ - codeparrot/apps
7
+ - facebook/belebele
8
+ - boolq
9
+ - jondurbin/cinematika-v0.1
10
+ - drop
11
+ - lmsys/lmsys-chat-1m
12
+ - TIGER-Lab/MathInstruct
13
+ - cais/mmlu
14
+ - Muennighoff/natural-instructions
15
+ - openbookqa
16
+ - piqa
17
+ - Vezora/Tested-22k-Python-Alpaca
18
+ - cakiki/rosetta-code
19
+ - Open-Orca/SlimOrca
20
+ - spider
21
+ - squad_v2
22
+ - migtissera/Synthia-v1.3
23
+ - datasets/winogrande
24
+ inference: false
25
+ license: apache-2.0
26
+ model_creator: Jon Durbin
27
+ model_name: Bagel 7B v0.1
28
+ model_type: mistral
29
+ prompt_template: 'Below is an instruction that describes a task. Write a response
30
+ that appropriately completes the request.
31
+
32
+
33
+ ### Instruction:
34
+
35
+ {prompt}
36
+
37
+
38
+ ### Response:
39
+
40
+ '
41
+ quantized_by: TheBloke
42
+ ---
43
+ <!-- markdownlint-disable MD041 -->
44
+
45
+ <!-- header start -->
46
+ <!-- 200823 -->
47
+ <div style="width: auto; margin-left: auto; margin-right: auto">
48
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
49
+ </div>
50
+ <div style="display: flex; justify-content: space-between; width: 100%;">
51
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
52
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
53
+ </div>
54
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
55
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
56
+ </div>
57
+ </div>
58
+ <div style="text-align:center; margin-top: 0em; margin-bottom: 0em"><p style="margin-top: 0.25em; margin-bottom: 0em;">TheBloke's LLM work is generously supported by a grant from <a href="https://a16z.com">andreessen horowitz (a16z)</a></p></div>
59
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
60
+ <!-- header end -->
61
+
62
+ # Bagel 7B v0.1 - GGUF
63
+ - Model creator: [Jon Durbin](https://huggingface.co/jondurbin)
64
+ - Original model: [Bagel 7B v0.1](https://huggingface.co/jondurbin/bagel-7b-v0.1)
65
+
66
+ <!-- description start -->
67
+ ## Description
68
+
69
+ This repo contains GGUF format model files for [Jon Durbin's Bagel 7B v0.1](https://huggingface.co/jondurbin/bagel-7b-v0.1).
70
+
71
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
72
+
73
+ <!-- description end -->
74
+ <!-- README_GGUF.md-about-gguf start -->
75
+ ### About GGUF
76
+
77
+ GGUF is a new format introduced by the llama.cpp team on August 21st 2023. It is a replacement for GGML, which is no longer supported by llama.cpp.
78
+
79
+ Here is an incomplete list of clients and libraries that are known to support GGUF:
80
+
81
+ * [llama.cpp](https://github.com/ggerganov/llama.cpp). The source project for GGUF. Offers a CLI and a server option.
82
+ * [text-generation-webui](https://github.com/oobabooga/text-generation-webui), the most widely used web UI, with many features and powerful extensions. Supports GPU acceleration.
83
+ * [KoboldCpp](https://github.com/LostRuins/koboldcpp), a fully featured web UI, with GPU accel across all platforms and GPU architectures. Especially good for story telling.
84
+ * [GPT4All](https://gpt4all.io/index.html), a free and open source local running GUI, supporting Windows, Linux and macOS with full GPU accel.
85
+ * [LM Studio](https://lmstudio.ai/), an easy-to-use and powerful local GUI for Windows and macOS (Silicon), with GPU acceleration. Linux available, in beta as of 27/11/2023.
86
+ * [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui), a great web UI with many interesting and unique features, including a full model library for easy model selection.
87
+ * [Faraday.dev](https://faraday.dev/), an attractive and easy to use character-based chat GUI for Windows and macOS (both Silicon and Intel), with GPU acceleration.
88
+ * [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
89
+ * [candle](https://github.com/huggingface/candle), a Rust ML framework with a focus on performance, including GPU support, and ease of use.
90
+ * [ctransformers](https://github.com/marella/ctransformers), a Python library with GPU accel, LangChain support, and OpenAI-compatible AI server. Note, as of time of writing (November 27th 2023), ctransformers has not been updated in a long time and does not support many recent models.
91
+
92
+ <!-- README_GGUF.md-about-gguf end -->
93
+ <!-- repositories-available start -->
94
+ ## Repositories available
95
+
96
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/bagel-7B-v0.1-AWQ)
97
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/bagel-7B-v0.1-GPTQ)
98
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/bagel-7B-v0.1-GGUF)
99
+ * [Jon Durbin's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/jondurbin/bagel-7b-v0.1)
100
+ <!-- repositories-available end -->
101
+
102
+ <!-- prompt-template start -->
103
+ ## Prompt template: Alpaca
104
+
105
+ ```
106
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
107
+
108
+ ### Instruction:
109
+ {prompt}
110
+
111
+ ### Response:
112
+
113
+ ```
114
+
115
+ <!-- prompt-template end -->
116
+
117
+
118
+ <!-- compatibility_gguf start -->
119
+ ## Compatibility
120
+
121
+ These quantised GGUFv2 files are compatible with llama.cpp from August 27th onwards, as of commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221)
122
+
123
+ They are also compatible with many third party UIs and libraries - please see the list at the top of this README.
124
+
125
+ ## Explanation of quantisation methods
126
+
127
+ <details>
128
+ <summary>Click to see details</summary>
129
+
130
+ The new methods available are:
131
+
132
+ * 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)
133
+ * 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.
134
+ * 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.
135
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
136
+ * 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
137
+
138
+ Refer to the Provided Files table below to see what files use which methods, and how.
139
+ </details>
140
+ <!-- compatibility_gguf end -->
141
+
142
+ <!-- README_GGUF.md-provided-files start -->
143
+ ## Provided files
144
+
145
+ | Name | Quant method | Bits | Size | Max RAM required | Use case |
146
+ | ---- | ---- | ---- | ---- | ---- | ----- |
147
+ | [bagel-7b-v0.1.Q2_K.gguf](https://huggingface.co/TheBloke/bagel-7B-v0.1-GGUF/blob/main/bagel-7b-v0.1.Q2_K.gguf) | Q2_K | 2 | 3.08 GB| 5.58 GB | smallest, significant quality loss - not recommended for most purposes |
148
+ | [bagel-7b-v0.1.Q3_K_S.gguf](https://huggingface.co/TheBloke/bagel-7B-v0.1-GGUF/blob/main/bagel-7b-v0.1.Q3_K_S.gguf) | Q3_K_S | 3 | 3.16 GB| 5.66 GB | very small, high quality loss |
149
+ | [bagel-7b-v0.1.Q3_K_M.gguf](https://huggingface.co/TheBloke/bagel-7B-v0.1-GGUF/blob/main/bagel-7b-v0.1.Q3_K_M.gguf) | Q3_K_M | 3 | 3.52 GB| 6.02 GB | very small, high quality loss |
150
+ | [bagel-7b-v0.1.Q3_K_L.gguf](https://huggingface.co/TheBloke/bagel-7B-v0.1-GGUF/blob/main/bagel-7b-v0.1.Q3_K_L.gguf) | Q3_K_L | 3 | 3.82 GB| 6.32 GB | small, substantial quality loss |
151
+ | [bagel-7b-v0.1.Q4_0.gguf](https://huggingface.co/TheBloke/bagel-7B-v0.1-GGUF/blob/main/bagel-7b-v0.1.Q4_0.gguf) | Q4_0 | 4 | 4.11 GB| 6.61 GB | legacy; small, very high quality loss - prefer using Q3_K_M |
152
+ | [bagel-7b-v0.1.Q4_K_S.gguf](https://huggingface.co/TheBloke/bagel-7B-v0.1-GGUF/blob/main/bagel-7b-v0.1.Q4_K_S.gguf) | Q4_K_S | 4 | 4.14 GB| 6.64 GB | small, greater quality loss |
153
+ | [bagel-7b-v0.1.Q4_K_M.gguf](https://huggingface.co/TheBloke/bagel-7B-v0.1-GGUF/blob/main/bagel-7b-v0.1.Q4_K_M.gguf) | Q4_K_M | 4 | 4.37 GB| 6.87 GB | medium, balanced quality - recommended |
154
+ | [bagel-7b-v0.1.Q5_0.gguf](https://huggingface.co/TheBloke/bagel-7B-v0.1-GGUF/blob/main/bagel-7b-v0.1.Q5_0.gguf) | Q5_0 | 5 | 5.00 GB| 7.50 GB | legacy; medium, balanced quality - prefer using Q4_K_M |
155
+ | [bagel-7b-v0.1.Q5_K_S.gguf](https://huggingface.co/TheBloke/bagel-7B-v0.1-GGUF/blob/main/bagel-7b-v0.1.Q5_K_S.gguf) | Q5_K_S | 5 | 5.00 GB| 7.50 GB | large, low quality loss - recommended |
156
+ | [bagel-7b-v0.1.Q5_K_M.gguf](https://huggingface.co/TheBloke/bagel-7B-v0.1-GGUF/blob/main/bagel-7b-v0.1.Q5_K_M.gguf) | Q5_K_M | 5 | 5.13 GB| 7.63 GB | large, very low quality loss - recommended |
157
+ | [bagel-7b-v0.1.Q6_K.gguf](https://huggingface.co/TheBloke/bagel-7B-v0.1-GGUF/blob/main/bagel-7b-v0.1.Q6_K.gguf) | Q6_K | 6 | 5.94 GB| 8.44 GB | very large, extremely low quality loss |
158
+ | [bagel-7b-v0.1.Q8_0.gguf](https://huggingface.co/TheBloke/bagel-7B-v0.1-GGUF/blob/main/bagel-7b-v0.1.Q8_0.gguf) | Q8_0 | 8 | 7.70 GB| 10.20 GB | very large, extremely low quality loss - not recommended |
159
+
160
+ **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.
161
+
162
+
163
+
164
+ <!-- README_GGUF.md-provided-files end -->
165
+
166
+ <!-- README_GGUF.md-how-to-download start -->
167
+ ## How to download GGUF files
168
+
169
+ **Note for manual downloaders:** You almost never want to clone the entire repo! Multiple different quantisation formats are provided, and most users only want to pick and download a single file.
170
+
171
+ The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
172
+
173
+ * LM Studio
174
+ * LoLLMS Web UI
175
+ * Faraday.dev
176
+
177
+ ### In `text-generation-webui`
178
+
179
+ Under Download Model, you can enter the model repo: TheBloke/bagel-7B-v0.1-GGUF and below it, a specific filename to download, such as: bagel-7b-v0.1.Q4_K_M.gguf.
180
+
181
+ Then click Download.
182
+
183
+ ### On the command line, including multiple files at once
184
+
185
+ I recommend using the `huggingface-hub` Python library:
186
+
187
+ ```shell
188
+ pip3 install huggingface-hub
189
+ ```
190
+
191
+ Then you can download any individual model file to the current directory, at high speed, with a command like this:
192
+
193
+ ```shell
194
+ huggingface-cli download TheBloke/bagel-7B-v0.1-GGUF bagel-7b-v0.1.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
195
+ ```
196
+
197
+ <details>
198
+ <summary>More advanced huggingface-cli download usage (click to read)</summary>
199
+
200
+ You can also download multiple files at once with a pattern:
201
+
202
+ ```shell
203
+ huggingface-cli download TheBloke/bagel-7B-v0.1-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
204
+ ```
205
+
206
+ For more documentation on downloading with `huggingface-cli`, please see: [HF -> Hub Python Library -> Download files -> Download from the CLI](https://huggingface.co/docs/huggingface_hub/guides/download#download-from-the-cli).
207
+
208
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
209
+
210
+ ```shell
211
+ pip3 install hf_transfer
212
+ ```
213
+
214
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
215
+
216
+ ```shell
217
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/bagel-7B-v0.1-GGUF bagel-7b-v0.1.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
218
+ ```
219
+
220
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
221
+ </details>
222
+ <!-- README_GGUF.md-how-to-download end -->
223
+
224
+ <!-- README_GGUF.md-how-to-run start -->
225
+ ## Example `llama.cpp` command
226
+
227
+ Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
228
+
229
+ ```shell
230
+ ./main -ngl 35 -m bagel-7b-v0.1.Q4_K_M.gguf --color -c 32768 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\n{prompt}\n\n### Response:"
231
+ ```
232
+
233
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
234
+
235
+ Change `-c 32768` to the desired sequence length. For extended sequence models - eg 8K, 16K, 32K - the necessary RoPE scaling parameters are read from the GGUF file and set by llama.cpp automatically. Note that longer sequence lengths require much more resources, so you may need to reduce this value.
236
+
237
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
238
+
239
+ 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)
240
+
241
+ ## How to run in `text-generation-webui`
242
+
243
+ Further instructions can be found in the text-generation-webui documentation, here: [text-generation-webui/docs/04 ‐ Model Tab.md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/04%20%E2%80%90%20Model%20Tab.md#llamacpp).
244
+
245
+ ## How to run from Python code
246
+
247
+ You can use GGUF models from Python using the [llama-cpp-python](https://github.com/abetlen/llama-cpp-python) or [ctransformers](https://github.com/marella/ctransformers) libraries. Note that at the time of writing (Nov 27th 2023), ctransformers has not been updated for some time and is not compatible with some recent models. Therefore I recommend you use llama-cpp-python.
248
+
249
+ ### How to load this model in Python code, using llama-cpp-python
250
+
251
+ For full documentation, please see: [llama-cpp-python docs](https://abetlen.github.io/llama-cpp-python/).
252
+
253
+ #### First install the package
254
+
255
+ Run one of the following commands, according to your system:
256
+
257
+ ```shell
258
+ # Base ctransformers with no GPU acceleration
259
+ pip install llama-cpp-python
260
+ # With NVidia CUDA acceleration
261
+ CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
262
+ # Or with OpenBLAS acceleration
263
+ CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
264
+ # Or with CLBLast acceleration
265
+ CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
266
+ # Or with AMD ROCm GPU acceleration (Linux only)
267
+ CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
268
+ # Or with Metal GPU acceleration for macOS systems only
269
+ CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
270
+
271
+ # In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
272
+ $env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
273
+ pip install llama-cpp-python
274
+ ```
275
+
276
+ #### Simple llama-cpp-python example code
277
+
278
+ ```python
279
+ from llama_cpp import Llama
280
+
281
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
282
+ llm = Llama(
283
+ model_path="./bagel-7b-v0.1.Q4_K_M.gguf", # Download the model file first
284
+ n_ctx=32768, # The max sequence length to use - note that longer sequence lengths require much more resources
285
+ n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
286
+ n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
287
+ )
288
+
289
+ # Simple inference example
290
+ output = llm(
291
+ "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\n{prompt}\n\n### Response:", # Prompt
292
+ max_tokens=512, # Generate up to 512 tokens
293
+ stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
294
+ echo=True # Whether to echo the prompt
295
+ )
296
+
297
+ # Chat Completion API
298
+
299
+ llm = Llama(model_path="./bagel-7b-v0.1.Q4_K_M.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
300
+ llm.create_chat_completion(
301
+ messages = [
302
+ {"role": "system", "content": "You are a story writing assistant."},
303
+ {
304
+ "role": "user",
305
+ "content": "Write a story about llamas."
306
+ }
307
+ ]
308
+ )
309
+ ```
310
+
311
+ ## How to use with LangChain
312
+
313
+ Here are guides on using llama-cpp-python and ctransformers with LangChain:
314
+
315
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
316
+ * [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
317
+
318
+ <!-- README_GGUF.md-how-to-run end -->
319
+
320
+ <!-- footer start -->
321
+ <!-- 200823 -->
322
+ ## Discord
323
+
324
+ For further support, and discussions on these models and AI in general, join us at:
325
+
326
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
327
+
328
+ ## Thanks, and how to contribute
329
+
330
+ Thanks to the [chirper.ai](https://chirper.ai) team!
331
+
332
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
333
+
334
+ 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.
335
+
336
+ 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.
337
+
338
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
339
+
340
+ * Patreon: https://patreon.com/TheBlokeAI
341
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
342
+
343
+ **Special thanks to**: Aemon Algiz.
344
+
345
+ **Patreon special mentions**: Michael Levine, 阿明, Trailburnt, Nikolai Manek, John Detwiler, Randy H, Will Dee, Sebastain Graf, NimbleBox.ai, Eugene Pentland, Emad Mostaque, Ai Maven, Jim Angel, Jeff Scroggin, Michael Davis, Manuel Alberto Morcote, Stephen Murray, Robert, Justin Joy, Luke @flexchar, Brandon Frisco, Elijah Stavena, S_X, Dan Guido, Undi ., Komninos Chatzipapas, Shadi, theTransient, Lone Striker, Raven Klaugh, jjj, Cap'n Zoog, Michel-Marie MAUDET (LINAGORA), Matthew Berman, David, Fen Risland, Omer Bin Jawed, Luke Pendergrass, Kalila, OG, Erik Bjäreholt, Rooh Singh, Joseph William Delisle, Dan Lewis, TL, John Villwock, AzureBlack, Brad, Pedro Madruga, Caitlyn Gatomon, K, jinyuan sun, Mano Prime, Alex, Jeffrey Morgan, Alicia Loh, Illia Dulskyi, Chadd, transmissions 11, fincy, Rainer Wilmers, ReadyPlayerEmma, knownsqashed, Mandus, biorpg, Deo Leter, Brandon Phillips, SuperWojo, Sean Connelly, Iucharbius, Jack West, Harry Royden McLaughlin, Nicholas, terasurfer, Vitor Caleffi, Duane Dunston, Johann-Peter Hartmann, David Ziegler, Olakabola, Ken Nordquist, Trenton Dambrowitz, Tom X Nguyen, Vadim, Ajan Kanaga, Leonard Tan, Clay Pascal, Alexandros Triantafyllidis, JM33133, Xule, vamX, ya boyyy, subjectnull, Talal Aujan, Alps Aficionado, wassieverse, Ari Malik, James Bentley, Woland, Spencer Kim, Michael Dempsey, Fred von Graf, Elle, zynix, William Richards, Stanislav Ovsiannikov, Edmond Seymore, Jonathan Leane, Martin Kemka, usrbinkat, Enrico Ros
346
+
347
+
348
+ Thank you to all my generous patrons and donaters!
349
+
350
+ And thank you again to a16z for their generous grant.
351
+
352
+ <!-- footer end -->
353
+
354
+ <!-- original-model-card start -->
355
+ # Original model card: Jon Durbin's Bagel 7B v0.1
356
+
357
+
358
+ # A bagel, with everything (except DPO)
359
+
360
+ ![bagel](bagel.png)
361
+
362
+ ## Overview
363
+
364
+ This is the pre-DPO version of the mistral-7b model fine-tuned with https://github.com/jondurbin/bagel
365
+
366
+ You probably want the higher performing model that underwent DPO: https://huggingface.co/jondurbin/bagel-dpo-7b-v0.1
367
+
368
+ The only benefit to this model is that it is less "truthful", for roleplaying and other types of scenarios that may benefit more from the SFT-only tune.
369
+
370
+ ## Data selection.
371
+
372
+ The first step in the process is creating a dataset.
373
+ In this case, we're actually creating a composite dataset, consisting of both supervised fine-tuning data (SFT) and direct preference optimization (DPO) data.
374
+
375
+ All instruction data, that is, data that is not plain text (like project Gutenberg and items from Cinematika) or DPO, is converted into ShareGPT format so it's easier to work with.
376
+
377
+ See the corresponding code in `bagel/data_sources/*.py` in the repo linked above for full implementation for each data source.
378
+
379
+ Deduplication is done by creating a uuid v5 of the instruction/text, then only adding items not previously seen (where datasets are loaded in order of the confidence score I assign them).
380
+ This means that if an instruction is in data source "Foo" with confidence 4 as well as in data source "Bar" with confidence score 2, only the entry from "Foo" will be taken.
381
+
382
+ ### SFT data sources
383
+
384
+ *Yes, you will see benchmark names in the list, but this only uses the train splits, and a decontamination by cosine similarity is performed at the end as a sanity check*
385
+
386
+ - [ai2_arc](https://huggingface.co/datasets/ai2_arc)
387
+ - Abstraction and reasoning dataset, useful in measuring "intelligence" to a certain extent.
388
+ - [airoboros](https://huggingface.co/datasets/unalignment/spicy-3.1)
389
+ - Variety of categories of synthetic instructions generated by gpt-4.
390
+ - [apps](https://huggingface.co/datasets/codeparrot/apps)
391
+ - Python coding dataset with 10k problems.
392
+ - [belebele](https://huggingface.co/datasets/facebook/belebele)
393
+ - Multi-lingual reading comprehension dataset.
394
+ - [boolq](https://huggingface.co/datasets/boolq)
395
+ - Corpus of yes/no questions (which can be surprisingly difficult for AI to answer apparently?)
396
+ - [cinematika](https://huggingface.co/datasets/jondurbin/cinematika-v0.1) (instruction and plain text)
397
+ - RP-style data synthesized from movie scripts so the model isn't quite as boring as it otherwise would be.
398
+ - [drop](https://huggingface.co/datasets/drop)
399
+ - More reading comprehension.
400
+ - [gutenberg](https://www.gutenberg.org/) (plain text)
401
+ - Books/plain text, again to make the model less boring, only a handful of examples supported by [chapterize](https://github.com/JonathanReeve/chapterize)
402
+ - [lmsys_chat_1m](https://huggingface.co/datasets/lmsys/lmsys-chat-1m) (only gpt-4 items, also used for DPO)
403
+ - Chats collected by the lmsys chat arena, containing a wide variety of chats with various models.
404
+ - [mathinstruct](https://huggingface.co/datasets/TIGER-Lab/MathInstruct)
405
+ - Composite dataset with a variety of math-related tasks and problem/question formats.
406
+ - [mmlu](https://huggingface.co/datasets/cais/mmlu)
407
+ - Massive Multitask Language Understanding - a wide variety of questions about various subject matters.
408
+ - [natural_instructions](https://huggingface.co/datasets/Muennighoff/natural-instructions)
409
+ - Millions of instructions from 1600+ task categories (sampled down substantially, stratified by task type)
410
+ - [openbookqa](https://huggingface.co/datasets/openbookqa)
411
+ - Question answering dataset.
412
+ - [piqa](https://huggingface.co/datasets/piqa)
413
+ - Phyiscal interaction question answering.
414
+ - [python_alpaca](https://huggingface.co/datasets/Vezora/Tested-22k-Python-Alpaca)
415
+ - Python instruction response pairs, validated as functional.
416
+ - [rosetta_code](https://huggingface.co/datasets/cakiki/rosetta-code)
417
+ - Code problems and solutions in a variety of programming languages taken from rosettacode.org.
418
+ - [slimorca](https://huggingface.co/datasets/Open-Orca/SlimOrca)
419
+ - Collection of ~500k gpt-4 verified chats from OpenOrca.
420
+ - [spider](https://huggingface.co/datasets/spider)
421
+ - SQL-targeted dataset.
422
+ - [squad_v2](https://huggingface.co/datasets/squad_v2)
423
+ - Contextual question answering (RAG).
424
+ - [synthia](https://huggingface.co/datasets/migtissera/Synthia-v1.3)
425
+ - GPT-4 generated data using advanced prompting from Migel Tissera.
426
+ - [winogrande](https://huggingface.co/datasets/winogrande)
427
+ - Fill in the blank style prompts.
428
+
429
+ Only the train splits were used (if a split was provided), and an additional pass of decontamination is performed using approximate nearest neighbor search (via faiss).
430
+
431
+ ## Prompt formatting
432
+
433
+ In sticking with the theme of the bagel, I didn't want to use a single prompt format, so I used 4 - vicuna, llama-2, alpaca, and chat-ml (sorta).
434
+ I also didn't want to randomly select a single prompt format for each item (hoping each instruction would generalize more when used in a variety of prompt formats), so each instruction is actually converted into every prompt format.
435
+
436
+ This means each epoch of our fine-tune is really basically 4 epochs. So, for the fine-tunes, I would recommend only doing 1 epoch (or 0.75 epochs). I am testing with a single epoch using a relatively low learning rate.
437
+
438
+ ### Alpaca (sort of)
439
+
440
+ ```
441
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
442
+
443
+ ### Instruction:
444
+ {system prompt, if provided}
445
+ {instruction}
446
+
447
+ ### Response:
448
+ ```
449
+
450
+ The main difference here is that because of the dataset formatting and variety of data sources, it would have been much to tedious to add an `### Input:` block, so the inputs are just in the instruction section.
451
+
452
+ ### Vicuna
453
+
454
+ ```
455
+ {system prompt, if provided, randomly defaulting to "A chat between a user and an unbiased, uncensored assistant."}
456
+ USER: {instruction}
457
+ ASSISTANT:
458
+ ```
459
+
460
+ ### ChatML (sort of)
461
+
462
+ I don't really understand the point of having special tokens for `<|im_start|>` and `<|im_end|>`, because in practice they just act as BOS and EOS tokens (but, please correct me if I'm wrong).
463
+
464
+ So, instead of:
465
+ ```text
466
+ {bos}<|im_start|>{role}
467
+ {text}
468
+ <|im_end|>{eos}
469
+ ```
470
+
471
+ I just changed it to:
472
+ ```text
473
+ {bos}{role}
474
+ {text}
475
+ {eos}
476
+ ```
477
+
478
+ In practice, this would mean tokenization code like such:
479
+ ```python
480
+ tokenizer = AutoTokenizer.from_pretrained('mistralai/mistral-7b-v0.1')
481
+
482
+ input_str = f"""system
483
+ You are a goat.
484
+ {tokenizer.eos_token}
485
+ {tokenizer.bos_token}user
486
+ Tell me how to fry an egg.
487
+ {tokenizer.eos_token}
488
+ {tokenizer.bos_token}assistant
489
+ """
490
+
491
+ inputs = tokenizer(input_str, return_tensors="pt")
492
+ ```
493
+
494
+ If you *really* want to use `<|im_start|>` and `<|im_end|>`, just update your `tokenizer_config.json` to use `<|im_start|>` instead of `<s>` and `<|im_end|>` instead of `</s>` and when tokenizing. And if you still don't like what I've done to this chat-ml-ish format, feel free to cry into your pillow or fork the code and do a new fine-tune.
495
+
496
+ ### Llama-2 chat
497
+
498
+ ```
499
+ [INST] <<SYS>>
500
+ {system}
501
+ <</SYS>>
502
+
503
+ {instruction} [/INST]
504
+ ```
505
+
506
+ ### Fine-tune
507
+
508
+ *Note: I actually used my fork of [qlora](https://github.com/jondurbin/qlora)'s `train.py` for this, but I'm porting it to a minified version here, not tested yet!*
509
+
510
+ *More notes: I stopped the fine-tune around 50% because of budget constraints - it's a lot of data...*
511
+
512
+ ```bash
513
+ export BASE_DIR=/workspace
514
+ export WANDB_API_KEY=[redacted]
515
+ export WANDB_PROJECT=bagel-7b-v0.1
516
+
517
+ # Run the pretraining.
518
+ accelerate launch bagel/tune/sft.py \
519
+ --model_name_or_path $BASE_DIR/mistral-7b \
520
+ --final_output_dir $BASE_DIR/$WANDB_PROJECT \
521
+ --output_dir $BASE_DIR/$WANDB_PROJECT-workdir \
522
+ --num_train_epochs 1 \
523
+ --logging_steps 1 \
524
+ --save_strategy steps \
525
+ --save_steps 200 \
526
+ --save_total_limit 5 \
527
+ --data_seed 42 \
528
+ --evaluation_strategy steps \
529
+ --eval_dataset_size 0.0006 \
530
+ --eval_steps 200 \
531
+ --max_new_tokens 4096 \
532
+ --dataloader_num_workers 3 \
533
+ --logging_strategy steps \
534
+ --remove_unused_columns False \
535
+ --do_train \
536
+ --full_finetune \
537
+ --bf16 \
538
+ --bits 16 \
539
+ --optim adamw_torch \
540
+ --lr_scheduler_type linear \
541
+ --dataset $BASE_DIR/bagel/bagel-input-output-v0.1.parquet \
542
+ --dataset_format input-output \
543
+ --model_max_len 4096 \
544
+ --per_device_train_batch_size 8 \
545
+ --learning_rate 3.5e-7 \
546
+ --warmup_ratio 0.005 \
547
+ --adam_beta2 0.999 \
548
+ --max_grad_norm 0.3 \
549
+ --weight_decay 0.001 \
550
+ --seed 42 \
551
+ --report_to wandb \
552
+ --gradient_checkpointing True \
553
+ --gradient_accumulation_steps 4 \
554
+ --skip_excess_length False \
555
+ --ddp_find_unused_parameters False \
556
+ --use_flash_attention_2 \
557
+ --deepspeed deepspeed.json
558
+ ```
559
+
560
+ Deepspeed configuration:
561
+ ```json
562
+ {
563
+ "gradient_accumulation_steps": "auto",
564
+ "gradient_clipping": "auto",
565
+ "train_batch_size": "auto",
566
+ "train_micro_batch_size_per_gpu": "auto",
567
+ "bf16": {
568
+ "enabled": true
569
+ },
570
+ "zero_optimization": {
571
+ "stage": 2,
572
+ "contiguous_gradients": true,
573
+ "overlap_comm": true,
574
+ "reduce_scatter": true,
575
+ "reduce_bucket_size": 5e8,
576
+ "allgather_bucket_size": 5e8
577
+ }
578
+ }
579
+ ```
580
+
581
+ <!-- original-model-card end -->