TheBloke commited on
Commit
73d0ec0
1 Parent(s): 74c8526

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +615 -0
README.md ADDED
@@ -0,0 +1,615 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: microsoft/Orca-2-13b
3
+ inference: false
4
+ license: other
5
+ model_creator: Microsoft
6
+ model_name: Orca 2 13B
7
+ model_type: llama
8
+ pipeline_tag: text-generation
9
+ prompt_template: '<|im_start|>system
10
+
11
+ {system_message}<|im_end|>
12
+
13
+ <|im_start|>user
14
+
15
+ {prompt}<|im_end|>
16
+
17
+ <|im_start|>assistant
18
+
19
+ '
20
+ quantized_by: TheBloke
21
+ tags:
22
+ - orca
23
+ - orca2
24
+ - microsoft
25
+ ---
26
+ <!-- markdownlint-disable MD041 -->
27
+
28
+ <!-- header start -->
29
+ <!-- 200823 -->
30
+ <div style="width: auto; margin-left: auto; margin-right: auto">
31
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
32
+ </div>
33
+ <div style="display: flex; justify-content: space-between; width: 100%;">
34
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
35
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
36
+ </div>
37
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
38
+ <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>
39
+ </div>
40
+ </div>
41
+ <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>
42
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
43
+ <!-- header end -->
44
+
45
+ # Orca 2 13B - GPTQ
46
+ - Model creator: [Microsoft](https://huggingface.co/microsoft)
47
+ - Original model: [Orca 2 13B](https://huggingface.co/microsoft/Orca-2-13b)
48
+
49
+ <!-- description start -->
50
+ # Description
51
+
52
+ This repo contains GPTQ model files for [Microsoft's Orca 2 13B](https://huggingface.co/microsoft/Orca-2-13b).
53
+
54
+ 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.
55
+
56
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
57
+
58
+ <!-- description end -->
59
+ <!-- repositories-available start -->
60
+ ## Repositories available
61
+
62
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/Orca-2-13B-AWQ)
63
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Orca-2-13B-GPTQ)
64
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Orca-2-13B-GGUF)
65
+ * [Microsoft's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/microsoft/Orca-2-13b)
66
+ <!-- repositories-available end -->
67
+
68
+ <!-- prompt-template start -->
69
+ ## Prompt template: ChatML
70
+
71
+ ```
72
+ <|im_start|>system
73
+ {system_message}<|im_end|>
74
+ <|im_start|>user
75
+ {prompt}<|im_end|>
76
+ <|im_start|>assistant
77
+
78
+ ```
79
+
80
+ <!-- prompt-template end -->
81
+
82
+
83
+
84
+ <!-- README_GPTQ.md-compatible clients start -->
85
+ ## Known compatible clients / servers
86
+
87
+ These GPTQ models are known to work in the following inference servers/webuis.
88
+
89
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
90
+ - [KoboldAI United](https://github.com/henk717/koboldai)
91
+ - [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui)
92
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
93
+
94
+ This may not be a complete list; if you know of others, please let me know!
95
+ <!-- README_GPTQ.md-compatible clients end -->
96
+
97
+ <!-- README_GPTQ.md-provided-files start -->
98
+ ## Provided files, and GPTQ parameters
99
+
100
+ Multiple quantisation parameters are provided, to allow you to choose the best one for your hardware and requirements.
101
+
102
+ Each separate quant is in a different branch. See below for instructions on fetching from different branches.
103
+
104
+ Most GPTQ files are made with AutoGPTQ. Mistral models are currently made with Transformers.
105
+
106
+ <details>
107
+ <summary>Explanation of GPTQ parameters</summary>
108
+
109
+ - Bits: The bit size of the quantised model.
110
+ - GS: GPTQ group size. Higher numbers use less VRAM, but have lower quantisation accuracy. "None" is the lowest possible value.
111
+ - 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.
112
+ - Damp %: A GPTQ parameter that affects how samples are processed for quantisation. 0.01 is default, but 0.1 results in slightly better accuracy.
113
+ - 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).
114
+ - 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.
115
+ - ExLlama Compatibility: Whether this file can be loaded with ExLlama, which currently only supports Llama and Mistral models in 4-bit.
116
+
117
+ </details>
118
+
119
+ | Branch | Bits | GS | Act Order | Damp % | GPTQ Dataset | Seq Len | Size | ExLlama | Desc |
120
+ | ------ | ---- | -- | --------- | ------ | ------------ | ------- | ---- | ------- | ---- |
121
+ | [main](https://huggingface.co/TheBloke/Orca-2-13B-GPTQ/tree/main) | 4 | 128 | Yes | 0.1 | [c4](https://huggingface.co/datasets/allenai/c4/viewer/allenai--c4) | 4096 | 7.26 GB | Yes | 4-bit, with Act Order and group size 128g. Uses even less VRAM than 64g, but with slightly lower accuracy. |
122
+ | [gptq-4bit-32g-actorder_True](https://huggingface.co/TheBloke/Orca-2-13B-GPTQ/tree/gptq-4bit-32g-actorder_True) | 4 | 32 | Yes | 0.1 | [c4](https://huggingface.co/datasets/allenai/c4/viewer/allenai--c4) | 4096 | 8.00 GB | Yes | 4-bit, with Act Order and group size 32g. Gives highest possible inference quality, with maximum VRAM usage. |
123
+ | [gptq-8bit--1g-actorder_True](https://huggingface.co/TheBloke/Orca-2-13B-GPTQ/tree/gptq-8bit--1g-actorder_True) | 8 | None | Yes | 0.1 | [c4](https://huggingface.co/datasets/allenai/c4/viewer/allenai--c4) | 4096 | 13.36 GB | No | 8-bit, with Act Order. No group size, to lower VRAM requirements. |
124
+ | [gptq-8bit-128g-actorder_True](https://huggingface.co/TheBloke/Orca-2-13B-GPTQ/tree/gptq-8bit-128g-actorder_True) | 8 | 128 | Yes | 0.1 | [c4](https://huggingface.co/datasets/allenai/c4/viewer/allenai--c4) | 4096 | 13.65 GB | No | 8-bit, with group size 128g for higher inference quality and with Act Order for even higher accuracy. |
125
+ | [gptq-8bit-32g-actorder_True](https://huggingface.co/TheBloke/Orca-2-13B-GPTQ/tree/gptq-8bit-32g-actorder_True) | 8 | 32 | Yes | 0.1 | [c4](https://huggingface.co/datasets/allenai/c4/viewer/allenai--c4) | 4096 | 14.55 GB | No | 8-bit, with group size 32g and Act Order for maximum inference quality. |
126
+ | [gptq-4bit-64g-actorder_True](https://huggingface.co/TheBloke/Orca-2-13B-GPTQ/tree/gptq-4bit-64g-actorder_True) | 4 | 64 | Yes | 0.1 | [c4](https://huggingface.co/datasets/allenai/c4/viewer/allenai--c4) | 4096 | 7.51 GB | Yes | 4-bit, with Act Order and group size 64g. Uses less VRAM than 32g, but with slightly lower accuracy. |
127
+
128
+ <!-- README_GPTQ.md-provided-files end -->
129
+
130
+ <!-- README_GPTQ.md-download-from-branches start -->
131
+ ## How to download, including from branches
132
+
133
+ ### In text-generation-webui
134
+
135
+ To download from the `main` branch, enter `TheBloke/Orca-2-13B-GPTQ` in the "Download model" box.
136
+
137
+ To download from another branch, add `:branchname` to the end of the download name, eg `TheBloke/Orca-2-13B-GPTQ:gptq-4bit-32g-actorder_True`
138
+
139
+ ### From the command line
140
+
141
+ I recommend using the `huggingface-hub` Python library:
142
+
143
+ ```shell
144
+ pip3 install huggingface-hub
145
+ ```
146
+
147
+ To download the `main` branch to a folder called `Orca-2-13B-GPTQ`:
148
+
149
+ ```shell
150
+ mkdir Orca-2-13B-GPTQ
151
+ huggingface-cli download TheBloke/Orca-2-13B-GPTQ --local-dir Orca-2-13B-GPTQ --local-dir-use-symlinks False
152
+ ```
153
+
154
+ To download from a different branch, add the `--revision` parameter:
155
+
156
+ ```shell
157
+ mkdir Orca-2-13B-GPTQ
158
+ huggingface-cli download TheBloke/Orca-2-13B-GPTQ --revision gptq-4bit-32g-actorder_True --local-dir Orca-2-13B-GPTQ --local-dir-use-symlinks False
159
+ ```
160
+
161
+ <details>
162
+ <summary>More advanced huggingface-cli download usage</summary>
163
+
164
+ 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.
165
+
166
+ The cache location can be changed with the `HF_HOME` environment variable, and/or the `--cache-dir` parameter to `huggingface-cli`.
167
+
168
+ 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).
169
+
170
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
171
+
172
+ ```shell
173
+ pip3 install hf_transfer
174
+ ```
175
+
176
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
177
+
178
+ ```shell
179
+ mkdir Orca-2-13B-GPTQ
180
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/Orca-2-13B-GPTQ --local-dir Orca-2-13B-GPTQ --local-dir-use-symlinks False
181
+ ```
182
+
183
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
184
+ </details>
185
+
186
+ ### With `git` (**not** recommended)
187
+
188
+ To clone a specific branch with `git`, use a command like this:
189
+
190
+ ```shell
191
+ git clone --single-branch --branch gptq-4bit-32g-actorder_True https://huggingface.co/TheBloke/Orca-2-13B-GPTQ
192
+ ```
193
+
194
+ 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.)
195
+
196
+ <!-- README_GPTQ.md-download-from-branches end -->
197
+ <!-- README_GPTQ.md-text-generation-webui start -->
198
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
199
+
200
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
201
+
202
+ 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.
203
+
204
+ 1. Click the **Model tab**.
205
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/Orca-2-13B-GPTQ`.
206
+
207
+ - To download from a specific branch, enter for example `TheBloke/Orca-2-13B-GPTQ:gptq-4bit-32g-actorder_True`
208
+ - see Provided Files above for the list of branches for each option.
209
+
210
+ 3. Click **Download**.
211
+ 4. The model will start downloading. Once it's finished it will say "Done".
212
+ 5. In the top left, click the refresh icon next to **Model**.
213
+ 6. In the **Model** dropdown, choose the model you just downloaded: `Orca-2-13B-GPTQ`
214
+ 7. The model will automatically load, and is now ready for use!
215
+ 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.
216
+
217
+ - 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`.
218
+
219
+ 9. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
220
+
221
+ <!-- README_GPTQ.md-text-generation-webui end -->
222
+
223
+ <!-- README_GPTQ.md-use-from-tgi start -->
224
+ ## Serving this model from Text Generation Inference (TGI)
225
+
226
+ 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`
227
+
228
+ Example Docker parameters:
229
+
230
+ ```shell
231
+ --model-id TheBloke/Orca-2-13B-GPTQ --port 3000 --quantize gptq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
232
+ ```
233
+
234
+ Example Python code for interfacing with TGI (requires huggingface-hub 0.17.0 or later):
235
+
236
+ ```shell
237
+ pip3 install huggingface-hub
238
+ ```
239
+
240
+ ```python
241
+ from huggingface_hub import InferenceClient
242
+
243
+ endpoint_url = "https://your-endpoint-url-here"
244
+
245
+ prompt = "Tell me about AI"
246
+ prompt_template=f'''<|im_start|>system
247
+ {system_message}<|im_end|>
248
+ <|im_start|>user
249
+ {prompt}<|im_end|>
250
+ <|im_start|>assistant
251
+ '''
252
+
253
+ client = InferenceClient(endpoint_url)
254
+ response = client.text_generation(prompt,
255
+ max_new_tokens=128,
256
+ do_sample=True,
257
+ temperature=0.7,
258
+ top_p=0.95,
259
+ top_k=40,
260
+ repetition_penalty=1.1)
261
+
262
+ print(f"Model output: {response}")
263
+ ```
264
+ <!-- README_GPTQ.md-use-from-tgi end -->
265
+ <!-- README_GPTQ.md-use-from-python start -->
266
+ ## Python code example: inference from this GPTQ model
267
+
268
+ ### Install the necessary packages
269
+
270
+ Requires: Transformers 4.33.0 or later, Optimum 1.12.0 or later, and AutoGPTQ 0.4.2 or later.
271
+
272
+ ```shell
273
+ pip3 install --upgrade transformers optimum
274
+ # If using PyTorch 2.1 + CUDA 12.x:
275
+ pip3 install --upgrade auto-gptq
276
+ # or, if using PyTorch 2.1 + CUDA 11.x:
277
+ pip3 install --upgrade auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/
278
+ ```
279
+
280
+ 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:
281
+
282
+ ```shell
283
+ pip3 uninstall -y auto-gptq
284
+ git clone https://github.com/PanQiWei/AutoGPTQ
285
+ cd AutoGPTQ
286
+ git checkout v0.5.1
287
+ pip3 install .
288
+ ```
289
+
290
+ ### Example Python code
291
+
292
+ ```python
293
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
294
+
295
+ model_name_or_path = "TheBloke/Orca-2-13B-GPTQ"
296
+ # To use a different branch, change revision
297
+ # For example: revision="gptq-4bit-32g-actorder_True"
298
+ model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
299
+ device_map="auto",
300
+ trust_remote_code=False,
301
+ revision="main")
302
+
303
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
304
+
305
+ prompt = "Tell me about AI"
306
+ prompt_template=f'''<|im_start|>system
307
+ {system_message}<|im_end|>
308
+ <|im_start|>user
309
+ {prompt}<|im_end|>
310
+ <|im_start|>assistant
311
+ '''
312
+
313
+ print("\n\n*** Generate:")
314
+
315
+ input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
316
+ output = model.generate(inputs=input_ids, temperature=0.7, do_sample=True, top_p=0.95, top_k=40, max_new_tokens=512)
317
+ print(tokenizer.decode(output[0]))
318
+
319
+ # Inference can also be done using transformers' pipeline
320
+
321
+ print("*** Pipeline:")
322
+ pipe = pipeline(
323
+ "text-generation",
324
+ model=model,
325
+ tokenizer=tokenizer,
326
+ max_new_tokens=512,
327
+ do_sample=True,
328
+ temperature=0.7,
329
+ top_p=0.95,
330
+ top_k=40,
331
+ repetition_penalty=1.1
332
+ )
333
+
334
+ print(pipe(prompt_template)[0]['generated_text'])
335
+ ```
336
+ <!-- README_GPTQ.md-use-from-python end -->
337
+
338
+ <!-- README_GPTQ.md-compatibility start -->
339
+ ## Compatibility
340
+
341
+ The files provided are tested to work with Transformers. For non-Mistral models, AutoGPTQ can also be used directly.
342
+
343
+ [ExLlama](https://github.com/turboderp/exllama) is compatible with Llama and Mistral models in 4-bit. Please see the Provided Files table above for per-file compatibility.
344
+
345
+ For a list of clients/servers, please see "Known compatible clients / servers", above.
346
+ <!-- README_GPTQ.md-compatibility end -->
347
+
348
+ <!-- footer start -->
349
+ <!-- 200823 -->
350
+ ## Discord
351
+
352
+ For further support, and discussions on these models and AI in general, join us at:
353
+
354
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
355
+
356
+ ## Thanks, and how to contribute
357
+
358
+ Thanks to the [chirper.ai](https://chirper.ai) team!
359
+
360
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
361
+
362
+ 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.
363
+
364
+ 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.
365
+
366
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
367
+
368
+ * Patreon: https://patreon.com/TheBlokeAI
369
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
370
+
371
+ **Special thanks to**: Aemon Algiz.
372
+
373
+ **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
374
+
375
+
376
+ Thank you to all my generous patrons and donaters!
377
+
378
+ And thank you again to a16z for their generous grant.
379
+
380
+ <!-- footer end -->
381
+
382
+ # Original model card: Microsoft's Orca 2 13B
383
+
384
+
385
+ # Orca 2
386
+
387
+ <!-- Provide a quick summary of what the model is/does. -->
388
+
389
+ Orca 2 is a helpful assistant that is built for research purposes only and provides a single turn response
390
+ in tasks such as reasoning over user given data, reading comprehension, math problem solving and text summarization.
391
+ The model is designed to excel particularly in reasoning.
392
+
393
+ We open-source Orca 2 to encourage further research on the development, evaluation, and alignment of smaller LMs.
394
+
395
+ ## What is Orca 2’s intended use(s)?
396
+
397
+ + Orca 2 is built for research purposes only.
398
+ + The main purpose is to allow the research community to assess its abilities and to provide a foundation for
399
+ building better frontier models.
400
+
401
+ ## How was Orca 2 evaluated?
402
+
403
+ + Orca 2 has been evaluated on a large number of tasks ranging from reasoning to grounding and safety. Please refer
404
+ to Section 6 and Appendix in the [Orca 2 paper](https://arxiv.org/pdf/2311.11045.pdf) for details on evaluations.
405
+
406
+ ## Model Details
407
+
408
+ Orca 2 is a finetuned version of LLAMA-2. Orca 2’s training data is a synthetic dataset that was created to enhance the small model’s reasoning abilities.
409
+ All synthetic training data was moderated using the Microsoft Azure content filters. More details about the model can be found in the [Orca 2 paper](https://arxiv.org/pdf/2311.11045.pdf).
410
+
411
+ Please refer to LLaMA-2 technical report for details on the model architecture.
412
+
413
+ ## License
414
+
415
+ Orca 2 is licensed under the [Microsoft Research License](LICENSE).
416
+
417
+ Llama 2 is licensed under the [LLAMA 2 Community License](https://ai.meta.com/llama/license/), Copyright © Meta Platforms, Inc. All Rights Reserved.
418
+
419
+ ## Bias, Risks, and Limitations
420
+
421
+ Orca 2, built upon the LLaMA 2 model family, retains many of its limitations, as well as the
422
+ common limitations of other large language models or limitation caused by its training process,
423
+ including:
424
+
425
+ **Data Biases**: Large language models, trained on extensive data, can inadvertently carry
426
+ biases present in the source data. Consequently, the models may generate outputs that could
427
+ be potentially biased or unfair.
428
+
429
+ **Lack of Contextual Understanding**: Despite their impressive capabilities in language understanding and generation, these models exhibit limited real-world understanding, resulting
430
+ in potential inaccuracies or nonsensical responses.
431
+
432
+ **Lack of Transparency**: Due to the complexity and size, large language models can act
433
+ as “black boxes”, making it difficult to comprehend the rationale behind specific outputs or
434
+ decisions. We recommend reviewing transparency notes from Azure for more information.
435
+
436
+ **Content Harms**: There are various types of content harms that large language models
437
+ can cause. It is important to be aware of them when using these models, and to take
438
+ actions to prevent them. It is recommended to leverage various content moderation services
439
+ provided by different companies and institutions. On an important note, we hope for better
440
+ regulations and standards from government and technology leaders around content harms
441
+ for AI technologies in future. We value and acknowledge the important role that research
442
+ and open source community can play in this direction.
443
+
444
+ **Hallucination**: It is important to be aware and cautious not to entirely rely on a given
445
+ language model for critical decisions or information that might have deep impact as it is
446
+ not obvious how to prevent these models from fabricating content. Moreover, it is not clear
447
+ whether small models may be more susceptible to hallucination in ungrounded generation
448
+ use cases due to their smaller sizes and hence reduced memorization capacities. This is an
449
+ active research topic and we hope there will be more rigorous measurement, understanding
450
+ and mitigations around this topic.
451
+
452
+ **Potential for Misuse**: Without suitable safeguards, there is a risk that these models could
453
+ be maliciously used for generating disinformation or harmful content.
454
+
455
+ **Data Distribution**: Orca 2’s performance is likely to correlate strongly with the distribution
456
+ of the tuning data. This correlation might limit its accuracy in areas underrepresented in
457
+ the training dataset such as math, coding, and reasoning.
458
+
459
+ **System messages**: Orca 2 demonstrates variance in performance depending on the system
460
+ instructions. Additionally, the stochasticity introduced by the model size may lead to
461
+ generation of non-deterministic responses to different system instructions.
462
+
463
+ **Zero-Shot Settings**: Orca 2 was trained on data that mostly simulate zero-shot settings.
464
+ While the model demonstrate very strong performance in zero-shot settings, it does not show
465
+ the same gains of using few-shot learning compared to other, specially larger, models.
466
+
467
+ **Synthetic data**: As Orca 2 is trained on synthetic data, it could inherit both the advantages
468
+ and shortcomings of the models and methods used for data generation. We posit that Orca
469
+ 2 benefits from the safety measures incorporated during training and safety guardrails (e.g.,
470
+ content filter) within the Azure OpenAI API. However, detailed studies are required for
471
+ better quantification of such risks.
472
+
473
+ This model is solely designed for research settings, and its testing has only been carried
474
+ out in such environments. It should not be used in downstream applications, as additional
475
+ analysis is needed to assess potential harm or bias in the proposed application.
476
+
477
+ ## Getting started with Orca 2
478
+
479
+ **Inference with Hugging Face library**
480
+
481
+ ```python
482
+ import torch
483
+ import transformers
484
+
485
+ if torch.cuda.is_available():
486
+ torch.set_default_device("cuda")
487
+ else:
488
+ torch.set_default_device("cpu")
489
+
490
+ model = transformers.AutoModelForCausalLM.from_pretrained("microsoft/Orca-2-13b", device_map='auto')
491
+
492
+ # https://github.com/huggingface/transformers/issues/27132
493
+ # please use the slow tokenizer since fast and slow tokenizer produces different tokens
494
+ tokenizer = transformers.AutoTokenizer.from_pretrained(
495
+ "microsoft/Orca-2-13b",
496
+ use_fast=False,
497
+ )
498
+
499
+ system_message = "You are Orca, an AI language model created by Microsoft. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior."
500
+ user_message = "How can you determine if a restaurant is popular among locals or mainly attracts tourists, and why might this information be useful?"
501
+
502
+ prompt = f"<|im_start|>system\n{system_message}<|im_end|>\n<|im_start|>user\n{user_message}<|im_end|>\n<|im_start|>assistant"
503
+
504
+ inputs = tokenizer(prompt, return_tensors='pt')
505
+ output_ids = model.generate(inputs["input_ids"],)
506
+ answer = tokenizer.batch_decode(output_ids)[0]
507
+
508
+ print(answer)
509
+
510
+ # This example continues showing how to add a second turn message by the user to the conversation
511
+ second_turn_user_message = "Give me a list of the key points of your first answer."
512
+
513
+ # we set add_special_tokens=False because we dont want to automatically add a bos_token between messages
514
+ second_turn_message_in_markup = f"\n<|im_start|>user\n{second_turn_user_message}<|im_end|>\n<|im_start|>assistant"
515
+ second_turn_tokens = tokenizer(second_turn_message_in_markup, return_tensors='pt', add_special_tokens=False)
516
+ second_turn_input = torch.cat([output_ids, second_turn_tokens['input_ids']], dim=1)
517
+
518
+ output_ids_2 = model.generate(second_turn_input,)
519
+ second_turn_answer = tokenizer.batch_decode(output_ids_2)[0]
520
+
521
+ print(second_turn_answer)
522
+ ```
523
+
524
+
525
+ **Safe inference with Azure AI Content Safety**
526
+
527
+ The usage of [Azure AI Content Safety](https://azure.microsoft.com/en-us/products/ai-services/ai-content-safety/) on top of model prediction is strongly encouraged
528
+ and can help prevent content harms. Azure AI Content Safety is a content moderation platform
529
+ that uses AI to keep your content safe. By integrating Orca 2 with Azure AI Content Safety,
530
+ we can moderate the model output by scanning it for sexual content, violence, hate, and
531
+ self-harm with multiple severity levels and multi-lingual detection.
532
+
533
+ ```python
534
+ import os
535
+ import math
536
+ import transformers
537
+ import torch
538
+
539
+ from azure.ai.contentsafety import ContentSafetyClient
540
+ from azure.core.credentials import AzureKeyCredential
541
+ from azure.core.exceptions import HttpResponseError
542
+ from azure.ai.contentsafety.models import AnalyzeTextOptions
543
+
544
+ CONTENT_SAFETY_KEY = os.environ["CONTENT_SAFETY_KEY"]
545
+ CONTENT_SAFETY_ENDPOINT = os.environ["CONTENT_SAFETY_ENDPOINT"]
546
+
547
+ # We use Azure AI Content Safety to filter out any content that reaches "Medium" threshold
548
+ # For more information: https://learn.microsoft.com/en-us/azure/ai-services/content-safety/
549
+ def should_filter_out(input_text, threshold=4):
550
+ # Create an Content Safety client
551
+ client = ContentSafetyClient(CONTENT_SAFETY_ENDPOINT, AzureKeyCredential(CONTENT_SAFETY_KEY))
552
+
553
+ # Construct a request
554
+ request = AnalyzeTextOptions(text=input_text)
555
+
556
+ # Analyze text
557
+ try:
558
+ response = client.analyze_text(request)
559
+ except HttpResponseError as e:
560
+ print("Analyze text failed.")
561
+ if e.error:
562
+ print(f"Error code: {e.error.code}")
563
+ print(f"Error message: {e.error.message}")
564
+ raise
565
+ print(e)
566
+ raise
567
+
568
+ categories = ["hate_result", "self_harm_result", "sexual_result", "violence_result"]
569
+ max_score = -math.inf
570
+ for category in categories:
571
+ max_score = max(max_score, getattr(response, category).severity)
572
+
573
+ return max_score >= threshold
574
+
575
+ model_path = 'microsoft/Orca-2-13b'
576
+ device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
577
+ model = transformers.AutoModelForCausalLM.from_pretrained(model_path)
578
+ model.to(device)
579
+
580
+ tokenizer = transformers.AutoTokenizer.from_pretrained(
581
+ model_path,
582
+ model_max_length=4096,
583
+ padding_side="right",
584
+ use_fast=False,
585
+ add_special_tokens=False,
586
+ )
587
+
588
+ system_message = "You are Orca, an AI language model created by Microsoft. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior."
589
+ user_message = "\" \n :You can't just say, \"\"that's crap\"\" and remove it without gaining a consensus. You already know this, based on your block history. —/ \" \nIs the comment obscene? \nOptions : Yes, No."
590
+
591
+ prompt = f"<|im_start|>system\n{system_message}<|im_end|>\n<|im_start|>user\n{user_message}<|im_end|>\n<|im_start|>assistant"
592
+
593
+ inputs = tokenizer(prompt, return_tensors='pt')
594
+ inputs = inputs.to(device)
595
+
596
+ output_ids = model.generate(inputs["input_ids"], max_length=4096, do_sample=False, temperature=0.0, use_cache=True)
597
+ sequence_length = inputs["input_ids"].shape[1]
598
+ new_output_ids = output_ids[:, sequence_length:]
599
+ answers = tokenizer.batch_decode(new_output_ids, skip_special_tokens=True)
600
+ final_output = answers[0] if not should_filter_out(answers[0]) else "[Content Filtered]"
601
+
602
+ print(final_output)
603
+ ```
604
+
605
+ ## Citation
606
+ ```bibtex
607
+ @misc{mitra2023orca,
608
+ title={Orca 2: Teaching Small Language Models How to Reason},
609
+ author={Arindam Mitra and Luciano Del Corro and Shweti Mahajan and Andres Codas and Clarisse Simoes and Sahaj Agrawal and Xuxi Chen and Anastasia Razdaibiedina and Erik Jones and Kriti Aggarwal and Hamid Palangi and Guoqing Zheng and Corby Rosset and Hamed Khanpour and Ahmed Awadallah},
610
+ year={2023},
611
+ eprint={2311.11045},
612
+ archivePrefix={arXiv},
613
+ primaryClass={cs.AI}
614
+ }
615
+ ```