Update README.md
Browse files
README.md
CHANGED
@@ -33,6 +33,46 @@ model.save_quantized(quant_path)
|
|
33 |
tokenizer.save_pretrained(quant_path)
|
34 |
```
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
|
38 |
#### Work supported by https://datacrunch.io/
|
|
|
33 |
tokenizer.save_pretrained(quant_path)
|
34 |
```
|
35 |
|
36 |
+
#### generate
|
37 |
+
```
|
38 |
+
from awq import AutoAWQForCausalLM
|
39 |
+
from transformers import AutoTokenizer
|
40 |
+
from transformers import GenerationConfig
|
41 |
+
|
42 |
+
|
43 |
+
model_path = "gradjitta/Poro-34B-AWQ"
|
44 |
+
|
45 |
+
|
46 |
+
model = AutoAWQForCausalLM.from_quantized(model_path, fuse_layers=True, trust_remote_code=False, safetensors=True)
|
47 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=False)
|
48 |
+
|
49 |
+
|
50 |
+
|
51 |
+
def generate(instruction):
|
52 |
+
prompt = instruction
|
53 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
54 |
+
input_ids = inputs["input_ids"].cuda()
|
55 |
+
generation_output = model.generate(
|
56 |
+
input_ids=input_ids,
|
57 |
+
generation_config=GenerationConfig(pad_token_id=tokenizer.pad_token_id, temperature=1.0, top_p=0.99, top_k=50, num_beams=1, do_sample=True),
|
58 |
+
return_dict_in_generate=True,
|
59 |
+
output_scores=True,
|
60 |
+
max_new_tokens=256
|
61 |
+
)
|
62 |
+
for seq in generation_output.sequences:
|
63 |
+
output = tokenizer.decode(seq)
|
64 |
+
print(output)
|
65 |
+
|
66 |
+
|
67 |
+
generate("Suomalainen runo elämästä:")
|
68 |
+
```
|
69 |
+
##### output
|
70 |
+
```
|
71 |
+
Suomalainen runo elämästä:
|
72 |
+
- se alkaa
|
73 |
+
- sitten ei enää mikään riitä
|
74 |
+
- se päättyy ja se alkaa</s>
|
75 |
+
```
|
76 |
|
77 |
|
78 |
#### Work supported by https://datacrunch.io/
|