munish0838
commited on
Commit
•
0565f04
1
Parent(s):
4ba09c4
Update README.md
Browse files
README.md
CHANGED
@@ -25,6 +25,11 @@ We introduce [SeaLLM-7B-v2](https://huggingface.co/SeaLLMs/SeaLLM-7B-v2), the st
|
|
25 |
* It achieves **7.54** score on the 🇬🇧 **MT-bench**, it ranks 3rd place on the leaderboard for 7B category and is the most outperforming multilingual model.
|
26 |
* It scores **45.74** on the VMLU benchmark for Vietnamese 🇻🇳, and is the only open-source multilingual model that can be competitive to monolingual models ([Vistral-7B](https://huggingface.co/Viet-Mistral/Vistral-7B-Chat)) of similar sizes.
|
27 |
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
<blockquote style="color:red">
|
30 |
<p><strong style="color: red">Terms of Use and License</strong>:
|
@@ -36,3 +41,293 @@ By using our released weights, codes, and demos, you agree to and comply with th
|
|
36 |
> 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.
|
37 |
> 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.
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
* It achieves **7.54** score on the 🇬🇧 **MT-bench**, it ranks 3rd place on the leaderboard for 7B category and is the most outperforming multilingual model.
|
26 |
* It scores **45.74** on the VMLU benchmark for Vietnamese 🇻🇳, and is the only open-source multilingual model that can be competitive to monolingual models ([Vistral-7B](https://huggingface.co/Viet-Mistral/Vistral-7B-Chat)) of similar sizes.
|
27 |
|
28 |
+
### Release and DEMO
|
29 |
+
|
30 |
+
- DEMO: [SeaLLMs/SeaLLM-7B](https://huggingface.co/spaces/SeaLLMs/SeaLLM-7B).
|
31 |
+
- Technical report: [Arxiv: SeaLLMs - Large Language Models for Southeast Asia](https://arxiv.org/pdf/2312.00738.pdf).
|
32 |
+
- Model weights: [SeaLLM-7B-v2](https://huggingface.co/SeaLLMs/SeaLLM-7B-v2).
|
33 |
|
34 |
<blockquote style="color:red">
|
35 |
<p><strong style="color: red">Terms of Use and License</strong>:
|
|
|
41 |
> 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.
|
42 |
> 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.
|
43 |
|
44 |
+
|
45 |
+
|
46 |
+
### What's new since SeaLLM-13B-v1 and SeaLLM-7B-v1?
|
47 |
+
|
48 |
+
* SeaLLM-7B-v2 is continue-pretrained from [Mistral-7B](https://huggingface.co/mistralai/Mistral-7B-v0.1) and underwent carefully designed tuning with focus in reasoning.
|
49 |
+
|
50 |
+
|
51 |
+
## Evaluation
|
52 |
+
|
53 |
+
|
54 |
+
### Zero-shot CoT Multilingual Math Reasoning
|
55 |
+
|
56 |
+
[SeaLLM-7B-v2](https://huggingface.co/SeaLLMs/SeaLLM-7B-v2) achieves with **78.2** score on the GSM8K with zero-shot CoT reasoning, making it the **state of the art** in the realm of 7B models. It also outperforms GPT-3.5 in the same GSM8K benchmark as translated into SEA languages (🇨🇳 🇻🇳 🇮🇩 🇹🇭). [SeaLLM-7B-v2](https://huggingface.co/SeaLLMs/SeaLLM-7B-v2) also surpasses GPT-3.5 on the Thai-translated MATH benchmark, with **22.4** vs 18.1 scores.
|
57 |
+
|
58 |
+
![fig_sea_math_side_by_side.png](fig_sea_math_side_by_side.png)
|
59 |
+
|
60 |
+
|
61 |
+
<details>
|
62 |
+
<summary>See details on English and translated GSM8K and MATH with zero-shot reasoning</summary>
|
63 |
+
<br>
|
64 |
+
|
65 |
+
| Model | GSM8K<br>en | MATH<br>en | GSM8K<br>zh | MATH<br>zh | GSM8K<br>vi | MATH<br>vi | GSM8K<br>id | MATH<br>id | GSM8K<br>th | MATH<br>th
|
66 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
67 |
+
| GPT-3.5 | 80.8 | 34.1 | 48.2 | 21.5 | 55 | 26.5 | 64.3 | 26.4 | 35.8 | 18.1
|
68 |
+
| Qwen-14B-chat | 61.4 | 18.4 | 41.6 | 11.8 | 33.6 | 3.6 | 44.7 | 8.6 | 22 | 6
|
69 |
+
| Vistral-7b-chat | 48.2 | 12.5 | | | 48.7 | 3.1 | | | |
|
70 |
+
| Qwen1.5-7B-chat | 56.8 | 15.3 | 40 | 2.7 | 37.7 | 9 | 36.9 | 7.7 | 21.9 |
|
71 |
+
| SeaLLM-7B-v2 | 78.2 | 27.5 | 53.7 | 17.6 | 69.9 | 23.8 | 71.5 | 24.4 | 59.6 | 22.4
|
72 |
+
|
73 |
+
</details>
|
74 |
+
|
75 |
+
Baselines were evaluated using their respective chat-template and system prompts ([Qwen1.5-7B-chat](https://huggingface.co/Qwen/Qwen1.5-7B-Chat/blob/main/tokenizer_config.json), [Vistral](https://huggingface.co/Viet-Mistral/Vistral-7B-Chat)).
|
76 |
+
|
77 |
+
#### Zero-shot MGSM
|
78 |
+
|
79 |
+
[SeaLLM-7B-v2](https://huggingface.co/SeaLLMs/SeaLLM-7B-v2) also outperforms GPT-3.5 and Qwen-14B on the multilingual MGSM for Zh and Th.
|
80 |
+
|
81 |
+
| Model | MGSM-Zh | MGSM-Th
|
82 |
+
|-----| ----- | ---
|
83 |
+
| ChatGPT (reported) | 61.2 | 47.2
|
84 |
+
| Qwen-14B-chat | 59.6 | 28
|
85 |
+
| SeaLLM-7B-v2 | **64.8** | **62.4**
|
86 |
+
|
87 |
+
|
88 |
+
### Zero-shot Commonsense Reasoning
|
89 |
+
|
90 |
+
We compare [SeaLLM-7B-v2](https://huggingface.co/SeaLLMs/SeaLLM-7B-v2) with ChatGPT and Mistral-7B-instruct on various zero-shot commonsense benchmarks (Arc-Challenge, Winogrande and Hellaswag). We use the 2-stage technique in [(Kojima et al., 2023)](https://arxiv.org/pdf/2205.11916.pdf) to grab the answer. Note that we **DID NOT** use "Let's think step-by-step" to invoke explicit CoT.
|
91 |
+
|
92 |
+
| 0-shot reasoning | Arc-Challenge | Winogrande | Hellaswag
|
93 |
+
|-----| ----- | --- | -- |
|
94 |
+
| ChatGPT (reported) | 84.6* | 66.8* | 72.0*
|
95 |
+
| ChatGPT (reproduced)| 84.1 | 63.1 | 79.5
|
96 |
+
| Mistral-7B-Instruct | 68.1 | 56.4 | 45.6
|
97 |
+
| Qwen1.5-7B-chat | 79.3 | 59.4 | 69.3
|
98 |
+
| SeaLLM-7B-v2 | 82.5 | 68.3 | 80.9
|
99 |
+
|
100 |
+
Baselines were evaluated using their respective chat-template and system prompts ([Qwen1.5-7B-chat](https://huggingface.co/Qwen/Qwen1.5-7B-Chat/blob/main/tokenizer_config.json), [Mistral](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1)).
|
101 |
+
|
102 |
+
### Multilingual World Knowledge
|
103 |
+
|
104 |
+
|
105 |
+
We evaluate models on 3 benchmarks following the recommended default setups: 5-shot MMLU for En, 3-shot [M3Exam](https://arxiv.org/pdf/2306.05179.pdf) (M3e) for En, Zh, Vi, Id, Th, and zero-shot [VMLU](https://vmlu.ai/) for Vi.
|
106 |
+
|
107 |
+
| Model | Langs | En<br>MMLU | En<br>M3e | Zh<br>M3e | Vi<br>M3e | Vi<br>VMLU | Id<br>M3e | Th<br>M3e
|
108 |
+
|-----| ----- | --- | -- | ----- | ---- | --- | --- | --- |
|
109 |
+
| GPT-3.5 | Multi | 68.90 | 75.46 | 60.20 | 58.64 | 46.32 | 49.27 | 37.41
|
110 |
+
| Vistral-7B-chat | Mono | 56.86 | 67.00 | 44.56 | 54.33 | 50.03 | 36.49 | 25.27
|
111 |
+
| Qwen1.5-7B-chat | Multi | 61.00 | 52.07 | 81.96 | 43.38 | 45.02 | 24.29 | 20.25
|
112 |
+
| SeaLLM-7B-v2 | Multi | 61.89 | 70.91 | 55.43 | 51.15 | 45.74 | 42.25 | 35.52
|
113 |
+
|
114 |
+
|
115 |
+
VMLU reproduce script [here](https://github.com/DAMO-NLP-SG/SeaLLMs/blob/main/evaluation/vmlu/vmlu_run.py). Lm-eval was used to evaluate MMLU.
|
116 |
+
0-shot VMLU scores for baselines were evaluated using their respective chat-template and system prompts ([Qwen1.5-7B-chat](https://huggingface.co/Qwen/Qwen1.5-7B-Chat/blob/main/tokenizer_config.json)).
|
117 |
+
|
118 |
+
|
119 |
+
### MT-Bench
|
120 |
+
|
121 |
+
On the English [MT-bench](https://arxiv.org/abs/2306.05685) metric, SeaLLM-7B-v2 achieves **7.54** score on the MT-bench (3rd place on the leaderboard for 7B category), outperforms many 70B models and is arguably the only one that handles 10 SEA languages.
|
122 |
+
|
123 |
+
Refer to [mt_bench/seallm_7b_v2.jsonl](https://huggingface.co/SeaLLMs/SeaLLM-7B-v2/blob/main/evaluation/mt_bench/seallm_7b_v2.jsonl) for the MT-bench predictions of SeaLLM-7B-v2, and [here](https://github.com/lm-sys/FastChat/issues/3013#issue-2118685341) to reproduce it.
|
124 |
+
|
125 |
+
| Model | Access | Langs | MT-Bench
|
126 |
+
| --- | --- | --- | --- |
|
127 |
+
| GPT-4-turbo | closed | multi | 9.32
|
128 |
+
| GPT-4-0613 | closed | multi | 9.18
|
129 |
+
| Mixtral-8x7b (46B) | open | multi | 8.3
|
130 |
+
| Starling-LM-7B-alpha | open | mono (en) | 8.0
|
131 |
+
| OpenChat-3.5-7B | open | mono (en) | 7.81
|
132 |
+
| **SeaLLM-7B-v2** | **open** | **multi (10+)** | **7.54**
|
133 |
+
| [Qwen-14B](https://huggingface.co/Qwen/Qwen-14B-Chat) | open | multi | 6.96
|
134 |
+
| [Llama-2-70B](https://huggingface.co/meta-llama/Llama-2-70b-chat-hf) | open | mono (en) | 6.86
|
135 |
+
| Mistral-7B-instuct | open | mono (en) | 6.84
|
136 |
+
|
137 |
+
|
138 |
+
### Sea-Bench
|
139 |
+
|
140 |
+
Similar to MT-Bench, [Sea-bench](https://huggingface.co/datasets/SeaLLMs/Sea-bench) is a set of categorized instruction test sets to measure models' ability as an assistant that is specifically focused on 9 SEA languages, including non-Latin low-resource languages.
|
141 |
+
|
142 |
+
As shown, the huge improvements come from math-reasoning, reaching GPT-3.5 level of performance.
|
143 |
+
|
144 |
+
![fig_sea_bench_side_by_side.png](fig_sea_bench_side_by_side.png)
|
145 |
+
|
146 |
+
Refer to [sea_bench/seallm_7b_v2.jsonl](https://huggingface.co/SeaLLMs/SeaLLM-7B-v2/blob/main/evaluation/sea_bench/seallm_7b_v2.jsonl) for the Sea-bench predictions of SeaLLM-7B-v2.
|
147 |
+
|
148 |
+
|
149 |
+
### Usage
|
150 |
+
|
151 |
+
#### Instruction format
|
152 |
+
|
153 |
+
```python
|
154 |
+
prompt = """<|im_start|>system
|
155 |
+
You are a helpful assistant.</s><|im_start|>user
|
156 |
+
Hello world</s><|im_start|>assistant
|
157 |
+
Hi there, how can I help?</s>"""
|
158 |
+
|
159 |
+
# NOTE: previous commit has \n between </s> and <|im_start|>, that was incorrect!
|
160 |
+
# <|im_start|> is not a special token.
|
161 |
+
# Transformers chat_template should be consistent with vLLM format below.
|
162 |
+
|
163 |
+
# ! ENSURE 1 and only 1 bos `<s>` at the beginning of sequence
|
164 |
+
print(tokenizer.convert_ids_to_tokens(tokenizer.encode(prompt)))
|
165 |
+
|
166 |
+
'<s>', '▁<', '|', 'im', '_', 'start', '|', '>', 'system', '<0x0A>', 'You', '▁are', '▁a', '▁helpful', '▁assistant', '.', '</s>', '▁<', '|', 'im', '_', 'start', '|', '>', 'user', '<0x0A>', 'Hello', '▁world', '</s>', '▁<', '|', 'im', '_', 'start', '|', '>', 'ass', 'istant', '<0x0A>', 'Hi', '▁there', ',', '▁how', '▁can', '▁I', '▁help', '?', '</s>']
|
167 |
+
"""
|
168 |
+
```
|
169 |
+
|
170 |
+
#### Using transformers's chat_template
|
171 |
+
```python
|
172 |
+
|
173 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
174 |
+
|
175 |
+
device = "cuda" # the device to load the model onto
|
176 |
+
|
177 |
+
# use bfloat16 to ensure the best performance.
|
178 |
+
model = AutoModelForCausalLM.from_pretrained("SeaLLMs/SeaLLM-7B-v2", torch_dtype=torch.bfloat16, device_map=device)
|
179 |
+
tokenizer = AutoTokenizer.from_pretrained("SeaLLMs/SeaLLM-7B-v2")
|
180 |
+
|
181 |
+
messages = [
|
182 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
183 |
+
{"role": "user", "content": "Hello world"},
|
184 |
+
{"role": "assistant", "content": "Hi there, how can I help you today?"},
|
185 |
+
{"role": "user", "content": "Explain general relativity in details."}
|
186 |
+
]
|
187 |
+
|
188 |
+
encodeds = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True)
|
189 |
+
print(tokenizer.convert_ids_to_tokens(encodeds[0]))
|
190 |
+
# ['<s>', '▁<', '|', 'im', '_', 'start', '|', '>', 'system', '<0x0A>', 'You', '▁are', '▁a', '▁helpful', '▁assistant', '.', '</s>', '▁<', '|', 'im', '_', 'start', '|', '>', 'user', '<0x0A>', 'Hello', '▁world', '</s>', '▁<', '|', 'im', '_', 'start', '|', '>', 'ass', 'istant', '<0x0A>', 'Hi', '▁there', ',', '▁how', '▁can', '▁I', '▁help', '▁you', '▁today', '?', '</s>', '▁<', '|', 'im', '_', 'start', '|', '>', 'user', '<0x0A>', 'Ex', 'plain', '▁general', '▁rel', 'ativity', '▁in', '▁details', '.', '</s>', '▁<', '|', 'im', '_', 'start', '|', '>', 'ass', 'istant', '<0x0A>']
|
191 |
+
|
192 |
+
model_inputs = encodeds.to(device)
|
193 |
+
model.to(device)
|
194 |
+
|
195 |
+
generated_ids = model.generate(model_inputs, max_new_tokens=1000, do_sample=True, pad_token_id=tokenizer.pad_token_id)
|
196 |
+
decoded = tokenizer.batch_decode(generated_ids)
|
197 |
+
print(decoded[0])
|
198 |
+
|
199 |
+
```
|
200 |
+
|
201 |
+
#### Using vLLM
|
202 |
+
|
203 |
+
```python
|
204 |
+
from vllm import LLM, SamplingParams
|
205 |
+
TURN_TEMPLATE = "<|im_start|>{role}\n{content}</s>"
|
206 |
+
TURN_PREFIX = "<|im_start|>{role}\n"
|
207 |
+
|
208 |
+
# There is no \n between </s> and <|im_start|>.
|
209 |
+
|
210 |
+
def seallm_chat_convo_format(conversations, add_assistant_prefix: bool, system_prompt=None):
|
211 |
+
# conversations: list of dict with key `role` and `content` (openai format)
|
212 |
+
if conversations[0]['role'] != 'system' and system_prompt is not None:
|
213 |
+
conversations = [{"role": "system", "content": system_prompt}] + conversations
|
214 |
+
text = ''
|
215 |
+
for turn_id, turn in enumerate(conversations):
|
216 |
+
prompt = TURN_TEMPLATE.format(role=turn['role'], content=turn['content'])
|
217 |
+
text += prompt
|
218 |
+
if add_assistant_prefix:
|
219 |
+
prompt = TURN_PREFIX.format(role='assistant')
|
220 |
+
text += prompt
|
221 |
+
return text
|
222 |
+
|
223 |
+
sparams = SamplingParams(temperature=0.1, max_tokens=1024, stop=['</s>', '<|im_start|>'])
|
224 |
+
llm = LLM("SeaLLMs/SeaLLM-7B-v2", dtype="bfloat16")
|
225 |
+
|
226 |
+
message = "Explain general relativity in details."
|
227 |
+
prompt = seallm_chat_convo_format(message, True)
|
228 |
+
gen = llm.generate(prompt, sampling_params)
|
229 |
+
|
230 |
+
print(gen[0].outputs[0].text)
|
231 |
+
```
|
232 |
+
|
233 |
+
#### Fine-tuning SeaLLM-7B-v2
|
234 |
+
|
235 |
+
Should follow the chat format and accurately mask out source tokens. Here is an example.
|
236 |
+
|
237 |
+
```python
|
238 |
+
conversations = [
|
239 |
+
{"role": "system", "content": "You are helful assistant."},
|
240 |
+
{"role": "user", "content": "Hello world."},
|
241 |
+
{"role": "assistant", "content": "Hi there, how can I help?"},
|
242 |
+
{"role": "user", "content": "Tell me a joke."},
|
243 |
+
{"role": "assistant", "content": "Why don't scientists trust atoms? Because they make up everything."},
|
244 |
+
]
|
245 |
+
def seallm_7b_v2_tokenize_multi_turns(tokenizer, conversations, add_assistant_prefix=False):
|
246 |
+
"""
|
247 |
+
Inputs:
|
248 |
+
conversations: list of dict following openai format, eg
|
249 |
+
conversations = [
|
250 |
+
{"role": "system", "content": "You are helful assistant."},
|
251 |
+
{"role": "user", "content": "Hello world."},
|
252 |
+
{"role": "assistant", "content": "Hi there, how can I help?"},
|
253 |
+
{"role": "user", "content": "Tell me a joke."},
|
254 |
+
{"role": "assistant", "content": "Why don't scientists trust atoms? Because they make up everything."},
|
255 |
+
]
|
256 |
+
add_assistant_prefix: whether to add assistant_prefix, only for inference decoding
|
257 |
+
Outputs:
|
258 |
+
tokenize_output_sample, {
|
259 |
+
"input_ids": ...
|
260 |
+
"token_type_ids": 1 if train and 0 if masked out (not train)
|
261 |
+
}
|
262 |
+
During training, need to create a labels, with masked-out tokens = -100 to avoid loss computations.
|
263 |
+
labels = sample['input_ids'].clone()
|
264 |
+
labels[sample['token_type_ids'] == 0] = -100
|
265 |
+
"""
|
266 |
+
TURN_TEMPLATE = "<|im_start|>{role}\n{content}</s>"
|
267 |
+
TURN_PREFIX = "<|im_start|>{role}\n"
|
268 |
+
sample = None
|
269 |
+
assistant_prefix_len = None
|
270 |
+
for turn_id, turn in enumerate(conversations):
|
271 |
+
prompt = TURN_TEMPLATE.format(role=turn['role'], content=turn['content'])
|
272 |
+
turn_sample = tokenizer(
|
273 |
+
prompt, padding=False, truncation=False, verbose=False, add_special_tokens=False,
|
274 |
+
return_token_type_ids=True,
|
275 |
+
)
|
276 |
+
if turn['role'] == 'assistant':
|
277 |
+
if assistant_prefix_len is None:
|
278 |
+
assistant_prefix_len = len(tokenizer.encode(TURN_PREFIX.format(role=turn['role']), add_special_tokens=False))
|
279 |
+
turn_sample['token_type_ids'][assistant_prefix_len:] = [1] * (len(turn_sample['input_ids']) - assistant_prefix_len)
|
280 |
+
if sample is None:
|
281 |
+
sample = turn_sample
|
282 |
+
else:
|
283 |
+
for k in turn_sample.keys():
|
284 |
+
sample[k].extend(turn_sample[k])
|
285 |
+
if add_assistant_prefix:
|
286 |
+
assistant_prefix_sample = tokenizer(
|
287 |
+
TURN_PREFIX.format(role="assistant"), padding=False, truncation=False, verbose=False, add_special_tokens=False,
|
288 |
+
return_token_type_ids=True,
|
289 |
+
)
|
290 |
+
for k in sample.keys():
|
291 |
+
sample[k].extend(assistant_prefix_sample[k])
|
292 |
+
if tokenizer.add_bos_token:
|
293 |
+
sample['input_ids'] = [tokenizer.bos_token_id] + sample['input_ids']
|
294 |
+
sample['attention_mask'] = [1] + sample['attention_mask']
|
295 |
+
sample['token_type_ids'] = [sample['token_type_ids'][0]] + sample['token_type_ids']
|
296 |
+
return sample
|
297 |
+
|
298 |
+
# ! testing
|
299 |
+
sample = seallm_7b_v2_tokenize_multi_turns(tokenizer, conversations)
|
300 |
+
print(tokenizer.convert_ids_to_tokens(sample['input_ids']))
|
301 |
+
print(sample['token_type_ids'])
|
302 |
+
# ['<s>', '▁<', '|', 'im', '_', 'start', '|', '>', 'system', '<0x0A>', 'You', '▁are', '▁hel', 'ful', '▁assistant', '.', '</s>', '▁<', '|', 'im', '_', 'start', '|', '>', 'user', '<0x0A>', 'Hello', '▁world', '.', '</s>', '▁<', '|', 'im', '_', 'start', '|', '>', 'ass', 'istant', '<0x0A>', 'Hi', '▁there', ',', '▁how', '▁can', '▁I', '▁help', '?', '</s>', '▁<', '|', 'im', '_', 'start', '|', '>', 'user', '<0x0A>', 'Tell', '▁me', '▁a', '▁joke', '.', '</s>', '▁<', '|', 'im', '_', 'start', '|', '>', 'ass', 'istant', '<0x0A>', 'Why', '▁don', "'", 't', '▁scientists', '▁trust', '▁atoms', '?', '▁Because', '▁they', '▁make', '▁up', '▁everything', '.', '</s>']
|
303 |
+
# [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
304 |
+
|
305 |
+
|
306 |
+
|
307 |
+
```
|
308 |
+
|
309 |
+
|
310 |
+
## Acknowledgement to Our Linguists
|
311 |
+
|
312 |
+
We would like to express our special thanks to our professional and native linguists, Tantong Champaiboon, Nguyen Ngoc Yen Nhi and Tara Devina Putri, who helped build, evaluate, and fact-check our sampled pretraining and SFT dataset as well as evaluating our models across different aspects, especially safety.
|
313 |
+
|
314 |
+
## Citation
|
315 |
+
|
316 |
+
If you find our project useful, we hope you would kindly star our repo and cite our work as follows: Corresponding Author: [[email protected]](mailto:[email protected])
|
317 |
+
|
318 |
+
**Author list and order will change!**
|
319 |
+
|
320 |
+
* `*` and `^` are equal contributions.
|
321 |
+
|
322 |
+
```
|
323 |
+
@article{damonlpsg2023seallm,
|
324 |
+
author = {Xuan-Phi Nguyen*, Wenxuan Zhang*, Xin Li*, Mahani Aljunied*,
|
325 |
+
Zhiqiang Hu, Chenhui Shen^, Yew Ken Chia^, Xingxuan Li, Jianyu Wang,
|
326 |
+
Qingyu Tan, Liying Cheng, Guanzheng Chen, Yue Deng, Sen Yang,
|
327 |
+
Chaoqun Liu, Hang Zhang, Lidong Bing},
|
328 |
+
title = {SeaLLMs - Large Language Models for Southeast Asia},
|
329 |
+
year = 2023,
|
330 |
+
Eprint = {arXiv:2312.00738},
|
331 |
+
}
|
332 |
+
```
|
333 |
+
|