macadeliccc
commited on
Commit
•
0e4af86
1
Parent(s):
f16b32d
Update README.md
Browse files
README.md
CHANGED
@@ -8,34 +8,12 @@ This model is part of a series of HQQ tests. I make no claims on the performance
|
|
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 =
|
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 |
```
|
|
|
8 |
This is a very extreme example of quantization.
|
9 |
|
10 |
```python
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
from hqq.engine.hf import HQQModelForCausalLM, AutoTokenizer
|
|
|
12 |
|
13 |
tokenizer = AutoTokenizer.from_pretrained('macadeliccc/Nous-Hermes-2-Mixtral-8x7B-DPO-HQQ', trust_remote_code=True)
|
14 |
+
model = HQQModelForCausalLM.from_pretrained(
|
15 |
"macadeliccc/Nous-Hermes-2-Mixtral-8x7B-DPO-HQQ",
|
16 |
torch_dtype=torch.float16,
|
17 |
device_map="auto"
|
18 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
```
|