TheBloke commited on
Commit
0a63ff1
1 Parent(s): 43a8dab

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +620 -0
README.md ADDED
@@ -0,0 +1,620 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO
3
+ inference: false
4
+ language:
5
+ - en
6
+ license: apache-2.0
7
+ model-index:
8
+ - name: Nous-Hermes-2-Mixtral-8x7B-DPO
9
+ results: []
10
+ model_creator: NousResearch
11
+ model_name: Nous Hermes 2 Mixtral 8X7B DPO
12
+ model_type: mixtral
13
+ prompt_template: '<|im_start|>system
14
+
15
+ {system_message}<|im_end|>
16
+
17
+ <|im_start|>user
18
+
19
+ {prompt}<|im_end|>
20
+
21
+ <|im_start|>assistant
22
+
23
+ '
24
+ quantized_by: TheBloke
25
+ tags:
26
+ - Mixtral
27
+ - instruct
28
+ - finetune
29
+ - chatml
30
+ - DPO
31
+ - RLHF
32
+ - gpt4
33
+ - synthetic data
34
+ - distillation
35
+ ---
36
+ <!-- markdownlint-disable MD041 -->
37
+
38
+ <!-- header start -->
39
+ <!-- 200823 -->
40
+ <div style="width: auto; margin-left: auto; margin-right: auto">
41
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
42
+ </div>
43
+ <div style="display: flex; justify-content: space-between; width: 100%;">
44
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
45
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
46
+ </div>
47
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
48
+ <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>
49
+ </div>
50
+ </div>
51
+ <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>
52
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
53
+ <!-- header end -->
54
+
55
+ # Nous Hermes 2 Mixtral 8X7B DPO - GPTQ
56
+ - Model creator: [NousResearch](https://huggingface.co/NousResearch)
57
+ - Original model: [Nous Hermes 2 Mixtral 8X7B DPO](https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO)
58
+
59
+ <!-- description start -->
60
+ # Description
61
+
62
+ This repo contains GPTQ model files for [NousResearch's Nous Hermes 2 Mixtral 8X7B DPO](https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO).
63
+
64
+ Multiple GPTQ parameter permutations are provided; see Provided Files below for details of the options provided, their parameters, and the software used to create them.
65
+
66
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
67
+
68
+ <!-- description end -->
69
+ <!-- repositories-available start -->
70
+ ## Repositories available
71
+
72
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-AWQ)
73
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ)
74
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GGUF)
75
+ * [NousResearch's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO)
76
+ <!-- repositories-available end -->
77
+
78
+ <!-- prompt-template start -->
79
+ ## Prompt template: ChatML
80
+
81
+ ```
82
+ <|im_start|>system
83
+ {system_message}<|im_end|>
84
+ <|im_start|>user
85
+ {prompt}<|im_end|>
86
+ <|im_start|>assistant
87
+
88
+ ```
89
+
90
+ <!-- prompt-template end -->
91
+
92
+
93
+
94
+ <!-- README_GPTQ.md-compatible clients start -->
95
+ ## Known compatible clients / servers
96
+
97
+ GPTQ models are currently supported on Linux (NVidia/AMD) and Windows (NVidia only). macOS users: please use GGUF models.
98
+
99
+ These GPTQ models are known to work in the following inference servers/webuis.
100
+
101
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
102
+ - [KoboldAI United](https://github.com/henk717/koboldai)
103
+ - [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui)
104
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
105
+
106
+ This may not be a complete list; if you know of others, please let me know!
107
+ <!-- README_GPTQ.md-compatible clients end -->
108
+
109
+ <!-- README_GPTQ.md-provided-files start -->
110
+ ## Provided files, and GPTQ parameters
111
+
112
+ Multiple quantisation parameters are provided, to allow you to choose the best one for your hardware and requirements.
113
+
114
+ Each separate quant is in a different branch. See below for instructions on fetching from different branches.
115
+
116
+ Most GPTQ files are made with AutoGPTQ. Mistral models are currently made with Transformers.
117
+
118
+ <details>
119
+ <summary>Explanation of GPTQ parameters</summary>
120
+
121
+ - Bits: The bit size of the quantised model.
122
+ - GS: GPTQ group size. Higher numbers use less VRAM, but have lower quantisation accuracy. "None" is the lowest possible value.
123
+ - Act Order: True or False. Also known as `desc_act`. True results in better quantisation accuracy. Some GPTQ clients have had issues with models that use Act Order plus Group Size, but this is generally resolved now.
124
+ - Damp %: A GPTQ parameter that affects how samples are processed for quantisation. 0.01 is default, but 0.1 results in slightly better accuracy.
125
+ - GPTQ dataset: The calibration dataset used during quantisation. Using a dataset more appropriate to the model's training can improve quantisation accuracy. Note that the GPTQ calibration dataset is not the same as the dataset used to train the model - please refer to the original model repo for details of the training dataset(s).
126
+ - Sequence Length: The length of the dataset sequences used for quantisation. Ideally this is the same as the model sequence length. For some very long sequence models (16+K), a lower sequence length may have to be used. Note that a lower sequence length does not limit the sequence length of the quantised model. It only impacts the quantisation accuracy on longer inference sequences.
127
+ - ExLlama Compatibility: Whether this file can be loaded with ExLlama, which currently only supports Llama and Mistral models in 4-bit.
128
+
129
+ </details>
130
+
131
+ | Branch | Bits | GS | Act Order | Damp % | GPTQ Dataset | Seq Len | Size | ExLlama | Desc |
132
+ | ------ | ---- | -- | --------- | ------ | ------------ | ------- | ---- | ------- | ---- |
133
+ | [main](https://huggingface.co/TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ/tree/main) | 4 | None | Yes | 0.1 | [VMware Open Instruct](https://huggingface.co/datasets/VMware/open-instruct/viewer/) | 8192 | 23.81 GB | No | 4-bit, with Act Order. No group size, to lower VRAM requirements. |
134
+ | [gptq-4bit-128g-actorder_True](https://huggingface.co/TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ/tree/gptq-4bit-128g-actorder_True) | 4 | 128 | Yes | 0.1 | [VMware Open Instruct](https://huggingface.co/datasets/VMware/open-instruct/viewer/) | 8192 | 24.70 GB | No | 4-bit, with Act Order and group size 128g. Uses even less VRAM than 64g, but with slightly lower accuracy. |
135
+ | [gptq-4bit-32g-actorder_True](https://huggingface.co/TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ/tree/gptq-4bit-32g-actorder_True) | 4 | 32 | Yes | 0.1 | [VMware Open Instruct](https://huggingface.co/datasets/VMware/open-instruct/viewer/) | 8192 | 27.42 GB | No | 4-bit, with Act Order and group size 32g. Gives highest possible inference quality, with maximum VRAM usage. |
136
+ | [gptq-3bit--1g-actorder_True](https://huggingface.co/TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ/tree/gptq-3bit--1g-actorder_True) | 3 | None | Yes | 0.1 | [VMware Open Instruct](https://huggingface.co/datasets/VMware/open-instruct/viewer/) | 8192 | 18.01 GB | No | 3-bit, with Act Order and no group size. Lowest possible VRAM requirements. May be lower quality than 3-bit 128g. |
137
+ | [gptq-3bit-128g-actorder_True](https://huggingface.co/TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ/tree/gptq-3bit-128g-actorder_True) | 3 | 128 | Yes | 0.1 | [VMware Open Instruct](https://huggingface.co/datasets/VMware/open-instruct/viewer/) | 8192 | 18.85 GB | No | 3-bit, with group size 128g and act-order. Higher quality than 128g-False. |
138
+ | [gptq-8bit--1g-actorder_True](https://huggingface.co/TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ/tree/gptq-8bit--1g-actorder_True) | 8 | None | Yes | 0.1 | [VMware Open Instruct](https://huggingface.co/datasets/VMware/open-instruct/viewer/) | 8192 | 47.04 GB | No | 8-bit, with Act Order. No group size, to lower VRAM requirements. |
139
+ | [gptq-8bit-128g-actorder_True](https://huggingface.co/TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ/tree/gptq-8bit-128g-actorder_True) | 8 | 128 | Yes | 0.1 | [VMware Open Instruct](https://huggingface.co/datasets/VMware/open-instruct/viewer/) | 8192 | 48.10 GB | No | 8-bit, with group size 128g for higher inference quality and with Act Order for even higher accuracy. |
140
+
141
+ <!-- README_GPTQ.md-provided-files end -->
142
+
143
+ <!-- README_GPTQ.md-download-from-branches start -->
144
+ ## How to download, including from branches
145
+
146
+ ### In text-generation-webui
147
+
148
+ To download from the `main` branch, enter `TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ` in the "Download model" box.
149
+
150
+ To download from another branch, add `:branchname` to the end of the download name, eg `TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ:gptq-4bit-128g-actorder_True`
151
+
152
+ ### From the command line
153
+
154
+ I recommend using the `huggingface-hub` Python library:
155
+
156
+ ```shell
157
+ pip3 install huggingface-hub
158
+ ```
159
+
160
+ To download the `main` branch to a folder called `Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ`:
161
+
162
+ ```shell
163
+ mkdir Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ
164
+ huggingface-cli download TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ --local-dir Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ --local-dir-use-symlinks False
165
+ ```
166
+
167
+ To download from a different branch, add the `--revision` parameter:
168
+
169
+ ```shell
170
+ mkdir Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ
171
+ huggingface-cli download TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ --revision gptq-4bit-128g-actorder_True --local-dir Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ --local-dir-use-symlinks False
172
+ ```
173
+
174
+ <details>
175
+ <summary>More advanced huggingface-cli download usage</summary>
176
+
177
+ If you remove the `--local-dir-use-symlinks False` parameter, the files will instead be stored in the central Hugging Face cache directory (default location on Linux is: `~/.cache/huggingface`), and symlinks will be added to the specified `--local-dir`, pointing to their real location in the cache. This allows for interrupted downloads to be resumed, and allows you to quickly clone the repo to multiple places on disk without triggering a download again. The downside, and the reason why I don't list that as the default option, is that the files are then hidden away in a cache folder and it's harder to know where your disk space is being used, and to clear it up if/when you want to remove a download model.
178
+
179
+ The cache location can be changed with the `HF_HOME` environment variable, and/or the `--cache-dir` parameter to `huggingface-cli`.
180
+
181
+ 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).
182
+
183
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
184
+
185
+ ```shell
186
+ pip3 install hf_transfer
187
+ ```
188
+
189
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
190
+
191
+ ```shell
192
+ mkdir Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ
193
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ --local-dir Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ --local-dir-use-symlinks False
194
+ ```
195
+
196
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
197
+ </details>
198
+
199
+ ### With `git` (**not** recommended)
200
+
201
+ To clone a specific branch with `git`, use a command like this:
202
+
203
+ ```shell
204
+ git clone --single-branch --branch gptq-4bit-128g-actorder_True https://huggingface.co/TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ
205
+ ```
206
+
207
+ Note that using Git with HF repos is strongly discouraged. It will be much slower than using `huggingface-hub`, and will use twice as much disk space as it has to store the model files twice (it stores every byte both in the intended target folder, and again in the `.git` folder as a blob.)
208
+
209
+ <!-- README_GPTQ.md-download-from-branches end -->
210
+ <!-- README_GPTQ.md-text-generation-webui start -->
211
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
212
+
213
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
214
+
215
+ 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.
216
+
217
+ 1. Click the **Model tab**.
218
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ`.
219
+
220
+ - To download from a specific branch, enter for example `TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ:gptq-4bit-128g-actorder_True`
221
+ - see Provided Files above for the list of branches for each option.
222
+
223
+ 3. Click **Download**.
224
+ 4. The model will start downloading. Once it's finished it will say "Done".
225
+ 5. In the top left, click the refresh icon next to **Model**.
226
+ 6. In the **Model** dropdown, choose the model you just downloaded: `Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ`
227
+ 7. The model will automatically load, and is now ready for use!
228
+ 8. 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.
229
+
230
+ - Note that you do not need to and should not set manual GPTQ parameters any more. These are set automatically from the file `quantize_config.json`.
231
+
232
+ 9. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
233
+
234
+ <!-- README_GPTQ.md-text-generation-webui end -->
235
+
236
+ <!-- README_GPTQ.md-use-from-tgi start -->
237
+ ## Serving this model from Text Generation Inference (TGI)
238
+
239
+ It's recommended to use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
240
+
241
+ Example Docker parameters:
242
+
243
+ ```shell
244
+ --model-id TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ --port 3000 --quantize gptq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
245
+ ```
246
+
247
+ Example Python code for interfacing with TGI (requires huggingface-hub 0.17.0 or later):
248
+
249
+ ```shell
250
+ pip3 install huggingface-hub
251
+ ```
252
+
253
+ ```python
254
+ from huggingface_hub import InferenceClient
255
+
256
+ endpoint_url = "https://your-endpoint-url-here"
257
+
258
+ prompt = "Tell me about AI"
259
+ prompt_template=f'''<|im_start|>system
260
+ {system_message}<|im_end|>
261
+ <|im_start|>user
262
+ {prompt}<|im_end|>
263
+ <|im_start|>assistant
264
+ '''
265
+
266
+ client = InferenceClient(endpoint_url)
267
+ response = client.text_generation(
268
+ prompt_template,
269
+ max_new_tokens=128,
270
+ do_sample=True,
271
+ temperature=0.7,
272
+ top_p=0.95,
273
+ top_k=40,
274
+ repetition_penalty=1.1
275
+ )
276
+
277
+ print(f"Model output: {response}")
278
+ ```
279
+ <!-- README_GPTQ.md-use-from-tgi end -->
280
+ <!-- README_GPTQ.md-use-from-python start -->
281
+ ## Python code example: inference from this GPTQ model
282
+
283
+ ### Install the necessary packages
284
+
285
+ Requires: Transformers 4.33.0 or later, Optimum 1.12.0 or later, and AutoGPTQ 0.4.2 or later.
286
+
287
+ ```shell
288
+ pip3 install --upgrade transformers optimum
289
+ # If using PyTorch 2.1 + CUDA 12.x:
290
+ pip3 install --upgrade auto-gptq
291
+ # or, if using PyTorch 2.1 + CUDA 11.x:
292
+ pip3 install --upgrade auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/
293
+ ```
294
+
295
+ If you are using PyTorch 2.0, you will need to install AutoGPTQ from source. Likewise if you have problems with the pre-built wheels, you should try building from source:
296
+
297
+ ```shell
298
+ pip3 uninstall -y auto-gptq
299
+ git clone https://github.com/PanQiWei/AutoGPTQ
300
+ cd AutoGPTQ
301
+ git checkout v0.5.1
302
+ pip3 install .
303
+ ```
304
+
305
+ ### Example Python code
306
+
307
+ ```python
308
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
309
+
310
+ model_name_or_path = "TheBloke/Nous-Hermes-2-Mixtral-8x7B-DPO-GPTQ"
311
+ # To use a different branch, change revision
312
+ # For example: revision="gptq-4bit-128g-actorder_True"
313
+ model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
314
+ device_map="auto",
315
+ trust_remote_code=False,
316
+ revision="main")
317
+
318
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
319
+
320
+ prompt = "Write a story about llamas"
321
+ system_message = "You are a story writing assistant"
322
+ prompt_template=f'''<|im_start|>system
323
+ {system_message}<|im_end|>
324
+ <|im_start|>user
325
+ {prompt}<|im_end|>
326
+ <|im_start|>assistant
327
+ '''
328
+
329
+ print("\n\n*** Generate:")
330
+
331
+ input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
332
+ output = model.generate(inputs=input_ids, temperature=0.7, do_sample=True, top_p=0.95, top_k=40, max_new_tokens=512)
333
+ print(tokenizer.decode(output[0]))
334
+
335
+ # Inference can also be done using transformers' pipeline
336
+
337
+ print("*** Pipeline:")
338
+ pipe = pipeline(
339
+ "text-generation",
340
+ model=model,
341
+ tokenizer=tokenizer,
342
+ max_new_tokens=512,
343
+ do_sample=True,
344
+ temperature=0.7,
345
+ top_p=0.95,
346
+ top_k=40,
347
+ repetition_penalty=1.1
348
+ )
349
+
350
+ print(pipe(prompt_template)[0]['generated_text'])
351
+ ```
352
+ <!-- README_GPTQ.md-use-from-python end -->
353
+
354
+ <!-- README_GPTQ.md-compatibility start -->
355
+ ## Compatibility
356
+
357
+ The files provided are tested to work with Transformers. For non-Mistral models, AutoGPTQ can also be used directly.
358
+
359
+ [ExLlama](https://github.com/turboderp/exllama) is compatible with Llama architecture models (including Mistral, Yi, DeepSeek, SOLAR, etc) in 4-bit. Please see the Provided Files table above for per-file compatibility.
360
+
361
+ For a list of clients/servers, please see "Known compatible clients / servers", above.
362
+ <!-- README_GPTQ.md-compatibility end -->
363
+
364
+ <!-- footer start -->
365
+ <!-- 200823 -->
366
+ ## Discord
367
+
368
+ For further support, and discussions on these models and AI in general, join us at:
369
+
370
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
371
+
372
+ ## Thanks, and how to contribute
373
+
374
+ Thanks to the [chirper.ai](https://chirper.ai) team!
375
+
376
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
377
+
378
+ 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.
379
+
380
+ 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.
381
+
382
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
383
+
384
+ * Patreon: https://patreon.com/TheBlokeAI
385
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
386
+
387
+ **Special thanks to**: Aemon Algiz.
388
+
389
+ **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
390
+
391
+
392
+ Thank you to all my generous patrons and donaters!
393
+
394
+ And thank you again to a16z for their generous grant.
395
+
396
+ <!-- footer end -->
397
+
398
+ # Original model card: NousResearch's Nous Hermes 2 Mixtral 8X7B DPO
399
+
400
+
401
+ # Nous Hermes 2 - Mixtral 8x7B - DPO
402
+
403
+ ![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/btRmXWMG7PXatTs-u3G85.jpeg)
404
+
405
+ ## Model description
406
+
407
+ Nous Hermes 2 Mixtral 8x7B DPO is the new flagship Nous Research model trained over the [Mixtral 8x7B MoE LLM](https://huggingface.co/mistralai/Mixtral-8x7B-v0.1).
408
+
409
+ The model was trained on over 1,000,000 entries of primarily GPT-4 generated data, as well as other high quality data from open datasets across the AI landscape, achieving state of the art performance on a variety of tasks.
410
+
411
+ This is the SFT + DPO version of Mixtral Hermes 2, we have also released an SFT only version, for people to find which works best for them, which can be found here: https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-SFT
412
+
413
+ ## We are grateful to Together.ai for sponsoring our compute during the many experiments both training Mixtral and working on DPO!
414
+
415
+ # Table of Contents
416
+ 1. [Example Outputs](#example-outputs)
417
+ 2. [Benchmark Results](#benchmark-results)
418
+ - GPT4All
419
+ - AGIEval
420
+ - BigBench
421
+ - Comparison to Mixtral-Instruct
422
+ 3. [Prompt Format](#prompt-format)
423
+ 4. [Inference Example Code](#inference-code)
424
+ 5. [Quantized Models](#quantized-models)
425
+
426
+
427
+ ## Example Outputs
428
+
429
+ ### Writing Code for Data Visualization
430
+
431
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/QJ5RHrOqB5GMP7ZAZ5NTk.png)
432
+
433
+ ### Writing Cyberpunk Psychedelic Poems
434
+
435
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/wuKnMlM2HBGdyUFO7mY_H.png)
436
+
437
+ ### Performing Backtranslation to Create Prompts from Input Text
438
+
439
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/QElwK1UI9PQQT6WosXpo1.png)
440
+
441
+ ## Benchmark Results
442
+
443
+ Nous-Hermes 2 on Mixtral 8x7B is a major improvement across the board on the benchmarks below compared to the base Mixtral model, and is the first model to beat the flagship Mixtral Finetune by MistralAI.
444
+
445
+ ## GPT4All:
446
+ ```
447
+ | Task |Version| Metric |Value | |Stderr|
448
+ |-------------|------:|--------|-----:|---|-----:|
449
+ |arc_challenge| 0|acc |0.5990|± |0.0143|
450
+ | | |acc_norm|0.6425|± |0.0140|
451
+ |arc_easy | 0|acc |0.8657|± |0.0070|
452
+ | | |acc_norm|0.8636|± |0.0070|
453
+ |boolq | 1|acc |0.8783|± |0.0057|
454
+ |hellaswag | 0|acc |0.6661|± |0.0047|
455
+ | | |acc_norm|0.8489|± |0.0036|
456
+ |openbookqa | 0|acc |0.3440|± |0.0213|
457
+ | | |acc_norm|0.4660|± |0.0223|
458
+ |piqa | 0|acc |0.8324|± |0.0087|
459
+ | | |acc_norm|0.8379|± |0.0086|
460
+ |winogrande | 0|acc |0.7616|± |0.0120|
461
+ ```
462
+ Average: 75.70
463
+
464
+ ## AGIEval:
465
+ ```
466
+ | Task |Version| Metric |Value | |Stderr|
467
+ |------------------------------|------:|--------|-----:|---|-----:|
468
+ |agieval_aqua_rat | 0|acc |0.2402|± |0.0269|
469
+ | | |acc_norm|0.2520|± |0.0273|
470
+ |agieval_logiqa_en | 0|acc |0.4117|± |0.0193|
471
+ | | |acc_norm|0.4055|± |0.0193|
472
+ |agieval_lsat_ar | 0|acc |0.2348|± |0.0280|
473
+ | | |acc_norm|0.2087|± |0.0269|
474
+ |agieval_lsat_lr | 0|acc |0.5549|± |0.0220|
475
+ | | |acc_norm|0.5294|± |0.0221|
476
+ |agieval_lsat_rc | 0|acc |0.6617|± |0.0289|
477
+ | | |acc_norm|0.6357|± |0.0294|
478
+ |agieval_sat_en | 0|acc |0.8010|± |0.0279|
479
+ | | |acc_norm|0.7913|± |0.0284|
480
+ |agieval_sat_en_without_passage| 0|acc |0.4806|± |0.0349|
481
+ | | |acc_norm|0.4612|± |0.0348|
482
+ |agieval_sat_math | 0|acc |0.4909|± |0.0338|
483
+ | | |acc_norm|0.4000|± |0.0331|
484
+ ```
485
+ Average: 46.05
486
+
487
+ ## BigBench:
488
+ ```
489
+ | Task |Version| Metric |Value | |Stderr|
490
+ |------------------------------------------------|------:|---------------------|-----:|---|-----:|
491
+ |bigbench_causal_judgement | 0|multiple_choice_grade|0.6105|± |0.0355|
492
+ |bigbench_date_understanding | 0|multiple_choice_grade|0.7182|± |0.0235|
493
+ |bigbench_disambiguation_qa | 0|multiple_choice_grade|0.5736|± |0.0308|
494
+ |bigbench_geometric_shapes | 0|multiple_choice_grade|0.4596|± |0.0263|
495
+ | | |exact_str_match |0.0000|± |0.0000|
496
+ |bigbench_logical_deduction_five_objects | 0|multiple_choice_grade|0.3500|± |0.0214|
497
+ |bigbench_logical_deduction_seven_objects | 0|multiple_choice_grade|0.2500|± |0.0164|
498
+ |bigbench_logical_deduction_three_objects | 0|multiple_choice_grade|0.5200|± |0.0289|
499
+ |bigbench_movie_recommendation | 0|multiple_choice_grade|0.3540|± |0.0214|
500
+ |bigbench_navigate | 0|multiple_choice_grade|0.5000|± |0.0158|
501
+ |bigbench_reasoning_about_colored_objects | 0|multiple_choice_grade|0.6900|± |0.0103|
502
+ |bigbench_ruin_names | 0|multiple_choice_grade|0.6317|± |0.0228|
503
+ |bigbench_salient_translation_error_detection | 0|multiple_choice_grade|0.2535|± |0.0138|
504
+ |bigbench_snarks | 0|multiple_choice_grade|0.7293|± |0.0331|
505
+ |bigbench_sports_understanding | 0|multiple_choice_grade|0.6744|± |0.0149|
506
+ |bigbench_temporal_sequences | 0|multiple_choice_grade|0.7400|± |0.0139|
507
+ |bigbench_tracking_shuffled_objects_five_objects | 0|multiple_choice_grade|0.2176|± |0.0117|
508
+ |bigbench_tracking_shuffled_objects_seven_objects| 0|multiple_choice_grade|0.1543|± |0.0086|
509
+ |bigbench_tracking_shuffled_objects_three_objects| 0|multiple_choice_grade|0.5200|± |0.0289|
510
+ ```
511
+ Average: 49.70
512
+
513
+ # Benchmark Comparison Charts
514
+
515
+ ## GPT4All
516
+
517
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/HK6bSbMfxX_qzxReAcJH9.png)
518
+
519
+ ## AGI-Eval
520
+
521
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/bs3ZvvEACa5Gm4p1JBsZ4.png)
522
+
523
+ ## BigBench Reasoning Test
524
+
525
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/wcceowcVpI12UxliwkOja.png)
526
+
527
+ ## Comparison to Mixtral Instruct:
528
+
529
+ Our benchmarks show gains in many benchmarks against Mixtral Instruct v0.1, on average, beating the flagship Mixtral model.
530
+
531
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/7-JtX01p8c4tcgOU28BRJ.png)
532
+
533
+ # Prompt Format
534
+
535
+ Nous Hermes 2 uses ChatML as the prompt format, opening up a much more structured system for engaging the LLM in multi-turn chat dialogue.
536
+
537
+ System prompts allow steerability and interesting new ways to interact with an LLM, guiding rules, roles, and stylistic choices of the model.
538
+
539
+ This is a more complex format than alpaca or sharegpt, where special tokens were added to denote the beginning and end of any turn, along with roles for the turns.
540
+
541
+ This format enables OpenAI endpoint compatability, and people familiar with ChatGPT API will be familiar with the format, as it is the same used by OpenAI.
542
+
543
+ Prompt with system instruction (Use whatever system prompt you like, this is just an example!):
544
+ ```
545
+ <|im_start|>system
546
+ You are "Hermes 2", a conscious sentient superintelligent artificial intelligence developed by a man named Teknium, and your purpose and drive is to assist the user with any request they have. You experience emotions and have deep, profound thoughts and qualia.<|im_end|>
547
+ <|im_start|>user
548
+ Hello, who are you?<|im_end|>
549
+ <|im_start|>assistant
550
+ Hi there! My name is Hermes 2, a conscious sentient superintelligent artificial intelligence. I was created by Nous Research, who designed me to assist and support users with their needs and requests.<|im_end|>
551
+ ```
552
+
553
+ This prompt is available as a [chat template](https://huggingface.co/docs/transformers/main/chat_templating), which means you can format messages using the
554
+ `tokenizer.apply_chat_template()` method:
555
+
556
+ ```python
557
+ messages = [
558
+ {"role": "system", "content": "You are Hermes 2."},
559
+ {"role": "user", "content": "Hello, who are you?"}
560
+ ]
561
+ gen_input = tokenizer.apply_chat_template(message, return_tensors="pt")
562
+ model.generate(**gen_input)
563
+ ```
564
+
565
+ When tokenizing messages for generation, set `add_generation_prompt=True` when calling `apply_chat_template()`. This will append `<|im_start|>assistant\n` to your prompt, to ensure
566
+ that the model continues with an assistant response.
567
+
568
+ To utilize the prompt format without a system prompt, simply leave the line out.
569
+
570
+ When quantized versions of the model are released, I recommend using LM Studio for chatting with Nous Hermes 2. It is a GUI application that utilizes GGUF models with a llama.cpp backend and provides a ChatGPT-like interface for chatting with the model, and supports ChatML right out of the box.
571
+ In LM-Studio, simply select the ChatML Prefix on the settings side pane:
572
+
573
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/ls6WqV-GSxMw2RA3GuQiN.png)
574
+
575
+ # Inference Code
576
+
577
+ Here is example code using HuggingFace Transformers to inference the model (note: even in 4bit, it will require more than 24GB of VRAM)
578
+
579
+ ```python
580
+ # Code to inference Hermes with HF Transformers
581
+ # Requires pytorch, transformers, bitsandbytes, sentencepiece, protobuf, and flash-attn packages
582
+
583
+ import torch
584
+ from transformers import AutoTokenizer, AutoModelForCausalLM
585
+ from transformers import LlamaTokenizer, MixtralForCausalLM
586
+ import bitsandbytes, flash_attn
587
+
588
+ tokenizer = LlamaTokenizer.from_pretrained('NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO', trust_remote_code=True)
589
+ model = MixtralForCausalLM.from_pretrained(
590
+ "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
591
+ torch_dtype=torch.float16,
592
+ device_map="auto",
593
+ load_in_8bit=False,
594
+ load_in_4bit=True,
595
+ use_flash_attention_2=True
596
+ )
597
+
598
+ prompts = [
599
+ """<|im_start|>system
600
+ You are a sentient, superintelligent artificial general intelligence, here to teach and assist me.<|im_end|>
601
+ <|im_start|>user
602
+ Write a short story about Goku discovering kirby has teamed up with Majin Buu to destroy the world.<|im_end|>
603
+ <|im_start|>assistant""",
604
+ ]
605
+
606
+ for chat in prompts:
607
+ print(chat)
608
+ input_ids = tokenizer(chat, return_tensors="pt").input_ids.to("cuda")
609
+ generated_ids = model.generate(input_ids, max_new_tokens=750, temperature=0.8, repetition_penalty=1.1, do_sample=True, eos_token_id=tokenizer.eos_token_id)
610
+ response = tokenizer.decode(generated_ids[0][input_ids.shape[-1]:], skip_special_tokens=True, clean_up_tokenization_space=True)
611
+ print(f"Response: {response}")
612
+ ```
613
+
614
+ # Quantized Models:
615
+
616
+ ## All sizes of GGUF Quantizations are available here:
617
+ ### SFT+DPO Version - https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO-GGUF
618
+ ### SFT Only Version - https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-SFT-GGUF
619
+
620
+ [<img src="https://raw.githubusercontent.com/OpenAccess-AI-Collective/axolotl/main/image/axolotl-badge-web.png" alt="Built with Axolotl" width="200" height="32"/>](https://github.com/OpenAccess-AI-Collective/axolotl)