itsankitkp
commited on
Commit
•
37149df
1
Parent(s):
1041e34
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,46 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Qwen2-0.5B-Instruct-awq
|
2 |
+
base_model: Qwen/Qwen2-0.5B-Instruct
|
3 |
+
|
4 |
+
Quantized version of Qwen2 model
|
5 |
+
|
6 |
+
Inference
|
7 |
+
```python
|
8 |
+
from awq import AutoAWQForCausalLM
|
9 |
+
from transformers import AutoTokenizer, TextStreamer
|
10 |
+
|
11 |
+
quant_path = "itsankitkp/Qwen2-0.5B-Instruct-awq"
|
12 |
+
|
13 |
+
# Load model
|
14 |
+
model = AutoAWQForCausalLM.from_quantized(quant_path, fuse_layers=True)
|
15 |
+
tokenizer = AutoTokenizer.from_pretrained(quant_path, trust_remote_code=True)
|
16 |
+
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
17 |
+
|
18 |
+
# Convert prompt to tokens
|
19 |
+
prompt_template = """\
|
20 |
+
<|system|>
|
21 |
+
</s>
|
22 |
+
<|user|>
|
23 |
+
{prompt}</s>
|
24 |
+
<|assistant|>"""
|
25 |
+
|
26 |
+
prompt = "You're standing on the surface of the Earth. "\
|
27 |
+
"You walk one mile south, one mile west and one mile north. "\
|
28 |
+
"You end up exactly where you started. Where are you?"
|
29 |
+
|
30 |
+
tokens = tokenizer(
|
31 |
+
prompt_template.format(prompt=prompt),
|
32 |
+
return_tensors='pt'
|
33 |
+
).input_ids.cuda()
|
34 |
+
|
35 |
+
# Generate output
|
36 |
+
generation_output = model.generate(
|
37 |
+
tokens,
|
38 |
+
streamer=streamer,
|
39 |
+
max_seq_len=512
|
40 |
+
)
|
41 |
+
```
|
42 |
+
|
43 |
+
|
44 |
+
---
|
45 |
+
license: mit
|
46 |
+
---
|