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}<|end_of_turn|>GPT4 Assistant:
|
9 |
+
|
10 |
+
'
|
11 |
+
quantized_by: TheBloke
|
12 |
+
---
|
13 |
+
<!-- markdownlint-disable MD041 -->
|
14 |
+
|
15 |
+
<!-- header start -->
|
16 |
+
<!-- 200823 -->
|
17 |
+
<div style="width: auto; margin-left: auto; margin-right: auto">
|
18 |
+
<img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
|
19 |
+
</div>
|
20 |
+
<div style="display: flex; justify-content: space-between; width: 100%;">
|
21 |
+
<div style="display: flex; flex-direction: column; align-items: flex-start;">
|
22 |
+
<p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
|
23 |
+
</div>
|
24 |
+
<div style="display: flex; flex-direction: column; align-items: flex-end;">
|
25 |
+
<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>
|
26 |
+
</div>
|
27 |
+
</div>
|
28 |
+
<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>
|
29 |
+
<hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
|
30 |
+
<!-- header end -->
|
31 |
+
|
32 |
+
# OpenChat 3.5 7B - AWQ
|
33 |
+
- Model creator: [OpenChat](https://huggingface.co/openchat)
|
34 |
+
- Original model: [OpenChat 3.5 7B](https://huggingface.co/openchat/openchat_3.5)
|
35 |
+
|
36 |
+
<!-- description start -->
|
37 |
+
## Description
|
38 |
+
|
39 |
+
This repo contains AWQ model files for [OpenChat's OpenChat 3.5 7B](https://huggingface.co/openchat/openchat_3.5).
|
40 |
+
|
41 |
+
These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
|
42 |
+
|
43 |
+
|
44 |
+
### About AWQ
|
45 |
+
|
46 |
+
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.
|
47 |
+
|
48 |
+
It is supported by:
|
49 |
+
|
50 |
+
- [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
|
51 |
+
- [vLLM](https://github.com/vllm-project/vllm) - Llama and Mistral models only
|
52 |
+
- [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
|
53 |
+
- [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
|
54 |
+
|
55 |
+
<!-- description end -->
|
56 |
+
<!-- repositories-available start -->
|
57 |
+
## Repositories available
|
58 |
+
|
59 |
+
* [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/openchat_3.5-AWQ)
|
60 |
+
* [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/openchat_3.5-GPTQ)
|
61 |
+
* [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/openchat_3.5-GGUF)
|
62 |
+
* [OpenChat's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/openchat/openchat_3.5)
|
63 |
+
<!-- repositories-available end -->
|
64 |
+
|
65 |
+
<!-- prompt-template start -->
|
66 |
+
## Prompt template: OpenChat
|
67 |
+
|
68 |
+
```
|
69 |
+
GPT4 User: {prompt}<|end_of_turn|>GPT4 Assistant:
|
70 |
+
|
71 |
+
```
|
72 |
+
|
73 |
+
<!-- prompt-template end -->
|
74 |
+
|
75 |
+
|
76 |
+
<!-- README_AWQ.md-provided-files start -->
|
77 |
+
## Provided files, and AWQ parameters
|
78 |
+
|
79 |
+
For my first release of AWQ models, I am releasing 128g models only. I will consider adding 32g as well if there is interest, and once I have done perplexity and evaluation comparisons, but at this time 32g models are still not fully tested with AutoAWQ and vLLM.
|
80 |
+
|
81 |
+
Models are released as sharded safetensors files.
|
82 |
+
|
83 |
+
| Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
|
84 |
+
| ------ | ---- | -- | ----------- | ------- | ---- |
|
85 |
+
| [main](https://huggingface.co/TheBloke/openchat_3.5-AWQ/tree/main) | 4 | 128 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-v1/test) | 4096 | 4.15 GB
|
86 |
+
|
87 |
+
<!-- README_AWQ.md-provided-files end -->
|
88 |
+
|
89 |
+
<!-- README_AWQ.md-text-generation-webui start -->
|
90 |
+
## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
|
91 |
+
|
92 |
+
Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
|
93 |
+
|
94 |
+
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.
|
95 |
+
|
96 |
+
1. Click the **Model tab**.
|
97 |
+
2. Under **Download custom model or LoRA**, enter `TheBloke/openchat_3.5-AWQ`.
|
98 |
+
3. Click **Download**.
|
99 |
+
4. The model will start downloading. Once it's finished it will say "Done".
|
100 |
+
5. In the top left, click the refresh icon next to **Model**.
|
101 |
+
6. In the **Model** dropdown, choose the model you just downloaded: `openchat_3.5-AWQ`
|
102 |
+
7. Select **Loader: AutoAWQ**.
|
103 |
+
8. Click Load, and the model will load and is now ready for use.
|
104 |
+
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.
|
105 |
+
10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
|
106 |
+
<!-- README_AWQ.md-text-generation-webui end -->
|
107 |
+
|
108 |
+
<!-- README_AWQ.md-use-from-vllm start -->
|
109 |
+
## Multi-user inference server: vLLM
|
110 |
+
|
111 |
+
Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
|
112 |
+
|
113 |
+
- Please ensure you are using vLLM version 0.2 or later.
|
114 |
+
- When using vLLM as a server, pass the `--quantization awq` parameter.
|
115 |
+
|
116 |
+
For example:
|
117 |
+
|
118 |
+
```shell
|
119 |
+
python3 python -m vllm.entrypoints.api_server --model TheBloke/openchat_3.5-AWQ --quantization awq
|
120 |
+
```
|
121 |
+
|
122 |
+
- When using vLLM from Python code, again set `quantization=awq`.
|
123 |
+
|
124 |
+
For example:
|
125 |
+
|
126 |
+
```python
|
127 |
+
from vllm import LLM, SamplingParams
|
128 |
+
|
129 |
+
prompts = [
|
130 |
+
"Tell me about AI",
|
131 |
+
"Write a story about llamas",
|
132 |
+
"What is 291 - 150?",
|
133 |
+
"How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
|
134 |
+
]
|
135 |
+
prompt_template=f'''GPT4 User: {prompt}<|end_of_turn|>GPT4 Assistant:
|
136 |
+
'''
|
137 |
+
|
138 |
+
prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
|
139 |
+
|
140 |
+
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
|
141 |
+
|
142 |
+
llm = LLM(model="TheBloke/openchat_3.5-AWQ", quantization="awq", dtype="auto")
|
143 |
+
|
144 |
+
outputs = llm.generate(prompts, sampling_params)
|
145 |
+
|
146 |
+
# Print the outputs.
|
147 |
+
for output in outputs:
|
148 |
+
prompt = output.prompt
|
149 |
+
generated_text = output.outputs[0].text
|
150 |
+
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
|
151 |
+
```
|
152 |
+
<!-- README_AWQ.md-use-from-vllm start -->
|
153 |
+
|
154 |
+
<!-- README_AWQ.md-use-from-tgi start -->
|
155 |
+
## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
|
156 |
+
|
157 |
+
Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
|
158 |
+
|
159 |
+
Example Docker parameters:
|
160 |
+
|
161 |
+
```shell
|
162 |
+
--model-id TheBloke/openchat_3.5-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
|
163 |
+
```
|
164 |
+
|
165 |
+
Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
|
166 |
+
|
167 |
+
```shell
|
168 |
+
pip3 install huggingface-hub
|
169 |
+
```
|
170 |
+
|
171 |
+
```python
|
172 |
+
from huggingface_hub import InferenceClient
|
173 |
+
|
174 |
+
endpoint_url = "https://your-endpoint-url-here"
|
175 |
+
|
176 |
+
prompt = "Tell me about AI"
|
177 |
+
prompt_template=f'''GPT4 User: {prompt}<|end_of_turn|>GPT4 Assistant:
|
178 |
+
'''
|
179 |
+
|
180 |
+
client = InferenceClient(endpoint_url)
|
181 |
+
response = client.text_generation(prompt,
|
182 |
+
max_new_tokens=128,
|
183 |
+
do_sample=True,
|
184 |
+
temperature=0.7,
|
185 |
+
top_p=0.95,
|
186 |
+
top_k=40,
|
187 |
+
repetition_penalty=1.1)
|
188 |
+
|
189 |
+
print(f"Model output: ", response)
|
190 |
+
```
|
191 |
+
<!-- README_AWQ.md-use-from-tgi end -->
|
192 |
+
|
193 |
+
<!-- README_AWQ.md-use-from-python start -->
|
194 |
+
## Inference from Python code using AutoAWQ
|
195 |
+
|
196 |
+
### Install the AutoAWQ package
|
197 |
+
|
198 |
+
Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.1 or later.
|
199 |
+
|
200 |
+
```shell
|
201 |
+
pip3 install autoawq
|
202 |
+
```
|
203 |
+
|
204 |
+
If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
|
205 |
+
|
206 |
+
```shell
|
207 |
+
pip3 uninstall -y autoawq
|
208 |
+
git clone https://github.com/casper-hansen/AutoAWQ
|
209 |
+
cd AutoAWQ
|
210 |
+
pip3 install .
|
211 |
+
```
|
212 |
+
|
213 |
+
### AutoAWQ example code
|
214 |
+
|
215 |
+
```python
|
216 |
+
from awq import AutoAWQForCausalLM
|
217 |
+
from transformers import AutoTokenizer
|
218 |
+
|
219 |
+
model_name_or_path = "TheBloke/openchat_3.5-AWQ"
|
220 |
+
|
221 |
+
# Load tokenizer
|
222 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=False)
|
223 |
+
# Load model
|
224 |
+
model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
|
225 |
+
trust_remote_code=False, safetensors=True)
|
226 |
+
|
227 |
+
prompt = "Tell me about AI"
|
228 |
+
prompt_template=f'''GPT4 User: {prompt}<|end_of_turn|>GPT4 Assistant:
|
229 |
+
'''
|
230 |
+
|
231 |
+
print("*** Running model.generate:")
|
232 |
+
|
233 |
+
token_input = tokenizer(
|
234 |
+
prompt_template,
|
235 |
+
return_tensors='pt'
|
236 |
+
).input_ids.cuda()
|
237 |
+
|
238 |
+
# Generate output
|
239 |
+
generation_output = model.generate(
|
240 |
+
token_input,
|
241 |
+
do_sample=True,
|
242 |
+
temperature=0.7,
|
243 |
+
top_p=0.95,
|
244 |
+
top_k=40,
|
245 |
+
max_new_tokens=512
|
246 |
+
)
|
247 |
+
|
248 |
+
# Get the tokens from the output, decode them, print them
|
249 |
+
token_output = generation_output[0]
|
250 |
+
text_output = tokenizer.decode(token_output)
|
251 |
+
print("LLM output: ", text_output)
|
252 |
+
|
253 |
+
"""
|
254 |
+
# Inference should be possible with transformers pipeline as well in future
|
255 |
+
# But currently this is not yet supported by AutoAWQ (correct as of September 25th 2023)
|
256 |
+
from transformers import pipeline
|
257 |
+
|
258 |
+
print("*** Pipeline:")
|
259 |
+
pipe = pipeline(
|
260 |
+
"text-generation",
|
261 |
+
model=model,
|
262 |
+
tokenizer=tokenizer,
|
263 |
+
max_new_tokens=512,
|
264 |
+
do_sample=True,
|
265 |
+
temperature=0.7,
|
266 |
+
top_p=0.95,
|
267 |
+
top_k=40,
|
268 |
+
repetition_penalty=1.1
|
269 |
+
)
|
270 |
+
|
271 |
+
print(pipe(prompt_template)[0]['generated_text'])
|
272 |
+
"""
|
273 |
+
```
|
274 |
+
<!-- README_AWQ.md-use-from-python end -->
|
275 |
+
|
276 |
+
<!-- README_AWQ.md-compatibility start -->
|
277 |
+
## Compatibility
|
278 |
+
|
279 |
+
The files provided are tested to work with:
|
280 |
+
|
281 |
+
- [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
|
282 |
+
- [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
|
283 |
+
- [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
|
284 |
+
- [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
|
285 |
+
|
286 |
+
<!-- README_AWQ.md-compatibility end -->
|
287 |
+
|
288 |
+
<!-- footer start -->
|
289 |
+
<!-- 200823 -->
|
290 |
+
## Discord
|
291 |
+
|
292 |
+
For further support, and discussions on these models and AI in general, join us at:
|
293 |
+
|
294 |
+
[TheBloke AI's Discord server](https://discord.gg/theblokeai)
|
295 |
+
|
296 |
+
## Thanks, and how to contribute
|
297 |
+
|
298 |
+
Thanks to the [chirper.ai](https://chirper.ai) team!
|
299 |
+
|
300 |
+
Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
|
301 |
+
|
302 |
+
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.
|
303 |
+
|
304 |
+
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.
|
305 |
+
|
306 |
+
Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
|
307 |
+
|
308 |
+
* Patreon: https://patreon.com/TheBlokeAI
|
309 |
+
* Ko-Fi: https://ko-fi.com/TheBlokeAI
|
310 |
+
|
311 |
+
**Special thanks to**: Aemon Algiz.
|
312 |
+
|
313 |
+
**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
|
314 |
+
|
315 |
+
|
316 |
+
Thank you to all my generous patrons and donaters!
|
317 |
+
|
318 |
+
And thank you again to a16z for their generous grant.
|
319 |
+
|
320 |
+
<!-- footer end -->
|
321 |
+
|
322 |
+
# Original model card: OpenChat's OpenChat 3.5 7B
|
323 |
+
|
324 |
+
|
325 |
+
# OpenChat: Advancing Open-source Language Models with Mixed-Quality Data
|
326 |
+
|
327 |
+
<div align="center">
|
328 |
+
<img src="https://raw.githubusercontent.com/imoneoi/openchat/master/assets/logo_new.png" style="width: 65%">
|
329 |
+
</div>
|
330 |
+
|
331 |
+
<p align="center">
|
332 |
+
<a href="https://openchat.team">Online Demo</a> •
|
333 |
+
<a href="https://discord.gg/pQjnXvNKHY">Discord</a> •
|
334 |
+
<a href="https://huggingface.co/openchat">Huggingface</a> •
|
335 |
+
<a href="https://arxiv.org/pdf/2309.11235.pdf">Paper</a>
|
336 |
+
</p>
|
337 |
+
|
338 |
+
**🔥 The first 7B model Achieves Comparable Results with ChatGPT (March)! 🔥**
|
339 |
+
|
340 |
+
**🤖 #1 Open-source model on MT-bench scoring 7.81, outperforming 70B models 🤖**
|
341 |
+
|
342 |
+
<div align="center">
|
343 |
+
<img src="https://raw.githubusercontent.com/imoneoi/openchat/master/assets/openchat.png" style="width: 50%">
|
344 |
+
</div>
|
345 |
+
|
346 |
+
OpenChat is an innovative library of open-source language models, fine-tuned with [C-RLFT](https://arxiv.org/pdf/2309.11235.pdf) - a strategy inspired by offline reinforcement learning. Our models learn from mixed-quality data without preference labels, delivering exceptional performance on par with ChatGPT, even with a 7B model. Despite our simple approach, we are committed to developing a high-performance, commercially viable, open-source large language model, and we continue to make significant strides toward this vision.
|
347 |
+
|
348 |
+
[![DOI](https://zenodo.org/badge/645397533.svg)](https://zenodo.org/badge/latestdoi/645397533)
|
349 |
+
|
350 |
+
## Usage
|
351 |
+
|
352 |
+
To use this model, we highly recommend installing the OpenChat package by following the [installation guide](#installation) and using the OpenChat OpenAI-compatible API server by running the serving command from the table below. The server is optimized for high-throughput deployment using [vLLM](https://github.com/vllm-project/vllm) and can run on a consumer GPU with 24GB RAM. To enable tensor parallelism, append `--tensor-parallel-size N` to the serving command.
|
353 |
+
|
354 |
+
Once started, the server listens at `localhost:18888` for requests and is compatible with the [OpenAI ChatCompletion API specifications](https://platform.openai.com/docs/api-reference/chat). Please refer to the example request below for reference. Additionally, you can use the [OpenChat Web UI](#web-ui) for a user-friendly experience.
|
355 |
+
|
356 |
+
If you want to deploy the server as an online service, you can use `--api-keys sk-KEY1 sk-KEY2 ...` to specify allowed API keys and `--disable-log-requests --disable-log-stats --log-file openchat.log` for logging only to a file. For security purposes, we recommend using an [HTTPS gateway](https://fastapi.tiangolo.com/es/deployment/concepts/#security-https) in front of the server.
|
357 |
+
|
358 |
+
<details>
|
359 |
+
<summary>Example request (click to expand)</summary>
|
360 |
+
|
361 |
+
```bash
|
362 |
+
curl http://localhost:18888/v1/chat/completions \
|
363 |
+
-H "Content-Type: application/json" \
|
364 |
+
-d '{
|
365 |
+
"model": "openchat_3.5",
|
366 |
+
"messages": [{"role": "user", "content": "You are a large language model named OpenChat. Write a poem to describe yourself"}]
|
367 |
+
}'
|
368 |
+
```
|
369 |
+
|
370 |
+
Coding Mode
|
371 |
+
|
372 |
+
```bash
|
373 |
+
curl http://localhost:18888/v1/chat/completions \
|
374 |
+
-H "Content-Type: application/json" \
|
375 |
+
-d '{
|
376 |
+
"model": "openchat_3.5",
|
377 |
+
"condition": "Code",
|
378 |
+
"messages": [{"role": "user", "content": "Write an aesthetic TODO app using HTML5 and JS, in a single file. You should use round corners and gradients to make it more aesthetic."}]
|
379 |
+
}'
|
380 |
+
```
|
381 |
+
|
382 |
+
</details>
|
383 |
+
|
384 |
+
| Model | Size | Context | Weights | Serving |
|
385 |
+
|--------------|------|---------|-------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
|
386 |
+
| OpenChat 3.5 | 7B | 8192 | [Huggingface](https://huggingface.co/openchat/openchat_3.5) | `python -m ochat.serving.openai_api_server --model openchat/openchat_3.5 --engine-use-ray --worker-use-ray` |
|
387 |
+
|
388 |
+
For inference with Huggingface Transformers (slow and not recommended), follow the conversation template provided below.
|
389 |
+
|
390 |
+
<details>
|
391 |
+
<summary>Conversation templates (click to expand)</summary>
|
392 |
+
|
393 |
+
```python
|
394 |
+
import transformers
|
395 |
+
tokenizer = transformers.AutoTokenizer.from_pretrained("openchat/openchat_3.5")
|
396 |
+
|
397 |
+
# Single-turn
|
398 |
+
tokens = tokenizer("GPT4 Correct User: Hello<|end_of_turn|>GPT4 Correct Assistant:").input_ids
|
399 |
+
assert tokens == [1, 420, 6316, 28781, 3198, 3123, 1247, 28747, 22557, 32000, 420, 6316, 28781, 3198, 3123, 21631, 28747]
|
400 |
+
|
401 |
+
# Multi-turn
|
402 |
+
tokens = tokenizer("GPT4 Correct User: Hello<|end_of_turn|>GPT4 Correct Assistant: Hi<|end_of_turn|>GPT4 Correct User: How are you today?<|end_of_turn|>GPT4 Correct Assistant:").input_ids
|
403 |
+
assert tokens == [1, 420, 6316, 28781, 3198, 3123, 1247, 28747, 22557, 32000, 420, 6316, 28781, 3198, 3123, 21631, 28747, 15359, 32000, 420, 6316, 28781, 3198, 3123, 1247, 28747, 1602, 460, 368, 3154, 28804, 32000, 420, 6316, 28781, 3198, 3123, 21631, 28747]
|
404 |
+
|
405 |
+
# Coding Mode
|
406 |
+
tokens = tokenizer("Code User: Implement quicksort using C++<|end_of_turn|>Code Assistant:").input_ids
|
407 |
+
assert tokens == [1, 7596, 1247, 28747, 26256, 2936, 7653, 1413, 334, 1680, 32000, 7596, 21631, 28747]
|
408 |
+
```
|
409 |
+
|
410 |
+
</details>
|
411 |
+
|
412 |
+
## <a id="benchmarks"></a> Benchmarks
|
413 |
+
|
414 |
+
| Model | # Params | Average | MT-Bench | AGIEval | BBH MC | TruthfulQA | MMLU | HumanEval | BBH CoT | GSM8K |
|
415 |
+
|--------------------|----------|----------|--------------|----------|----------|---------------|--------------|-----------------|-------------|--------------|
|
416 |
+
| OpenChat-3.5 | **7B** | **61.6** | 7.81 | **47.4** | **47.6** | **59.1** | 64.3 | **55.5** | 63.5 | **77.3** |
|
417 |
+
| ChatGPT (March)* | ? | 61.5 | **7.94** | 47.1 | **47.6** | 57.7 | **67.3** | 48.1 | **70.1** | 74.9 |
|
418 |
+
| Mistral | 7B | - | 6.84 | 38.0 | 39.0 | - | 60.1 | 30.5 | - | 52.2 |
|
419 |
+
| Open-source SOTA** | 13B-70B | 61.4 | 7.71 | 41.7 | 49.7 | 62.3 | 63.7 | 73.2 | 41.4 | 82.3 |
|
420 |
+
| | | | WizardLM 70B | Orca 13B | Orca 13B | Platypus2 70B | WizardLM 70B | WizardCoder 34B | Flan-T5 11B | MetaMath 70B |
|
421 |
+
|
422 |
+
*: ChatGPT (March) results are from GPT-4 Technical Report, Chain-of-Thought Hub, and our evaluation.
|
423 |
+
|
424 |
+
**: Open-source SOTA results are taken from reported results in instruction-tuned model papers and official repositories.
|
425 |
+
|
426 |
+
***: All zero-shot benchmarks follow the same setting as in the AGIEval paper and Orca paper. CoT tasks use the same configuration as Chain-of-Thought Hub, HumanEval is evaluated with EvalPlus, and MT-bench is run using FastChat. To reproduce our results, follow the instructions in [our repository](https://github.com/imoneoi/openchat/#benchmarks).
|
427 |
+
|
428 |
+
## Limitations
|
429 |
+
|
430 |
+
**Foundation Model Limitations**
|
431 |
+
Despite its advanced capabilities, OpenChat is still bound by the limitations inherent in its foundation models. These limitations may impact the model's performance in areas such as:
|
432 |
+
|
433 |
+
- Complex reasoning
|
434 |
+
- Mathematical and arithmetic tasks
|
435 |
+
- Programming and coding challenges
|
436 |
+
|
437 |
+
**Hallucination of Non-existent Information**
|
438 |
+
OpenChat may sometimes generate information that does not exist or is not accurate, also known as "hallucination". Users should be aware of this possibility and verify any critical information obtained from the model.
|
439 |
+
|
440 |
+
**Safety**
|
441 |
+
OpenChat may sometimes generate harmful, hate speech, biased responses, or answer unsafe questions. It's crucial to apply additional AI safety measures in use cases that require safe and moderated responses.
|
442 |
+
|
443 |
+
## License
|
444 |
+
|
445 |
+
Our OpenChat 3.5 code and models are distributed under the Apache License 2.0.
|
446 |
+
|
447 |
+
## Citation
|
448 |
+
|
449 |
+
```
|
450 |
+
@article{wang2023openchat,
|
451 |
+
title={OpenChat: Advancing Open-source Language Models with Mixed-Quality Data},
|
452 |
+
author={Wang, Guan and Cheng, Sijie and Zhan, Xianyuan and Li, Xiangang and Song, Sen and Liu, Yang},
|
453 |
+
journal={arXiv preprint arXiv:2309.11235},
|
454 |
+
year={2023}
|
455 |
+
}
|
456 |
+
```
|
457 |
+
|
458 |
+
## Acknowledgements
|
459 |
+
|
460 |
+
We extend our heartfelt gratitude to Alignment Lab AI, Nous Research, and Pygmalion AI for their substantial contributions to data collection and model training.
|
461 |
+
|
462 |
+
Special thanks go to Changling Liu from GPT Desk Pte. Ltd., Qiying Yu at Tsinghua University, Baochang Ma, and Hao Wan from 01.AI company for their generous provision of resources. We are also deeply grateful to Jianxiong Li and Peng Li at Tsinghua University for their insightful discussions.
|
463 |
+
|
464 |
+
Furthermore, we appreciate the developers behind the following projects for their significant contributions to our research: [Mistral](https://mistral.ai/), [Chain-of-Thought Hub](https://github.com/FranxYao/chain-of-thought-hub), [Llama 2](https://ai.meta.com/llama/), [Self-Instruct](https://arxiv.org/abs/2212.10560), [FastChat (Vicuna)](https://github.com/lm-sys/FastChat), [Alpaca](https://github.com/tatsu-lab/stanford_alpaca.git), and [StarCoder](https://github.com/bigcode-project/starcoder). Their work has been instrumental in driving our research forward.
|