TheBloke commited on
Commit
3d790a2
1 Parent(s): cde70ec

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +415 -0
README.md ADDED
@@ -0,0 +1,415 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: MerlynMind/merlyn-education-corpus-qa-v2
3
+ inference: false
4
+ license: apache-2.0
5
+ model_creator: Merlyn Mind
6
+ model_name: Merlyn Education Corpus QA v2
7
+ model_type: llama
8
+ prompt_template: 'Instruction:\t{system_message}
9
+
10
+ Conversation:
11
+
12
+ ''user1'':\tuser message to analyse
13
+
14
+ ''user2'':\tuser message to analyse
15
+
16
+ Response:
17
+
18
+ '
19
+ quantized_by: TheBloke
20
+ tags:
21
+ - MerlynMind
22
+ - education
23
+ ---
24
+ <!-- markdownlint-disable MD041 -->
25
+
26
+ <!-- header start -->
27
+ <!-- 200823 -->
28
+ <div style="width: auto; margin-left: auto; margin-right: auto">
29
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
30
+ </div>
31
+ <div style="display: flex; justify-content: space-between; width: 100%;">
32
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
33
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
34
+ </div>
35
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
36
+ <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>
37
+ </div>
38
+ </div>
39
+ <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>
40
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
41
+ <!-- header end -->
42
+
43
+ # Merlyn Education Corpus QA v2 - GGUF
44
+ - Model creator: [Merlyn Mind](https://huggingface.co/MerlynMind)
45
+ - Original model: [Merlyn Education Corpus QA v2](https://huggingface.co/MerlynMind/merlyn-education-corpus-qa-v2)
46
+
47
+ <!-- description start -->
48
+ ## Description
49
+
50
+ This repo contains GGUF format model files for [Merlyn Mind's Merlyn Education Corpus QA v2](https://huggingface.co/MerlynMind/merlyn-education-corpus-qa-v2).
51
+
52
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
53
+
54
+ <!-- description end -->
55
+ <!-- README_GGUF.md-about-gguf start -->
56
+ ### About GGUF
57
+
58
+ 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.
59
+
60
+ Here is an incomplete list of clients and libraries that are known to support GGUF:
61
+
62
+ * [llama.cpp](https://github.com/ggerganov/llama.cpp). The source project for GGUF. Offers a CLI and a server option.
63
+ * [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.
64
+ * [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.
65
+ * [LM Studio](https://lmstudio.ai/), an easy-to-use and powerful local GUI for Windows and macOS (Silicon), with GPU acceleration.
66
+ * [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.
67
+ * [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.
68
+ * [ctransformers](https://github.com/marella/ctransformers), a Python library with GPU accel, LangChain support, and OpenAI-compatible AI server.
69
+ * [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
70
+ * [candle](https://github.com/huggingface/candle), a Rust ML framework with a focus on performance, including GPU support, and ease of use.
71
+
72
+ <!-- README_GGUF.md-about-gguf end -->
73
+ <!-- repositories-available start -->
74
+ ## Repositories available
75
+
76
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-AWQ)
77
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GPTQ)
78
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GGUF)
79
+ * [Merlyn Mind's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/MerlynMind/merlyn-education-corpus-qa-v2)
80
+ <!-- repositories-available end -->
81
+
82
+ <!-- prompt-template start -->
83
+ ## Prompt template: Merlyn-Education
84
+
85
+ ```
86
+ Instruction:\t{system_message}
87
+ Conversation:
88
+ 'user1':\tuser message to analyse
89
+ 'user2':\tuser message to analyse
90
+ Response:
91
+
92
+ ```
93
+
94
+ <!-- prompt-template end -->
95
+ <!-- licensing start -->
96
+ ## Licensing
97
+
98
+ The creator of the source model has listed its license as `apache-2.0`, and this quantization has therefore used that same license.
99
+
100
+ As this model is based on Llama 2, it is also subject to the Meta Llama 2 license terms, and the license files for that are additionally included. It should therefore be considered as being claimed to be licensed under both licenses. I contacted Hugging Face for clarification on dual licensing but they do not yet have an official position. Should this change, or should Meta provide any feedback on this situation, I will update this section accordingly.
101
+
102
+ In the meantime, any questions regarding licensing, and in particular how these two licenses might interact, should be directed to the original model repository: [Merlyn Mind's Merlyn Education Corpus QA v2](https://huggingface.co/MerlynMind/merlyn-education-corpus-qa-v2).
103
+ <!-- licensing end -->
104
+ <!-- compatibility_gguf start -->
105
+ ## Compatibility
106
+
107
+ 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)
108
+
109
+ They are also compatible with many third party UIs and libraries - please see the list at the top of this README.
110
+
111
+ ## Explanation of quantisation methods
112
+
113
+ <details>
114
+ <summary>Click to see details</summary>
115
+
116
+ The new methods available are:
117
+
118
+ * 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)
119
+ * 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.
120
+ * 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.
121
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
122
+ * 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
123
+
124
+ Refer to the Provided Files table below to see what files use which methods, and how.
125
+ </details>
126
+ <!-- compatibility_gguf end -->
127
+
128
+ <!-- README_GGUF.md-provided-files start -->
129
+ ## Provided files
130
+
131
+ | Name | Quant method | Bits | Size | Max RAM required | Use case |
132
+ | ---- | ---- | ---- | ---- | ---- | ----- |
133
+ | [merlyn-education-corpus-qa-v2.Q2_K.gguf](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GGUF/blob/main/merlyn-education-corpus-qa-v2.Q2_K.gguf) | Q2_K | 2 | 5.43 GB| 7.93 GB | smallest, significant quality loss - not recommended for most purposes |
134
+ | [merlyn-education-corpus-qa-v2.Q3_K_S.gguf](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GGUF/blob/main/merlyn-education-corpus-qa-v2.Q3_K_S.gguf) | Q3_K_S | 3 | 5.66 GB| 8.16 GB | very small, high quality loss |
135
+ | [merlyn-education-corpus-qa-v2.Q3_K_M.gguf](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GGUF/blob/main/merlyn-education-corpus-qa-v2.Q3_K_M.gguf) | Q3_K_M | 3 | 6.34 GB| 8.84 GB | very small, high quality loss |
136
+ | [merlyn-education-corpus-qa-v2.Q3_K_L.gguf](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GGUF/blob/main/merlyn-education-corpus-qa-v2.Q3_K_L.gguf) | Q3_K_L | 3 | 6.93 GB| 9.43 GB | small, substantial quality loss |
137
+ | [merlyn-education-corpus-qa-v2.Q4_0.gguf](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GGUF/blob/main/merlyn-education-corpus-qa-v2.Q4_0.gguf) | Q4_0 | 4 | 7.37 GB| 9.87 GB | legacy; small, very high quality loss - prefer using Q3_K_M |
138
+ | [merlyn-education-corpus-qa-v2.Q4_K_S.gguf](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GGUF/blob/main/merlyn-education-corpus-qa-v2.Q4_K_S.gguf) | Q4_K_S | 4 | 7.41 GB| 9.91 GB | small, greater quality loss |
139
+ | [merlyn-education-corpus-qa-v2.Q4_K_M.gguf](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GGUF/blob/main/merlyn-education-corpus-qa-v2.Q4_K_M.gguf) | Q4_K_M | 4 | 7.87 GB| 10.37 GB | medium, balanced quality - recommended |
140
+ | [merlyn-education-corpus-qa-v2.Q5_0.gguf](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GGUF/blob/main/merlyn-education-corpus-qa-v2.Q5_0.gguf) | Q5_0 | 5 | 8.97 GB| 11.47 GB | legacy; medium, balanced quality - prefer using Q4_K_M |
141
+ | [merlyn-education-corpus-qa-v2.Q5_K_S.gguf](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GGUF/blob/main/merlyn-education-corpus-qa-v2.Q5_K_S.gguf) | Q5_K_S | 5 | 8.97 GB| 11.47 GB | large, low quality loss - recommended |
142
+ | [merlyn-education-corpus-qa-v2.Q5_K_M.gguf](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GGUF/blob/main/merlyn-education-corpus-qa-v2.Q5_K_M.gguf) | Q5_K_M | 5 | 9.23 GB| 11.73 GB | large, very low quality loss - recommended |
143
+ | [merlyn-education-corpus-qa-v2.Q6_K.gguf](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GGUF/blob/main/merlyn-education-corpus-qa-v2.Q6_K.gguf) | Q6_K | 6 | 10.68 GB| 13.18 GB | very large, extremely low quality loss |
144
+ | [merlyn-education-corpus-qa-v2.Q8_0.gguf](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GGUF/blob/main/merlyn-education-corpus-qa-v2.Q8_0.gguf) | Q8_0 | 8 | 13.83 GB| 16.33 GB | very large, extremely low quality loss - not recommended |
145
+
146
+ **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.
147
+
148
+
149
+
150
+ <!-- README_GGUF.md-provided-files end -->
151
+
152
+ <!-- README_GGUF.md-how-to-download start -->
153
+ ## How to download GGUF files
154
+
155
+ **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.
156
+
157
+ The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
158
+
159
+ * LM Studio
160
+ * LoLLMS Web UI
161
+ * Faraday.dev
162
+
163
+ ### In `text-generation-webui`
164
+
165
+ Under Download Model, you can enter the model repo: TheBloke/merlyn-education-corpus-qa-v2-GGUF and below it, a specific filename to download, such as: merlyn-education-corpus-qa-v2.Q4_K_M.gguf.
166
+
167
+ Then click Download.
168
+
169
+ ### On the command line, including multiple files at once
170
+
171
+ I recommend using the `huggingface-hub` Python library:
172
+
173
+ ```shell
174
+ pip3 install huggingface-hub
175
+ ```
176
+
177
+ Then you can download any individual model file to the current directory, at high speed, with a command like this:
178
+
179
+ ```shell
180
+ huggingface-cli download TheBloke/merlyn-education-corpus-qa-v2-GGUF merlyn-education-corpus-qa-v2.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
181
+ ```
182
+
183
+ <details>
184
+ <summary>More advanced huggingface-cli download usage</summary>
185
+
186
+ You can also download multiple files at once with a pattern:
187
+
188
+ ```shell
189
+ huggingface-cli download TheBloke/merlyn-education-corpus-qa-v2-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
190
+ ```
191
+
192
+ 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).
193
+
194
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
195
+
196
+ ```shell
197
+ pip3 install hf_transfer
198
+ ```
199
+
200
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
201
+
202
+ ```shell
203
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/merlyn-education-corpus-qa-v2-GGUF merlyn-education-corpus-qa-v2.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
204
+ ```
205
+
206
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
207
+ </details>
208
+ <!-- README_GGUF.md-how-to-download end -->
209
+
210
+ <!-- README_GGUF.md-how-to-run start -->
211
+ ## Example `llama.cpp` command
212
+
213
+ Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
214
+
215
+ ```shell
216
+ ./main -ngl 32 -m merlyn-education-corpus-qa-v2.Q4_K_M.gguf --color -c 4096 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "Instruction:\t{system_message}\nConversation:\n'user1':\tuser message to analyse\n'user2':\tuser message to analyse\nResponse:"
217
+ ```
218
+
219
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
220
+
221
+ Change `-c 4096` 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.
222
+
223
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
224
+
225
+ 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)
226
+
227
+ ## How to run in `text-generation-webui`
228
+
229
+ 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).
230
+
231
+ ## How to run from Python code
232
+
233
+ 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.
234
+
235
+ ### How to load this model in Python code, using ctransformers
236
+
237
+ #### First install the package
238
+
239
+ Run one of the following commands, according to your system:
240
+
241
+ ```shell
242
+ # Base ctransformers with no GPU acceleration
243
+ pip install ctransformers
244
+ # Or with CUDA GPU acceleration
245
+ pip install ctransformers[cuda]
246
+ # Or with AMD ROCm GPU acceleration (Linux only)
247
+ CT_HIPBLAS=1 pip install ctransformers --no-binary ctransformers
248
+ # Or with Metal GPU acceleration for macOS systems only
249
+ CT_METAL=1 pip install ctransformers --no-binary ctransformers
250
+ ```
251
+
252
+ #### Simple ctransformers example code
253
+
254
+ ```python
255
+ from ctransformers import AutoModelForCausalLM
256
+
257
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
258
+ llm = AutoModelForCausalLM.from_pretrained("TheBloke/merlyn-education-corpus-qa-v2-GGUF", model_file="merlyn-education-corpus-qa-v2.Q4_K_M.gguf", model_type="llama", gpu_layers=50)
259
+
260
+ print(llm("AI is going to"))
261
+ ```
262
+
263
+ ## How to use with LangChain
264
+
265
+ Here are guides on using llama-cpp-python and ctransformers with LangChain:
266
+
267
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
268
+ * [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
269
+
270
+ <!-- README_GGUF.md-how-to-run end -->
271
+
272
+ <!-- footer start -->
273
+ <!-- 200823 -->
274
+ ## Discord
275
+
276
+ For further support, and discussions on these models and AI in general, join us at:
277
+
278
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
279
+
280
+ ## Thanks, and how to contribute
281
+
282
+ Thanks to the [chirper.ai](https://chirper.ai) team!
283
+
284
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
285
+
286
+ 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.
287
+
288
+ 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.
289
+
290
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
291
+
292
+ * Patreon: https://patreon.com/TheBlokeAI
293
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
294
+
295
+ **Special thanks to**: Aemon Algiz.
296
+
297
+ **Patreon special mentions**: Brandon Frisco, LangChain4j, Spiking Neurons AB, transmissions 11, Joseph William Delisle, Nitin Borwankar, Willem Michiel, Michael Dempsey, vamX, Jeffrey Morgan, zynix, jjj, Omer Bin Jawed, Sean Connelly, jinyuan sun, Jeromy Smith, Shadi, Pawan Osman, Chadd, Elijah Stavena, Illia Dulskyi, Sebastain Graf, Stephen Murray, terasurfer, Edmond Seymore, Celu Ramasamy, Mandus, Alex, biorpg, Ajan Kanaga, Clay Pascal, Raven Klaugh, 阿明, K, ya boyyy, usrbinkat, Alicia Loh, John Villwock, ReadyPlayerEmma, Chris Smitley, Cap'n Zoog, fincy, GodLy, S_X, sidney chen, Cory Kujawski, OG, Mano Prime, AzureBlack, Pieter, Kalila, Spencer Kim, Tom X Nguyen, Stanislav Ovsiannikov, Michael Levine, Andrey, Trailburnt, Vadim, Enrico Ros, Talal Aujan, Brandon Phillips, Jack West, Eugene Pentland, Michael Davis, Will Dee, webtim, Jonathan Leane, Alps Aficionado, Rooh Singh, Tiffany J. Kim, theTransient, Luke @flexchar, Elle, Caitlyn Gatomon, Ari Malik, subjectnull, Johann-Peter Hartmann, Trenton Dambrowitz, Imad Khwaja, Asp the Wyvern, Emad Mostaque, Rainer Wilmers, Alexandros Triantafyllidis, Nicholas, Pedro Madruga, SuperWojo, Harry Royden McLaughlin, James Bentley, Olakabola, David Ziegler, Ai Maven, Jeff Scroggin, Nikolai Manek, Deo Leter, Matthew Berman, Fen Risland, Ken Nordquist, Manuel Alberto Morcote, Luke Pendergrass, TL, Fred von Graf, Randy H, Dan Guido, NimbleBox.ai, Vitor Caleffi, Gabriel Tamborski, knownsqashed, Lone Striker, Erik Bjäreholt, John Detwiler, Leonard Tan, Iucharbius
298
+
299
+
300
+ Thank you to all my generous patrons and donaters!
301
+
302
+ And thank you again to a16z for their generous grant.
303
+
304
+ <!-- footer end -->
305
+
306
+ <!-- original-model-card start -->
307
+ # Original model card: Merlyn Mind's Merlyn Education Corpus QA v2
308
+
309
+
310
+ # Merlyn-Education Corpus QA
311
+
312
+ merlyn-education-corpus-qa-v2 is a 13b parameter decoder-style transformer model for the education domain. It is fine-tuned from a [llama2-13b](https://huggingface.co/meta-llama/Llama-2-13b-hf) base-model.
313
+
314
+ This model was trained by [Merlyn Mind](https://www.merlyn.org/).
315
+
316
+ It is a model that provides an answer to a question based on the given context.
317
+
318
+ ## Model Date
319
+
320
+ August 21, 2023
321
+
322
+ ## Model License
323
+
324
+ Apache-2.0
325
+
326
+
327
+ ## Usage
328
+
329
+ Loading model and tokenizer:
330
+
331
+ ```python
332
+ import torch
333
+ from transformers import AutoTokenizer, AutoModelForCausalLM
334
+
335
+ model_path = "MerlynMind/merlyn-education-corpus-qa-v2"
336
+ device = torch.device("cuda:0") # change device id as necessary
337
+ model = AutoModelForCausalLM.from_pretrained(model_path)
338
+ tokenizer = AutoTokenizer.from_pretrained(model_path, fast_tokenizer=True)
339
+ model.to(device) # move to device
340
+
341
+ ```
342
+
343
+ Prompt example:
344
+
345
+ ```python
346
+ info = '''Information:\tThe Solar System is about 4.6 billion years old. The Sun formed by gravity in a large molecular cloud. It is mainly hydrogen, which it converts into helium.
347
+ Information:\tThe formation and evolution of the Solar System began 4.6 billion years ago with the gravitational collapse of a small part of a giant molecular cloud.
348
+ Information:\tAstronomers are now more or less certain that the order of the planets was not always as it is today. Knowing what we know today, we can see the Solar System is strange. All other planetary system we are able to study have their largest planet close to their star. Also we have noticed other oddities in the Solar System. Mars is smaller than it ought to be, and the asteroid belt has been disturbed.
349
+ Information:\tFor thousands of years, people had no need for a name for the "Solar System". They thought the Earth stayed still at the center of everything (geocentrism). The Greek philosopher Aristarchus of Samos suggested that there was a special order in the sky. Nicolaus Copernicus was the first to develop a mathematical system that described what we now call the "Solar System". This was called a "new system of the world". In the 17th century, Galileo Galilei, Johannes Kepler and Isaac Newton began to understand physics more clearly. People began to accept the idea that the Earth is a planet that moves around the Sun, and that the planets are worlds, and that all worlds are governed by the same same physical laws. More recently, telescopes and space probes sometimes let us see details directly. All inner planets have surface features. The gas giants (as the name suggests) have surfaces whose make-up is gradually being discovered.
350
+ Information:\tThere are eight planets in the Solar System. From closest to farthest from the Sun, they are: Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus and Neptune. The first four planets are called terrestrial planets. They are mostly made of rock and metal, and they are mostly solid. The last four planets are called gas giants. This is because they are much larger than other planets and are mostly made of gas.
351
+ '''
352
+ qs = "Question:\tHow old is the Solar System?"
353
+
354
+ prompt = tokenizer.bos_token
355
+ prompt += '''Instruction:\tYou are to try to answer the following question using only the pieces of information given.
356
+ Instruction:\tYour response should be a well formed JSON object with an 'answerable' property followed by an 'answer' property.
357
+ Instruction:\tIf you cannot answer the question given the information, the value of the 'answerable' should be 'false' and the 'answer' should be an empty string.
358
+ Instruction:\tIf you can answer the question given the information, the value of the 'answerable' should be 'true' and your answer should be the string value of the 'answer' property.
359
+ ''' + info + qs + " Response:"
360
+
361
+ ```
362
+
363
+ We recommend using newline character for stopping criterion, as follows:
364
+
365
+ ```python
366
+ from transformers import StoppingCriteria, StoppingCriteriaList
367
+
368
+ eos_tokens = [tokenizer.eos_token,'\n']
369
+ eos_token_ids = [tokenizer.encode(token)[0] for token in eos_tokens]
370
+
371
+ class MultipleEOSTokensStoppingCriteria(StoppingCriteria):
372
+ def __init__(self, eos_token_ids):
373
+ self.eos_token_ids = set(eos_token_ids)
374
+ def __call__(self, input_ids, scores) -> bool:
375
+ if input_ids.shape[-1] <= 1:
376
+ return False
377
+ for eos_token_id in self.eos_token_ids:
378
+ if eos_token_id == input_ids[0, -1].item():
379
+ return True
380
+ return False
381
+
382
+ # Define stopping criteria
383
+ multiple_eos_tokens_processor = MultipleEOSTokensStoppingCriteria(eos_token_ids)
384
+ stopping_criteria = StoppingCriteriaList([multiple_eos_tokens_processor])
385
+ ```
386
+
387
+ Inference:
388
+
389
+ ```python
390
+ inputs = tokenizer(prompt, return_tensors="pt", return_token_type_ids=False).to(device)
391
+ generate_ids = model.generate(
392
+ **inputs,
393
+ max_new_tokens=1024,
394
+ temperature=0.0,
395
+ num_beams=2,
396
+ top_p=1,
397
+ stopping_criteria=stopping_criteria
398
+ )
399
+ response = tokenizer.decode(generate_ids[0],
400
+ skip_special_tokens=True,
401
+ clean_up_tokenization_spaces=True)
402
+ ```
403
+
404
+ Example output (after response processing):
405
+
406
+ ```json
407
+ [{"answerable": "true", "answer": "4.6 billion years"}]
408
+ ```
409
+
410
+ ## Evaluation
411
+ This model is trained on a larger dataset compared to the [pythia-based v1 model](https://huggingface.co/MerlynMind/merlyn-education-corpus-qa), yielding better correctness and reduced hallucinations on a larger and more diverse benchmarking dataset.
412
+
413
+
414
+
415
+ <!-- original-model-card end -->