File size: 847 Bytes
ad6fd18
f4957f0
ad6fd18
 
f4957f0
ad6fd18
f4957f0
ad6fd18
 
 
 
 
 
f4957f0
ad6fd18
 
 
 
f4957f0
ad6fd18
 
 
 
f4957f0
ad6fd18
 
 
 
 
 
f4957f0
 
ad6fd18
 
 
 
f4957f0
ad6fd18
 
 
 
f4957f0
ad6fd18
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
# Please use transformers==4.45.0

import torch
import transformers

model_id = "GoToCompany/gemma2-9b-cpt-sahabatai-v1-instruct"

pipeline = transformers.pipeline(
    "text-generation",
    model=model_id,
    model_kwargs={"torch_dtype": torch.bfloat16},
    device_map="auto",
)

terminators = [
    pipeline.tokenizer.eos_token_id,
    pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>")
]

# Javanese
messages = [
   {"role": "user", "content": "Sopo wae sing ana ing Punakawan?"}
]

outputs = pipeline(
    messages,
    max_new_tokens=256,
    eos_token_id=terminators,
)
print(outputs[0]["generated_text"][-1])


# Sundanese
messages = [
    {"role": "user", "content": "Kumaha caritana si Kabayan?"},
]

outputs = pipeline(
    messages,
    max_new_tokens=256,
    eos_token_id=terminators,
)
print(outputs[0]["generated_text"][-1])