AlexWortega
commited on
Commit
•
a87bee4
1
Parent(s):
5f4da50
Update README.md
Browse files
README.md
CHANGED
@@ -9,4 +9,33 @@ datasets:
|
|
9 |
|
10 |
# Veles Instruct
|
11 |
|
12 |
-
Просто лучшая русская инстракт модель
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# Veles Instruct
|
11 |
|
12 |
+
Просто лучшая русская инстракт модель
|
13 |
+
|
14 |
+
```python
|
15 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
16 |
+
import torch
|
17 |
+
model = AutoModelForCausalLM.from_pretrained("Vikhrmodels/Vikhr-7B-instruct_0.3",
|
18 |
+
device_map="auto",
|
19 |
+
attn_implementation="flash_attention_2",
|
20 |
+
torch_dtype=torch.bfloat16)
|
21 |
+
|
22 |
+
tokenizer = AutoTokenizer.from_pretrained("Vikhrmodels/Vikhr-7B-instruct_0.3",use_fast=False)
|
23 |
+
from transformers import AutoTokenizer, pipeline
|
24 |
+
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
25 |
+
prompts = [
|
26 |
+
"В чем разница между фруктом и овощем?",
|
27 |
+
"Годы жизни колмагорова?"]
|
28 |
+
|
29 |
+
def test_inference(prompt):
|
30 |
+
prompt = pipe.tokenizer.apply_chat_template([{"role": "user", "content": prompt}], tokenize=False, add_generation_prompt=True)
|
31 |
+
print(prompt)
|
32 |
+
outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95, eos_token_id=tokenizer.eos_token_id)
|
33 |
+
return outputs[0]['generated_text'][len(prompt):].strip()
|
34 |
+
|
35 |
+
|
36 |
+
for prompt in prompts:
|
37 |
+
print(f" prompt:\n{prompt}")
|
38 |
+
print(f" response:\n{test_inference(prompt)}")
|
39 |
+
print("-"*50)
|
40 |
+
|
41 |
+
```
|