Views
No views yet
Transformerstransformers below. Make sure you have installed the latest transformers version (>4.40).1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3device = "cuda" # the device to load the model onto
4
5model = AutoModelForCausalLM.from_pretrained(
6 "SeaLLMs/SeaLLMs-v3-7B-Chat", # can change to "SeaLLMs/SeaLLMs-v3-1.5B-Chat" if your resource is limited
7 torch_dtype=torch.bfloat16,
8 device_map=device
9)
10tokenizer = AutoTokenizer.from_pretrained("SeaLLMs/SeaLLMs-v3-7B-Chat")
11
12# prepare messages to model
13prompt = "Hiii How are you?"
14messages = [
15 {"role": "system", "content": "You are a helpful assistant."},
16 {"role": "user", "content": prompt}
17]
18
19text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
20model_inputs = tokenizer([text], return_tensors="pt").to(device)
21print(f"Formatted text:\n {text}")
22print(f"Model input:\n {model_inputs}")
23
24generated_ids = model.generate(model_inputs.input_ids, max_new_tokens=512, do_sample=True, eos_token_id=tokenizer.eos_token_id)
25generated_ids = [
26 output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
27]
28response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
29
30print(f"Response:\n {response[0]}")TextStreamer to enable the model to continue conversing with you:1from transformers import AutoModelForCausalLM, AutoTokenizer
2from transformers import TextStreamer
3
4device = "cuda" # the device to load the model onto
5
6model = AutoModelForCausalLM.from_pretrained(
7 "SeaLLMs/SeaLLMs-v3-7B-Chat", # can change to "SeaLLMs/SeaLLMs-v3-1.5B-Chat" if your resource is limited
8 torch_dtype=torch.bfloat16,
9 device_map=device
10)
11tokenizer = AutoTokenizer.from_pretrained("SeaLLMs/SeaLLMs-v3-7B-Chat")
12
13# prepare messages to model
14messages = [
15 {"role": "system", "content": "You are a helpful assistant."},
16]
17
18while True:
19 prompt = input("User:")
20 messages.append({"role": "user", "content": prompt})
21 text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
22 model_inputs = tokenizer([text], return_tensors="pt").to(device)
23
24 streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
25 generated_ids = model.generate(model_inputs.input_ids, max_new_tokens=512, streamer=streamer)
26 generated_ids = [
27 output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
28 ]
29 response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
30 messages.append({"role": "assistant", "content": response})vllmpip install vllm.1from vllm import LLM, SamplingParams
2
3prompts = [
4 "Who is the president of US?",
5 "Can you speak Indonesian?"
6]
7
8llm = LLM(ckpt_path, dtype="bfloat16")
9sparams = SamplingParams(temperature=0.1, max_tokens=512)
10outputs = llm.generate(prompts, sparams)
11
12# print out the model response
13for output in outputs:
14 prompt = output.prompt
15 generated_text = output.outputs[0].text
16 print(f"Prompt: {prompt}\nResponse: {generated_text}\n\n")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.
| Model | en | zh | id | th | vi | avg | avg_sea |
|---|---|---|---|---|---|---|---|
| Sailor-7B-Chat | 0.66 | 0.652 | 0.475 | 0.462 | 0.513 | 0.552 | 0.483 |
| gemma-7b | 0.732 | 0.519 | 0.475 | 0.46 | 0.594 | 0.556 | 0.510 |
| SeaLLM-7B-v2.5 | 0.758 | 0.581 | 0.499 | 0.502 | 0.622 | 0.592 | 0.541 |
| Qwen2-7B | 0.815 | 0.874 | 0.53 | 0.479 | 0.628 | 0.665 | 0.546 |
| Qwen2-7B-Instruct | 0.809 | 0.88 | 0.558 | 0.555 | 0.624 | 0.685 | 0.579 |
| Sailor-14B | 0.748 | 0.84 | 0.536 | 0.528 | 0.621 | 0.655 | 0.562 |
| Sailor-14B-Chat | 0.749 | 0.843 | 0.553 | 0.566 | 0.637 | 0.67 | 0.585 |
| SeaLLMs-v3-7B | 0.809 | 0.863 | 0.545 | 0.530 | 0.628 | 0.675 | 0.568 |
| SeaLLMs-v3-7B-Chat | 0.809 | 0.874 | 0.558 | 0.569 | 0.649 | 0.692 | 0.592 |
| model | id turn1 | id turn2 | id avg | th turn1 | th turn2 | th avg | vi turn1 | vi turn2 | vi avg | avg |
|---|---|---|---|---|---|---|---|---|---|---|
| Qwen2-7B-Instruct | 5.93 | 5.84 | 5.89 | 5.47 | 5.20 | 5.34 | 6.17 | 5.60 | 5.89 | 5.70 |
| SeaLLM-7B-v2.5 | 6.27 | 4.96 | 5.62 | 5.79 | 3.82 | 4.81 | 6.02 | 4.02 | 5.02 | 5.15 |
| Sailor-14B-Chat | 5.26 | 5.53 | 5.40 | 4.62 | 4.36 | 4.49 | 5.31 | 4.74 | 5.03 | 4.97 |
| Sailor-7B-Chat | 4.60 | 4.04 | 4.32 | 3.94 | 3.17 | 3.56 | 4.82 | 3.62 | 4.22 | 4.03 |
| SeaLLMs-v3-7B-Chat | 6.73 | 6.59 | 6.66 | 6.48 | 5.90 | 6.19 | 6.34 | 5.79 | 6.07 | 6.31 |
| MGSM | en | id | ms | th | vi | zh | avg |
|---|---|---|---|---|---|---|---|
| Sailor-7B-Chat | 33.6 | 22.4 | 22.4 | 21.6 | 25.2 | 29.2 | 25.7 |
| Meta-Llama-3-8B-Instruct | 77.6 | 48 | 57.6 | 56 | 46.8 | 58.8 | 57.5 |
| glm-4-9b-chat | 72.8 | 53.6 | 53.6 | 34.8 | 52.4 | 70.8 | 56.3 |
| Qwen1.5-7B-Chat | 64 | 34.4 | 38.4 | 25.2 | 36 | 53.6 | 41.9 |
| Qwen2-7B-instruct | 82 | 66.4 | 62.4 | 58.4 | 64.4 | 76.8 | 68.4 |
| aya-23-8B | 28.8 | 16.4 | 14.4 | 2 | 16 | 12.8 | 15.1 |
| gemma-1.1-7b-it | 58.8 | 32.4 | 34.8 | 31.2 | 39.6 | 35.2 | 38.7 |
| SeaLLMs-7B-v2.5 | 79.6 | 69.2 | 70.8 | 61.2 | 66.8 | 62.4 | 68.3 |
| SeaLLMs-v3-7B-Chat | 74.8 | 71.2 | 70.8 | 71.2 | 71.2 | 79.6 | 73.1 |
| model | en | id | jv | km | lo | ms | my | ta | th | tl | vi | zh | avg |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Meta-Llama-3-8B-Instruct | 51.54 | 49.03 | 22.46 | 15.34 | 5.42 | 46.72 | 21.24 | 32.09 | 35.75 | 40.8 | 39.31 | 14.87 | 31.22 |
| Qwen2-7B-Instruct | 50.36 | 47.55 | 29.36 | 19.26 | 11.06 | 42.43 | 19.33 | 20.04 | 36.07 | 37.91 | 39.63 | 22.87 | 31.32 |
| Sailor-7B-Chat | 49.4 | 49.78 | 28.33 | 2.68 | 6.85 | 47.75 | 5.35 | 18.23 | 38.92 | 29 | 41.76 | 20.87 | 28.24 |
| SeaLLM-7B-v2.5 | 55.09 | 53.71 | 18.13 | 18.09 | 15.53 | 51.33 | 19.71 | 26.1 | 40.55 | 45.58 | 44.56 | 24.18 | 34.38 |
| SeaLLMs-v3-7B-Chat | 54.68 | 52.52 | 29.86 | 27.3 | 26.34 | 45.04 | 21.54 | 31.93 | 41.52 | 38.51 | 43.78 | 26.1 | 36.52 |
| Refusal-F1 Scores | en | zh | vi | th | id | avg |
|---|---|---|---|---|---|---|
| Qwen1.5-7B-Instruct | 53.85 | 51.70 | 52.85 | 35.50 | 58.40 | 50.46 |
| Qwen2-7B-Instruct | 58.79 | 33.08 | 56.21 | 44.60 | 55.98 | 49.73 |
| SeaLLM-7B-v2.5 | 12.90 | 0.77 | 2.45 | 19.42 | 0.78 | 7.26 |
| Sailor-7B-Chat | 33.49 | 18.82 | 5.19 | 9.68 | 16.42 | 16.72 |
| glm-4-9b-chat | 44.48 | 37.89 | 18.66 | 4.27 | 1.97 | 21.45 |
| Llama-3-8B-Instruct | 72.08 | 0.00 | 1.23 | 0.80 | 3.91 | 15.60 |
| gemma-1.1-7b-it | 52.39 | 27.74 | 23.96 | 22.97 | 31.72 | 31.76 |
| SeaLLMs-v3-7B-Chat | 71.36 | 78.39 | 77.93 | 61.31 | 68.95 | 71.59 |
| Model | en | jv | th | vi | zh | avg |
|---|---|---|---|---|---|---|
| Qwen2-7B-Instruct | 88.57 | 43.81 | 63.81 | 73.02 | 87.30 | 71.30 |
| Sailor-7B-Chat | 78.73 | 54.92 | 62.22 | 67.62 | 76.19 | 67.94 |
| Meta-Llama-3-8B-Instruct | 88.25 | 26.35 | 71.11 | 69.84 | 77.14 | 66.54 |
| Sailor-14B-Chat | 86.98 | 30.48 | 53.65 | 60.95 | 72.70 | 60.95 |
| glm-4-9b-chat | 77.14 | 21.27 | 30.16 | 60.63 | 74.92 | 52.82 |
| SeaLLMs-v3-7B-Chat | 88.89 | 60.00 | 73.33 | 83.81 | 92.70 | 79.75 |
@article{damonlp2024seallm3,
author = {Wenxuan Zhang*, Hou Pong Chan*, Yiran Zhao*, Mahani Aljunied*,
Jianyu Wang*, Chaoqun Liu, Yue Deng, Zhiqiang Hu, Weiwen Xu,
Yew Ken Chia, Xin Li, Lidong Bing},
title = {SeaLLMs 3: Open Foundation and Chat Multilingual Large Language Models for Southeast Asian Languages},
year = {2024},
url = {https://arxiv.org/abs/2407.19672}
}