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ator: 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 - AWQ
|
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 AWQ 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 |
+
|
55 |
+
### About AWQ
|
56 |
+
|
57 |
+
AWQ is an efficient, accurate and blazing-fast low-bit weight quantization method, currently supporting 4-bit quantization. Compared to GPTQ, it offers faster Transformers-based inference with equivalent or better quality compared to the most commonly used GPTQ settings.
|
58 |
+
|
59 |
+
It is supported by:
|
60 |
+
|
61 |
+
- [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
|
62 |
+
- [vLLM](https://github.com/vllm-project/vllm) - Llama and Mistral models only
|
63 |
+
- [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
|
64 |
+
- [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later, from any code or client that supports Transformers
|
65 |
+
- [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
|
66 |
+
|
67 |
+
<!-- description end -->
|
68 |
+
<!-- repositories-available start -->
|
69 |
+
## Repositories available
|
70 |
+
|
71 |
+
* [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-AWQ)
|
72 |
+
* [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GPTQ)
|
73 |
+
* [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-GGUF)
|
74 |
+
* [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)
|
75 |
+
<!-- repositories-available end -->
|
76 |
+
|
77 |
+
<!-- prompt-template start -->
|
78 |
+
## Prompt template: Merlyn-Education
|
79 |
+
|
80 |
+
```
|
81 |
+
Instruction:\t{system_message}
|
82 |
+
Conversation:
|
83 |
+
'user1':\tuser message to analyse
|
84 |
+
'user2':\tuser message to analyse
|
85 |
+
Response:
|
86 |
+
|
87 |
+
```
|
88 |
+
|
89 |
+
<!-- prompt-template end -->
|
90 |
+
<!-- licensing start -->
|
91 |
+
## Licensing
|
92 |
+
|
93 |
+
The creator of the source model has listed its license as `apache-2.0`, and this quantization has therefore used that same license.
|
94 |
+
|
95 |
+
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.
|
96 |
+
|
97 |
+
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).
|
98 |
+
<!-- licensing end -->
|
99 |
+
<!-- README_AWQ.md-provided-files start -->
|
100 |
+
## Provided files, and AWQ parameters
|
101 |
+
|
102 |
+
I currently release 128g GEMM models only. The addition of group_size 32 models, and GEMV kernel models, is being actively considered.
|
103 |
+
|
104 |
+
Models are released as sharded safetensors files.
|
105 |
+
|
106 |
+
| Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
|
107 |
+
| ------ | ---- | -- | ----------- | ------- | ---- |
|
108 |
+
| [main](https://huggingface.co/TheBloke/merlyn-education-corpus-qa-v2-AWQ/tree/main) | 4 | 128 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-raw-v1) | 4096 | 7.25 GB
|
109 |
+
|
110 |
+
<!-- README_AWQ.md-provided-files end -->
|
111 |
+
|
112 |
+
<!-- README_AWQ.md-text-generation-webui start -->
|
113 |
+
## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
|
114 |
+
|
115 |
+
Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
|
116 |
+
|
117 |
+
It is strongly recommended to use the text-generation-webui one-click-installers unless you're sure you know how to make a manual install.
|
118 |
+
|
119 |
+
1. Click the **Model tab**.
|
120 |
+
2. Under **Download custom model or LoRA**, enter `TheBloke/merlyn-education-corpus-qa-v2-AWQ`.
|
121 |
+
3. Click **Download**.
|
122 |
+
4. The model will start downloading. Once it's finished it will say "Done".
|
123 |
+
5. In the top left, click the refresh icon next to **Model**.
|
124 |
+
6. In the **Model** dropdown, choose the model you just downloaded: `merlyn-education-corpus-qa-v2-AWQ`
|
125 |
+
7. Select **Loader: AutoAWQ**.
|
126 |
+
8. Click Load, and the model will load and is now ready for use.
|
127 |
+
9. If you want any custom settings, set them and then click **Save settings for this model** followed by **Reload the Model** in the top right.
|
128 |
+
10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
|
129 |
+
<!-- README_AWQ.md-text-generation-webui end -->
|
130 |
+
|
131 |
+
<!-- README_AWQ.md-use-from-vllm start -->
|
132 |
+
## Multi-user inference server: vLLM
|
133 |
+
|
134 |
+
Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
|
135 |
+
|
136 |
+
- Please ensure you are using vLLM version 0.2 or later.
|
137 |
+
- When using vLLM as a server, pass the `--quantization awq` parameter.
|
138 |
+
|
139 |
+
For example:
|
140 |
+
|
141 |
+
```shell
|
142 |
+
python3 -m vllm.entrypoints.api_server --model TheBloke/merlyn-education-corpus-qa-v2-AWQ --quantization awq --dtype auto
|
143 |
+
```
|
144 |
+
|
145 |
+
- When using vLLM from Python code, again set `quantization=awq`.
|
146 |
+
|
147 |
+
For example:
|
148 |
+
|
149 |
+
```python
|
150 |
+
from vllm import LLM, SamplingParams
|
151 |
+
|
152 |
+
prompts = [
|
153 |
+
"Tell me about AI",
|
154 |
+
"Write a story about llamas",
|
155 |
+
"What is 291 - 150?",
|
156 |
+
"How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
|
157 |
+
]
|
158 |
+
prompt_template=f'''Instruction:\t{system_message}
|
159 |
+
Conversation:
|
160 |
+
'user1':\tuser message to analyse
|
161 |
+
'user2':\tuser message to analyse
|
162 |
+
Response:
|
163 |
+
'''
|
164 |
+
|
165 |
+
prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
|
166 |
+
|
167 |
+
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
|
168 |
+
|
169 |
+
llm = LLM(model="TheBloke/merlyn-education-corpus-qa-v2-AWQ", quantization="awq", dtype="auto")
|
170 |
+
|
171 |
+
outputs = llm.generate(prompts, sampling_params)
|
172 |
+
|
173 |
+
# Print the outputs.
|
174 |
+
for output in outputs:
|
175 |
+
prompt = output.prompt
|
176 |
+
generated_text = output.outputs[0].text
|
177 |
+
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
|
178 |
+
```
|
179 |
+
<!-- README_AWQ.md-use-from-vllm start -->
|
180 |
+
|
181 |
+
<!-- README_AWQ.md-use-from-tgi start -->
|
182 |
+
## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
|
183 |
+
|
184 |
+
Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
|
185 |
+
|
186 |
+
Example Docker parameters:
|
187 |
+
|
188 |
+
```shell
|
189 |
+
--model-id TheBloke/merlyn-education-corpus-qa-v2-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
|
190 |
+
```
|
191 |
+
|
192 |
+
Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
|
193 |
+
|
194 |
+
```shell
|
195 |
+
pip3 install huggingface-hub
|
196 |
+
```
|
197 |
+
|
198 |
+
```python
|
199 |
+
from huggingface_hub import InferenceClient
|
200 |
+
|
201 |
+
endpoint_url = "https://your-endpoint-url-here"
|
202 |
+
|
203 |
+
prompt = "Tell me about AI"
|
204 |
+
prompt_template=f'''Instruction:\t{system_message}
|
205 |
+
Conversation:
|
206 |
+
'user1':\tuser message to analyse
|
207 |
+
'user2':\tuser message to analyse
|
208 |
+
Response:
|
209 |
+
'''
|
210 |
+
|
211 |
+
client = InferenceClient(endpoint_url)
|
212 |
+
response = client.text_generation(prompt,
|
213 |
+
max_new_tokens=128,
|
214 |
+
do_sample=True,
|
215 |
+
temperature=0.7,
|
216 |
+
top_p=0.95,
|
217 |
+
top_k=40,
|
218 |
+
repetition_penalty=1.1)
|
219 |
+
|
220 |
+
print(f"Model output: ", response)
|
221 |
+
```
|
222 |
+
<!-- README_AWQ.md-use-from-tgi end -->
|
223 |
+
|
224 |
+
<!-- README_AWQ.md-use-from-python start -->
|
225 |
+
## Inference from Python code using Transformers
|
226 |
+
|
227 |
+
### Install the necessary packages
|
228 |
+
|
229 |
+
- Requires: [Transformers](https://huggingface.co/docs/transformers) 4.35.0 or later.
|
230 |
+
- Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.6 or later.
|
231 |
+
|
232 |
+
```shell
|
233 |
+
pip3 install --upgrade "autoawq>=0.1.6" "transformers>=4.35.0"
|
234 |
+
```
|
235 |
+
|
236 |
+
Note that if you are using PyTorch 2.0.1, the above AutoAWQ command will automatically upgrade you to PyTorch 2.1.0.
|
237 |
+
|
238 |
+
If you are using CUDA 11.8 and wish to continue using PyTorch 2.0.1, instead run this command:
|
239 |
+
|
240 |
+
```shell
|
241 |
+
pip3 install https://github.com/casper-hansen/AutoAWQ/releases/download/v0.1.6/autoawq-0.1.6+cu118-cp310-cp310-linux_x86_64.whl
|
242 |
+
```
|
243 |
+
|
244 |
+
If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
|
245 |
+
|
246 |
+
```shell
|
247 |
+
pip3 uninstall -y autoawq
|
248 |
+
git clone https://github.com/casper-hansen/AutoAWQ
|
249 |
+
cd AutoAWQ
|
250 |
+
pip3 install .
|
251 |
+
```
|
252 |
+
|
253 |
+
### Transformers example code (requires Transformers 4.35.0 and later)
|
254 |
+
|
255 |
+
```python
|
256 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
|
257 |
+
|
258 |
+
model_name_or_path = "TheBloke/merlyn-education-corpus-qa-v2-AWQ"
|
259 |
+
|
260 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
|
261 |
+
model = AutoModelForCausalLM.from_pretrained(
|
262 |
+
model_name_or_path,
|
263 |
+
low_cpu_mem_usage=True,
|
264 |
+
device_map="cuda:0"
|
265 |
+
)
|
266 |
+
|
267 |
+
# Using the text streamer to stream output one token at a time
|
268 |
+
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
269 |
+
|
270 |
+
prompt = "Tell me about AI"
|
271 |
+
prompt_template=f'''Instruction:\t{system_message}
|
272 |
+
Conversation:
|
273 |
+
'user1':\tuser message to analyse
|
274 |
+
'user2':\tuser message to analyse
|
275 |
+
Response:
|
276 |
+
'''
|
277 |
+
|
278 |
+
# Convert prompt to tokens
|
279 |
+
tokens = tokenizer(
|
280 |
+
prompt_template,
|
281 |
+
return_tensors='pt'
|
282 |
+
).input_ids.cuda()
|
283 |
+
|
284 |
+
generation_params = {
|
285 |
+
"do_sample": True,
|
286 |
+
"temperature": 0.7,
|
287 |
+
"top_p": 0.95,
|
288 |
+
"top_k": 40,
|
289 |
+
"max_new_tokens": 512,
|
290 |
+
"repetition_penalty": 1.1
|
291 |
+
}
|
292 |
+
|
293 |
+
# Generate streamed output, visible one token at a time
|
294 |
+
generation_output = model.generate(
|
295 |
+
tokens,
|
296 |
+
streamer=streamer,
|
297 |
+
**generation_params
|
298 |
+
)
|
299 |
+
|
300 |
+
# Generation without a streamer, which will include the prompt in the output
|
301 |
+
generation_output = model.generate(
|
302 |
+
tokens,
|
303 |
+
**generation_params
|
304 |
+
)
|
305 |
+
|
306 |
+
# Get the tokens from the output, decode them, print them
|
307 |
+
token_output = generation_output[0]
|
308 |
+
text_output = tokenizer.decode(token_output)
|
309 |
+
print("model.generate output: ", text_output)
|
310 |
+
|
311 |
+
# Inference is also possible via Transformers' pipeline
|
312 |
+
from transformers import pipeline
|
313 |
+
|
314 |
+
pipe = pipeline(
|
315 |
+
"text-generation",
|
316 |
+
model=model,
|
317 |
+
tokenizer=tokenizer,
|
318 |
+
**generation_params
|
319 |
+
)
|
320 |
+
|
321 |
+
pipe_output = pipe(prompt_template)[0]['generated_text']
|
322 |
+
print("pipeline output: ", pipe_output)
|
323 |
+
|
324 |
+
```
|
325 |
+
<!-- README_AWQ.md-use-from-python end -->
|
326 |
+
|
327 |
+
<!-- README_AWQ.md-compatibility start -->
|
328 |
+
## Compatibility
|
329 |
+
|
330 |
+
The files provided are tested to work with:
|
331 |
+
|
332 |
+
- [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
|
333 |
+
- [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
|
334 |
+
- [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
|
335 |
+
- [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later.
|
336 |
+
- [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
|
337 |
+
|
338 |
+
<!-- README_AWQ.md-compatibility end -->
|
339 |
+
|
340 |
+
<!-- footer start -->
|
341 |
+
<!-- 200823 -->
|
342 |
+
## Discord
|
343 |
+
|
344 |
+
For further support, and discussions on these models and AI in general, join us at:
|
345 |
+
|
346 |
+
[TheBloke AI's Discord server](https://discord.gg/theblokeai)
|
347 |
+
|
348 |
+
## Thanks, and how to contribute
|
349 |
+
|
350 |
+
Thanks to the [chirper.ai](https://chirper.ai) team!
|
351 |
+
|
352 |
+
Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
|
353 |
+
|
354 |
+
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.
|
355 |
+
|
356 |
+
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.
|
357 |
+
|
358 |
+
Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
|
359 |
+
|
360 |
+
* Patreon: https://patreon.com/TheBlokeAI
|
361 |
+
* Ko-Fi: https://ko-fi.com/TheBlokeAI
|
362 |
+
|
363 |
+
**Special thanks to**: Aemon Algiz.
|
364 |
+
|
365 |
+
**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
|
366 |
+
|
367 |
+
|
368 |
+
Thank you to all my generous patrons and donaters!
|
369 |
+
|
370 |
+
And thank you again to a16z for their generous grant.
|
371 |
+
|
372 |
+
<!-- footer end -->
|
373 |
+
|
374 |
+
# Original model card: Merlyn Mind's Merlyn Education Corpus QA v2
|
375 |
+
|
376 |
+
|
377 |
+
# Merlyn-Education Corpus QA
|
378 |
+
|
379 |
+
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.
|
380 |
+
|
381 |
+
This model was trained by [Merlyn Mind](https://www.merlyn.org/).
|
382 |
+
|
383 |
+
It is a model that provides an answer to a question based on the given context.
|
384 |
+
|
385 |
+
## Model Date
|
386 |
+
|
387 |
+
August 21, 2023
|
388 |
+
|
389 |
+
## Model License
|
390 |
+
|
391 |
+
Apache-2.0
|
392 |
+
|
393 |
+
|
394 |
+
## Usage
|
395 |
+
|
396 |
+
Loading model and tokenizer:
|
397 |
+
|
398 |
+
```python
|
399 |
+
import torch
|
400 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
401 |
+
|
402 |
+
model_path = "MerlynMind/merlyn-education-corpus-qa-v2"
|
403 |
+
device = torch.device("cuda:0") # change device id as necessary
|
404 |
+
model = AutoModelForCausalLM.from_pretrained(model_path)
|
405 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, fast_tokenizer=True)
|
406 |
+
model.to(device) # move to device
|
407 |
+
|
408 |
+
```
|
409 |
+
|
410 |
+
Prompt example:
|
411 |
+
|
412 |
+
```python
|
413 |
+
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.
|
414 |
+
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.
|
415 |
+
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.
|
416 |
+
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.
|
417 |
+
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.
|
418 |
+
'''
|
419 |
+
qs = "Question:\tHow old is the Solar System?"
|
420 |
+
|
421 |
+
prompt = tokenizer.bos_token
|
422 |
+
prompt += '''Instruction:\tYou are to try to answer the following question using only the pieces of information given.
|
423 |
+
Instruction:\tYour response should be a well formed JSON object with an 'answerable' property followed by an 'answer' property.
|
424 |
+
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.
|
425 |
+
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.
|
426 |
+
''' + info + qs + " Response:"
|
427 |
+
|
428 |
+
```
|
429 |
+
|
430 |
+
We recommend using newline character for stopping criterion, as follows:
|
431 |
+
|
432 |
+
```python
|
433 |
+
from transformers import StoppingCriteria, StoppingCriteriaList
|
434 |
+
|
435 |
+
eos_tokens = [tokenizer.eos_token,'\n']
|
436 |
+
eos_token_ids = [tokenizer.encode(token)[0] for token in eos_tokens]
|
437 |
+
|
438 |
+
class MultipleEOSTokensStoppingCriteria(StoppingCriteria):
|
439 |
+
def __init__(self, eos_token_ids):
|
440 |
+
self.eos_token_ids = set(eos_token_ids)
|
441 |
+
def __call__(self, input_ids, scores) -> bool:
|
442 |
+
if input_ids.shape[-1] <= 1:
|
443 |
+
return False
|
444 |
+
for eos_token_id in self.eos_token_ids:
|
445 |
+
if eos_token_id == input_ids[0, -1].item():
|
446 |
+
return True
|
447 |
+
return False
|
448 |
+
|
449 |
+
# Define stopping criteria
|
450 |
+
multiple_eos_tokens_processor = MultipleEOSTokensStoppingCriteria(eos_token_ids)
|
451 |
+
stopping_criteria = StoppingCriteriaList([multiple_eos_tokens_processor])
|
452 |
+
```
|
453 |
+
|
454 |
+
Inference:
|
455 |
+
|
456 |
+
```python
|
457 |
+
inputs = tokenizer(prompt, return_tensors="pt", return_token_type_ids=False).to(device)
|
458 |
+
generate_ids = model.generate(
|
459 |
+
**inputs,
|
460 |
+
max_new_tokens=1024,
|
461 |
+
temperature=0.0,
|
462 |
+
num_beams=2,
|
463 |
+
top_p=1,
|
464 |
+
stopping_criteria=stopping_criteria
|
465 |
+
)
|
466 |
+
response = tokenizer.decode(generate_ids[0],
|
467 |
+
skip_special_tokens=True,
|
468 |
+
clean_up_tokenization_spaces=True)
|
469 |
+
```
|
470 |
+
|
471 |
+
Example output (after response processing):
|
472 |
+
|
473 |
+
```json
|
474 |
+
[{"answerable": "true", "answer": "4.6 billion years"}]
|
475 |
+
```
|
476 |
+
|
477 |
+
## Evaluation
|
478 |
+
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.
|
479 |
+
|
480 |
+
|