-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
57 lines (49 loc) · 1.43 KB
/
main.py
File metadata and controls
57 lines (49 loc) · 1.43 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from transformers import pipeline
import torch
# https://huggingface.co/google/gemma-3-1b-it
MODEL = "google/gemma-3-1b-it"
pipe = pipeline(
"text-generation",
model=MODEL,
torch_dtype=torch.bfloat16,
)
messages = [
[
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."},
],
},
{
"role": "user",
"content": [
{"type": "text", "text": "소프트웨어 마에스트로에 관련된 시를 써줘"},
],
},
],
]
output = pipe(messages, max_new_tokens=50)
"""Expected output:
[
[
{
'generated_text': [
{
'role': 'system',
'content': [{'type': 'text', 'text': 'You are a helpful assistant.'}]
},
{
'role': 'user',
'content': [{'type': 'text', 'text': '소프트웨어 마에스트로에 관련된 시를 써줘'}]
},
{
'role': 'assistant',
'content': '## 소프트웨어 마에스트로\n\n어둠 속, 코드의 춤\n새로운 세계를 창조하는 예술가\n소프트웨어 마에스트로, 그 이름은\n세상의 지식으로 빚어낸 섬세'
}
]
}
]
]
"""
print(output[0][0]["generated_text"][2])