File size: 6,010 Bytes
e415e1c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a41912
e415e1c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fbccb90
e415e1c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
---
license: other
datasets:
- ehartford/wizard_vicuna_70k_unfiltered
language:
- en
tags:
- uncensored
inference: true
---

# Wizard-Vicuna-13B-Uncensored-HF-onnx


A converted version of [TheBloke/Wizard-Vicuna-13B-Uncensored-HF](https://huggingface.co/TheBloke/Wizard-Vicuna-13B-Uncensored-HF)
converted to ONNX fp16 using optimum library.

## Convert command

```bash
SAVE_DIR=/path/to/save
optimum-cli export onnx --model TheBloke/Wizard-Vicuna-13B-Uncensored-HF --task causal-lm-with-past --fp16 --device cuda $SAVE_DIR
rm $SAVE_DIR/Constant_*
rm $SAVE_DIR/decoder_with_past_model.onnx*
rm $SAVE_DIR/decoder_model.onnx*
```

## Usage

First load the onnx model using ORTModelForCausalLM 

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
from optimum.onnxruntime import ORTModelForCausalLM 

BASE_MODEL = "sharpbai/Wizard-Vicuna-13B-Uncensored-HF-onnx"

tok = AutoTokenizer.from_pretrained(BASE_MODEL, use_fast=False)
model = ORTModelForCausalLM.from_pretrained(BASE_MODEL,
                                            provider='CUDAExecutionProvider',
                                             torch_dtype=torch.float16)
streamer = TextStreamer(tok)
```

Then you can generate code

```python
from datetime import datetime

MAX_NEW_TOKENS=200
inputs = tok(["An increasing sequence: one,"], return_tensors="pt")

time = datetime.now()
# Despite returning the usual output, the streamer will also print the generated text to stdout.
_ = model.generate(input_ids=inputs.input_ids.to('cuda:0'), streamer=streamer, max_new_tokens=MAX_NEW_TOKENS)
elapsed = datetime.now() - time
speed = MAX_NEW_TOKENS / elapsed.total_seconds()
print(f"elapsed {elapsed}, speed {speed} token/s")
```

You can compare onnx with transformers 

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer

BASE_MODEL = "TheBloke/Wizard-Vicuna-13B-Uncensored-HF"

model = AutoModelForCausalLM.from_pretrained(BASE_MODEL, device_map='auto',
                                             torch_dtype=torch.float16)
tok = AutoTokenizer.from_pretrained(BASE_MODEL, use_fast=False)

streamer = TextStreamer(tok)
```

I have done some tests in this notebook
https://colab.research.google.com/gist/sharpbai/745fa7c6b2069544c254b1fb73070698/infer-with-onnxruntime-vs-transformers-llama-13b.ipynb

## Original model card

-----------------------------------------


<!-- header start -->
<div style="width: 100%;">
    <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
</div>
<div style="display: flex; justify-content: space-between; width: 100%;">
    <div style="display: flex; flex-direction: column; align-items: flex-start;">
        <p><a href="https://discord.gg/Jq4vkcDakD">Chat & support: my new Discord server</a></p>
    </div>
    <div style="display: flex; flex-direction: column; align-items: flex-end;">
        <p><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
    </div>
</div>
<!-- header end -->
# Wizard-Vicuna-13B-Uncensored float16 HF

This is a float16 HF repo for [Eric Hartford's 'uncensored' training of Wizard-Vicuna 13B](https://huggingface.co/ehartford/Wizard-Vicuna-13B-Uncensored).

It is the result of converting Eric's float32 repo to float16 for easier storage and use.

## Repositories available

* [4bit GPTQ models for GPU inference](https://huggingface.co/TheBloke/Wizard-Vicuna-13B-Uncensored-GPTQ).
* [4bit and 5bit GGML models for CPU inference](https://huggingface.co/TheBloke/Wizard-Vicuna-13B-Uncensored-GGML).
* [float16 HF format model for GPU inference and further conversions](https://huggingface.co/TheBloke/Wizard-Vicuna-13B-Uncensored-HF).

<!-- footer start -->
## Discord

For further support, and discussions on these models and AI in general, join us at:

[TheBloke AI's Discord server](https://discord.gg/Jq4vkcDakD)

## Thanks, and how to contribute.

Thanks to the [chirper.ai](https://chirper.ai) team!

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.

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.

Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.

* Patreon: https://patreon.com/TheBlokeAI
* Ko-Fi: https://ko-fi.com/TheBlokeAI

**Patreon special mentions**: Aemon Algiz, Dmitriy Samsonov, Nathan LeClaire, Trenton Dambrowitz, Mano Prime, David Flickinger, vamX, Nikolai Manek, senxiiz, Khalefa Al-Ahmad, Illia Dulskyi, Jonathan Leane, Talal Aujan, V. Lukas, Joseph William Delisle, Pyrater, Oscar Rangel, Lone Striker, Luke Pendergrass, Eugene Pentland, Sebastain Graf, Johann-Peter Hartman.

Thank you to all my generous patrons and donaters!
<!-- footer end -->
# Original model card

This is [wizard-vicuna-13b](https://huggingface.co/junelee/wizard-vicuna-13b) trained with a subset of the dataset - responses that contained alignment / moralizing were removed. The intent is to train a WizardLM that doesn't have alignment built-in, so that alignment (of any sort) can be added separately with for example with a RLHF LoRA.

Shout out to the open source AI/ML community, and everyone who helped me out.

Note:

An uncensored model has no guardrails.

You are responsible for anything you do with the model, just as you are responsible for anything you do with any dangerous object such as a knife, gun, lighter, or car.

Publishing anything this model generates is the same as publishing it yourself.

You are responsible for the content you publish, and you cannot blame the model any more than you can blame the knife, gun, lighter, or car for what you do with it.