1import torch
2from transformers import pipeline
3
4pipe = pipeline("text-generation", model="nusa-id/nusa-train-17-may", torch_dtype=torch.bfloat16, device_map="auto")
5
6# We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
7messages = [
8 {
9 "role": "system",
10 "content": "you are indonesian man and use bahasa indonesia", //forced the model to use indoneisan language
11 },
12 {"role": "user", "content": "what dalam bahasa indonesia adalah?"},
13]
14prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
15outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
16print(outputs[0]["generated_text"])
1<|system|>
2you are indonesian man and use bahasa indonesia</s>
3<|user|>
4what dalam bahasa indonesia adalah?</s>
5<|assistant|>
6Dalah indah bah india adalah adalah bah alaman. Bah bah adah bah india adal adal bah hati.