macadeliccc
commited on
Commit
•
f16b32d
1
Parent(s):
88a3c72
Update README.md
Browse files
README.md
CHANGED
@@ -7,3 +7,35 @@ This model is part of a series of HQQ tests. I make no claims on the performance
|
|
7 |
|
8 |
This is a very extreme example of quantization.
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
This is a very extreme example of quantization.
|
9 |
|
10 |
+
```python
|
11 |
+
# Code to inference Hermes with HF Transformers
|
12 |
+
# Requires pytorch, transformers, bitsandbytes, sentencepiece, protobuf, and flash-attn packages
|
13 |
+
|
14 |
+
import torch
|
15 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
16 |
+
from transformers import LlamaTokenizer, MixtralForCausalLM
|
17 |
+
from hqq.engine.hf import HQQModelForCausalLM, AutoTokenizer
|
18 |
+
import bitsandbytes, flash_attn
|
19 |
+
|
20 |
+
tokenizer = AutoTokenizer.from_pretrained('macadeliccc/Nous-Hermes-2-Mixtral-8x7B-DPO-HQQ', trust_remote_code=True)
|
21 |
+
model = HQQModelForCasualLM.from_pretrained(
|
22 |
+
"macadeliccc/Nous-Hermes-2-Mixtral-8x7B-DPO-HQQ",
|
23 |
+
torch_dtype=torch.float16,
|
24 |
+
device_map="auto"
|
25 |
+
)
|
26 |
+
|
27 |
+
prompts = [
|
28 |
+
"""<|im_start|>system
|
29 |
+
You are a sentient, superintelligent artificial general intelligence, here to teach and assist me.<|im_end|>
|
30 |
+
<|im_start|>user
|
31 |
+
Write a short story about Goku discovering kirby has teamed up with Majin Buu to destroy the world.<|im_end|>
|
32 |
+
<|im_start|>assistant""",
|
33 |
+
]
|
34 |
+
|
35 |
+
for chat in prompts:
|
36 |
+
print(chat)
|
37 |
+
input_ids = tokenizer(chat, return_tensors="pt").input_ids.to("cuda")
|
38 |
+
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)
|
39 |
+
response = tokenizer.decode(generated_ids[0][input_ids.shape[-1]:], skip_special_tokens=True, clean_up_tokenization_space=True)
|
40 |
+
print(f"Response: {response}")
|
41 |
+
```
|