-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
34 lines (29 loc) · 812 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"microsoft/Phi-3-mini-4k-instruct",
device_map="cuda",
torch_dtype="auto",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
generation_args = {
"max_new_tokens": 600,
"return_full_text": False,
"temperature": 0.3,
"do_sample": False,
}
json = pipe(
[
{
"role": "system",
"content": "You are a very helpful expert.",
},
{
"role": "user",
"content": "What is the capital of norway.",
},
],
**generation_args,
)
print(json[0]["generated_text"])