Views
No views yet

The logo was generated by MidJourney
transformers==4.46.3.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3device = "cuda"
4
5model = AutoModelForCausalLM.from_pretrained(
6 'sail/Sailor2-20B-Chat',
7 torch_dtype=torch.bfloat16,
8 device_map="auto"
9)
10
11tokenizer = AutoTokenizer.from_pretrained('sail/Sailor2-20B-Chat')
12system_prompt= \
13'You are an AI assistant named Sailor2, created by Sea AI Lab. \
14As an AI assistant, you can answer questions in English, Chinese, and Southeast Asian languages \
15such as Burmese, Cebuano, Ilocano, Indonesian, Javanese, Khmer, Lao, Malay, Sundanese, Tagalog, Thai, Vietnamese, and Waray. \
16Your responses should be friendly, unbiased, informative, detailed, and faithful.'
17
18prompt = "Beri saya pengenalan singkat tentang model bahasa besar."
19# prompt = "Hãy cho tôi một giới thiệu ngắn gọn về mô hình ngôn ngữ lớn."
20# prompt = "ให้ฉันแนะนำสั้น ๆ เกี่ยวกับโมเดลภาษาขนาดใหญ่"
21
22messages = [
23 {"role": "system", "content": system_prompt},
24 {"role": "user", "content": prompt}
25]
26text = tokenizer.apply_chat_template(
27 messages,
28 tokenize=False,
29 add_generation_prompt=True
30)
31
32model_inputs = tokenizer([text], return_tensors="pt").to(device)
33input_ids = model_inputs.input_ids.to(device)
34
35generated_ids = model.generate(
36 input_ids,
37 max_new_tokens=512,
38)
39
40generated_ids = [
41 output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
42]
43response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
44print(response)@article{sailor2report,
title = {Sailor2: Sailing in South-East Asia with Inclusive Multilingual LLM},
author = {Longxu Dou and Qian Liu and Fan Zhou and Changyu Chen and Zili Wang and Ziqi Jin and Zichen Liu and Tongyao Zhu and Cunxiao Du and Penghui Yang and Haonan Wang and Jiaheng Liu and Yongchi Zhao and Xiachong Feng and Xin Mao and Man Tsung Yeung and Kunat Pipatanakul and Fajri Koto and Min Si Thu and Hynek Kydl{\'\i}{\v{c}}ek and Zeyi Liu and Qunshu Lin and Sittipong Sripaisarnmongkol and Kridtaphad Sae-Khow and Nirattisai Thongchim and Taechawat Konkaew and Narong Borijindargoon and Anh Dao and Matichon Maneegard and Phakphum Artkaew and Zheng-Xin Yong and Quan Nguyen and Wannaphong Phatthiyaphaibun and Hoang H. Tran and Mike Zhang and Shiqi Chen and Tianyu Pang and Chao Du and Xinyi Wan and Wei Lu and Min Lin},
journal={arXiv preprint arXiv:2502.12982},
year = {2025}
}