Views
No views yet

Terms of Use and License: By using our released weights, codes, and demos, you agree to and comply with the terms and conditions specified in our SeaLLMs Terms Of Use.
Disclaimer: We must note that even though the weights, codes, and demos are released in an open manner, similar to other pre-trained language models, and despite our best efforts in red teaming and safety fine-tuning and enforcement, our models come with potential risks, including but not limited to inaccurate, misleading or potentially harmful generation. Developers and stakeholders should perform their own red teaming and provide related security measures before deployment, and they must abide by and comply with local governance and regulations. In no event shall the authors be held liable for any claim, damages, or other liability arising from the use of the released weights, codes, or demos.
The logo was generated by DALL-E 3.
tokenizer.add_special_tokens = False.1
2BOS_TOKEN = '<s>'
3EOS_TOKEN = '</s>'
4
5B_INST, E_INST = "[INST]", "[/INST]"
6B_SYS, E_SYS = "<<SYS>>\n", "\n<</SYS>>\n\n"
7
8SYSTEM_PROMPT = """You are a multilingual, helpful, respectful and honest assistant. \
9Please always answer as helpfully as possible, while being safe. Your \
10answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure \
11that your responses are socially unbiased and positive in nature.
12
13If a question does not make any sense, or is not factually coherent, explain why instead of answering something not \
14correct. If you don't know the answer to a question, please don't share false information.
15
16As a multilingual assistant, you must respond and follow instructions in the native language of the user by default, unless told otherwise. \
17Your response should adapt to the norms and customs of the respective language and culture.
18"""
19
20
21def chat_multiturn_seq_format(
22 message: str,
23 history: List[Tuple[str, str]] = None,
24):
25 """
26 ```
27 <bos>[INST] B_SYS SytemPrompt E_SYS Prompt [/INST] Answer <eos>
28 <bos>[INST] Prompt [/INST] Answer <eos>
29 <bos>[INST] Prompt [/INST]
30 ```
31 As the format auto-add <bos>, please turn off add_special_tokens with `tokenizer.add_special_tokens = False`
32 Inputs:
33 message: the current prompt
34 history: list of list indicating previous conversation. [[message1, response1], [message2, response2]]
35 Outputs:
36 full_prompt: the prompt that should go into the chat model
37
38 e.g:
39 full_prompt = chat_multiturn_seq_format("Hello world")
40 output = model.generate(tokenizer.encode(full_prompt, add_special_tokens=False), ...)
41 """
42 text = ''
43 for i, (prompt, res) in enumerate(history):
44 if i == 0:
45 text += f"{bos_token}{B_INST} {B_SYS} {sys_prompt} {E_SYS} {prompt} {E_INST}"
46 else:
47 text += f"{bos_token}{B_INST} {prompt}{end_instr}"
48 if res is not None:
49 text += f" {res} {eos_token} "
50 if len(history) == 0 or text.strip() == '':
51 text = f"{bos_token}{B_INST} {B_SYS} {sys_prompt} {E_SYS} {message} {E_INST}"
52 else:
53 text += f"{bos_token}{B_INST} {message} {E_INST}"
54 return text
55
56@article{damonlpsg2023seallm,
author = {Xuan-Phi Nguyen*, Wenxuan Zhang*, Xin Li*, Mahani Aljunied*,
Qingyu Tan, Liying Cheng, Guanzheng Chen, Yue Deng, Sen Yang,
Chaoqun Liu, Hang Zhang, Lidong Bing},
title = {SeaLLMs - Large Language Models for Southeast Asia},
year = 2023,
Eprint = {arXiv:2312.00738},
}