adding usage example
Browse files
README.md
CHANGED
@@ -71,3 +71,75 @@ Nous Hermes 2 on Mistral 7B DPO is the new flagship 7B Hermes! This model was DP
|
|
71 |
The model prior to DPO was trained on 1,000,000 instructions/chats of GPT-4 quality or better, primarily synthetic data as well as other high quality datasets, available from the repository [teknium/OpenHermes-2.5](https://huggingface.co/datasets/teknium/OpenHermes-2.5).
|
72 |
|
73 |
## Thank you to FluidStack for sponsoring compute for this model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
The model prior to DPO was trained on 1,000,000 instructions/chats of GPT-4 quality or better, primarily synthetic data as well as other high quality datasets, available from the repository [teknium/OpenHermes-2.5](https://huggingface.co/datasets/teknium/OpenHermes-2.5).
|
72 |
|
73 |
## Thank you to FluidStack for sponsoring compute for this model
|
74 |
+
|
75 |
+
## How to use
|
76 |
+
|
77 |
+
### Install the necessary packages
|
78 |
+
|
79 |
+
```bash
|
80 |
+
pip install --upgrade autoawq autoawq-kernels
|
81 |
+
```
|
82 |
+
|
83 |
+
### Example Python code
|
84 |
+
|
85 |
+
```python
|
86 |
+
from awq import AutoAWQForCausalLM
|
87 |
+
from transformers import AutoTokenizer, TextStreamer
|
88 |
+
|
89 |
+
model_path = "solidrust/Nous-Hermes-2-Mistral-7B-DPO-AWQ"
|
90 |
+
system_message = "You are Hermes, incarnated a powerful AI."
|
91 |
+
|
92 |
+
# Load model
|
93 |
+
model = AutoAWQForCausalLM.from_quantized(model_path,
|
94 |
+
fuse_layers=True)
|
95 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path,
|
96 |
+
trust_remote_code=True)
|
97 |
+
streamer = TextStreamer(tokenizer,
|
98 |
+
skip_prompt=True,
|
99 |
+
skip_special_tokens=True)
|
100 |
+
|
101 |
+
# Convert prompt to tokens
|
102 |
+
prompt_template = """\
|
103 |
+
<|im_start|>system
|
104 |
+
{system_message}<|im_end|>
|
105 |
+
<|im_start|>user
|
106 |
+
{prompt}<|im_end|>
|
107 |
+
<|im_start|>assistant"""
|
108 |
+
|
109 |
+
prompt = "You're standing on the surface of the Earth. "\
|
110 |
+
"You walk one mile south, one mile west and one mile north. "\
|
111 |
+
"You end up exactly where you started. Where are you?"
|
112 |
+
|
113 |
+
tokens = tokenizer(prompt_template.format(system_message=system_message,prompt=prompt),
|
114 |
+
return_tensors='pt').input_ids.cuda()
|
115 |
+
|
116 |
+
# Generate output
|
117 |
+
generation_output = model.generate(tokens,
|
118 |
+
streamer=streamer,
|
119 |
+
max_new_tokens=512)
|
120 |
+
|
121 |
+
```
|
122 |
+
|
123 |
+
### About AWQ
|
124 |
+
|
125 |
+
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.
|
126 |
+
|
127 |
+
AWQ models are currently supported on Linux and Windows, with NVidia GPUs only. macOS users: please use GGUF models instead.
|
128 |
+
|
129 |
+
It is supported by:
|
130 |
+
|
131 |
+
- [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
|
132 |
+
- [vLLM](https://github.com/vllm-project/vllm) - version 0.2.2 or later for support for all model types.
|
133 |
+
- [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
|
134 |
+
- [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later, from any code or client that supports Transformers
|
135 |
+
- [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
|
136 |
+
|
137 |
+
## Prompt template: ChatML
|
138 |
+
|
139 |
+
```plaintext
|
140 |
+
<|im_start|>system
|
141 |
+
{system_message}<|im_end|>
|
142 |
+
<|im_start|>user
|
143 |
+
{prompt}<|im_end|>
|
144 |
+
<|im_start|>assistant
|
145 |
+
```
|