Text Generation
Transformers
Safetensors
apertus
conversational
waiyiaisg commited on
Commit
12aef3d
·
verified ·
1 Parent(s): 6cd9fa0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +37 -98
README.md CHANGED
@@ -32,7 +32,7 @@ SEA-LION is a collection of Large Language Models (LLMs) which have been pretrai
32
 
33
  **Apertus-SEA-LION-v4-8B-IT** is a 8-billion parameter model built upon the Apertus-8B-Instruct architecture. To ensure **domain adaptation** for the region, the model underwent rigorous post-training on a curated dataset of approximately **6.4 million** instruction-text pairs.
34
 
35
- This extensive post-training instills **multilingual** and **multicultural** fluency, covering key SEA languages such as Burmese, Malay, Tagalog and Tamil. This curated dataset also includes a filtered open sourced set of tool-calling instruction-text pairs to impart these capabilities, in addition to linguistic fluency.
36
 
37
  Apertus-SEA-LION-v4-8B-IT is designed as a fully open model to align with this core philosophy, we have released the datasets used for post-training, as well as the evaluation codes and datasets used to evaluate the model.
38
 
@@ -56,7 +56,7 @@ For tokenization, the model employs the default tokenizer used in Apertus-8B-Ins
56
  - **Shared by:** AI Products Pillar, AI Singapore
57
  - **Model type:** Decoder
58
  - **Context length:** 65k
59
- - **Language(s):** Fine-tuned on English, Burmese, Tagalog, Malay and Tamil
60
  - **License:** [Apache-2.0](https://choosealicense.com/licenses/apache-2.0/)
61
  - **Finetuned from model:** [Apertus-8B-Instruct](https://huggingface.co/swiss-ai/Apertus-8B-Instruct-2509)
62
 
@@ -79,63 +79,22 @@ The model has not been aligned for safety. Developers and users should perform t
79
  Use the code below to get started with the model with 🤗 Transformers libraries.
80
 
81
  ```
82
- pip install transformers>=4.56.0
83
-
84
- ```
85
-
86
- ```
87
- # The code is adopted from Apertus example
88
  from transformers import AutoModelForCausalLM, AutoTokenizer
89
 
90
- model_name = "aisingapore/Apertus-SEA-LION-v4-8B-IT"
91
- device = "cuda" # for GPU usage or "cpu" for CPU usage
92
 
93
- # load the tokenizer and the model
94
- tokenizer = AutoTokenizer.from_pretrained(model_name)
95
  model = AutoModelForCausalLM.from_pretrained(
96
- model_name,
97
- ).to(device)
98
-
99
- # prepare the model input
100
- prompt = "Explain the concept of 'Hari Raya Puasa' in simple terms."
101
- messages_think = [
102
- {"role": "user", "content": prompt}
103
- ]
104
-
105
- text = tokenizer.apply_chat_template(
106
- messages_think,
107
- tokenize=False,
108
- add_generation_prompt=True,
109
- )
110
- model_inputs = tokenizer([text], return_tensors="pt", add_special_tokens=False).to(model.device)
111
-
112
- # Generate the output
113
- generated_ids = model.generate(**model_inputs, max_new_tokens=32768)
114
-
115
- # Get and decode the output
116
- output_ids = generated_ids[0][len(model_inputs.input_ids[0]) :]
117
- print(tokenizer.decode(output_ids, skip_special_tokens=True))
118
- ```
119
-
120
- ## Tool Calling
121
-
122
-
123
- The prompt in the example is in Malay and translates to “Please help me find a 4-room flat near Tampines, budget under $500,000. I also want to know the estimated monthly loan payment.”
124
-
125
- ```
126
- import torch
127
- from transformers import AutoTokenizer, AutoModelForCausalLM
128
 
129
- model_id = "aisingapore/Apertus-SEA-LION-v4-8B-IT"
130
- tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
131
- model = AutoModelForCausalLM.from_pretrained(
132
- model_id,
133
- torch_dtype=torch.bfloat16,
134
- device_map="auto"
135
- )
136
 
137
  messages = [
138
- {"role": "user", "content": "Tolong carikan flat 4-bilik dekat Tampines, bajet bawah $500,000. Nak tahu juga berapa anggaran pinjaman bulanan."}
 
 
 
139
  ]
140
 
141
  tools = [
@@ -173,63 +132,43 @@ tools = [
173
  }
174
  ]
175
 
176
- input_ids = tokenizer.apply_chat_template(
177
- messages,
178
- tools=tools,
179
- return_tensors="pt",
180
- add_generation_prompt=True
181
  ).to(model.device)
182
 
183
- generated_ids = model.generate(
184
- input_ids,
185
- max_new_tokens=512,
186
- do_sample=False,
187
- )
188
 
189
- response = tokenizer.decode(
190
- generated_ids[0][input_ids.shape[1]:],
191
- skip_special_tokens=False,
192
- ).replace("<end_of_turn>", "").strip()
193
 
194
- print(response)
 
195
 
 
 
 
 
196
  ```
197
 
 
198
 
 
 
 
199
 
200
- ## Training Details
201
-
202
- ### Training Data
203
-
204
- The instruction fine-tuning text dataset comprises of a collection of OSS & synthetic data. The datasets used for post-training can be accessed via the link below.
205
-
206
- **Datasets for Instruction Fine Tuning**:
207
-
208
- - 🤗[aisingapore/SEA-Instruct-2602](https://huggingface.co/datasets/aisingapore/SEA-Instruct-2602)
209
-
210
- **Datasets for Tool-calling**:
211
-
212
- - 🤗[allenai/Dolci-Instruct-SFT-Tool-Use](https://huggingface.co/datasets/allenai/Dolci-Instruct-SFT-Tool-Use)
213
- - 🤗[Agent-Ark/Toucan-1.5M](https://huggingface.co/datasets/Agent-Ark/Toucan-1.5M)
214
 
215
- ### Training Procedure
216
 
217
- #### Training Hyperparameters
 
218
 
219
- - **Training regime:** Our post-training workflow consists of instruction fine-tuning and model merging.
220
- - **Training hyperparameters:** The following hyperparameters were used during training:
 
221
 
222
- | Category | Hyperparameter | Value |
223
- | --- | --- | --- |
224
- | **Optimization** | Optimizer | `ADAMW_TORCH_FUSED` (β1=0.9, β2=0.999, ε=1e-08) |
225
- | **Batch Size** | Train Batch Size (per device) | `1` |
226
- | | Eval Batch Size (per device) | `1` |
227
- | **Hardware** | Distributed Type | `multi-GPU` |
228
- | | Number of Devices | `64` |
229
- | **Schedule** | LR Scheduler Type | `constant_with_warmup` |
230
- | | LR Scheduler Warmup Steps | `269` |
231
- | **Other** | Training Steps | `5397` |
232
- | | Seed | `42` |
233
 
234
  ## Evaluation
235
 
@@ -245,7 +184,7 @@ For the evaluation of general language capabilities, we employed the [SEA-HELM e
245
 
246
  Instruction-following and Multi-turn Chat
247
 
248
- We evaluated the models on instruction-following and multi-turn chat capabilities with SEA-IFEval (based on [IFEval](https://arxiv.org/abs/2311.07911)) and SEA-MTBench (based on [MT-Bench](https://arxiv.org/abs/2306.05685)) respectively. The two datasets were originally in English, the linguists and native speakers in the team worked together to filter, localise and translate the datasets into the respective target languages to ensure that the examples remained reasonable, meaningful and natural.
249
 
250
  #### Factors
251
 
@@ -261,7 +200,7 @@ SEA-IFEval evaluates a model's ability to adhere to constraints provided in the
261
 
262
  SEA-MTBench
263
 
264
- SEA-MTBench evaluates a model's ability to engage in multi-turn (2 turns) conversations and respond in ways that align with human needs. We use `gpt-4.1-2025-04-14` as the judge model and compare against `gpt-4.1-2025-04-14` as the baseline model. The metric used is the weighted win rate against the baseline model (i.e. average win rate across each category: Math, Reasoning, STEM, Humanities, Roleplay, Writing, Extraction).
265
 
266
  #### Metrics
267
 
 
32
 
33
  **Apertus-SEA-LION-v4-8B-IT** is a 8-billion parameter model built upon the Apertus-8B-Instruct architecture. To ensure **domain adaptation** for the region, the model underwent rigorous post-training on a curated dataset of approximately **6.4 million** instruction-text pairs.
34
 
35
+ This extensive post-training instills **multilingual** and **multicultural** fluency, covering key SEA languages such as Indonesian, Vietnamese, Thai, Filipino, Tamil, Burmese, Malay. This curated dataset also includes a filtered open sourced set of tool-calling instruction-text pairs to impart these capabilities, in addition to linguistic fluency.
36
 
37
  Apertus-SEA-LION-v4-8B-IT is designed as a fully open model to align with this core philosophy, we have released the datasets used for post-training, as well as the evaluation codes and datasets used to evaluate the model.
38
 
 
56
  - **Shared by:** AI Products Pillar, AI Singapore
57
  - **Model type:** Decoder
58
  - **Context length:** 65k
59
+ - **Language(s):** Indonesian, Vietnamese, Thai, Filipino, Tamil, Burmese, Malay
60
  - **License:** [Apache-2.0](https://choosealicense.com/licenses/apache-2.0/)
61
  - **Finetuned from model:** [Apertus-8B-Instruct](https://huggingface.co/swiss-ai/Apertus-8B-Instruct-2509)
62
 
 
79
  Use the code below to get started with the model with 🤗 Transformers libraries.
80
 
81
  ```
82
+ import torch
 
 
 
 
 
83
  from transformers import AutoModelForCausalLM, AutoTokenizer
84
 
85
+ model_id = "aisingapore/Apertus-SEA-LION-v4-8B-IT"
 
86
 
 
 
87
  model = AutoModelForCausalLM.from_pretrained(
88
+ model_id, device_map="auto"
89
+ ).eval()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
 
 
 
 
 
 
92
 
93
  messages = [
94
+ {
95
+ "role": "user",
96
+ "content": "Any flats for sale in Tampines?"
97
+ }
98
  ]
99
 
100
  tools = [
 
132
  }
133
  ]
134
 
135
+ inputs = tokenizer.apply_chat_template(
136
+ messages, tools=tools, add_generation_prompt=True, tokenize=True,
137
+ return_dict=True, return_tensors="pt"
 
 
138
  ).to(model.device)
139
 
140
+ input_len = inputs["input_ids"].shape[-1]
 
 
 
 
141
 
142
+ with torch.inference_mode():
143
+ generation = model.generate(**inputs, max_new_tokens=512, do_sample=False)
144
+ generation = generation[0][input_len:]
 
145
 
146
+ decoded = tokenizer.decode(generation, skip_special_tokens=True)
147
+ print(decoded)
148
 
149
+ # I'll search for HDB flats available for sale in Tampines. Let me check the listings for you.
150
+ # <tool_call>
151
+ # {"name": "search_hdb_listings", "arguments": {"location": "Tampines", "flat_type": "3-room", "max_price": 500000}}
152
+ # </tool_call>
153
  ```
154
 
155
+ ## Vllm Model Serving
156
 
157
+ ```
158
+ vllm serve aisingapore/Apertus-SEA-LION-v4-8B-IT --enable-auto-tool-choice --tool-call-parser hermes
159
+ ```
160
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
 
162
+ ## Training Details
163
 
164
+ **Training Datasets**:
165
+ The instruction fine-tuning text dataset comprises of a collection of OSS & synthetic data. The datasets used for Post Training can be accessed via the link below.
166
 
167
+ - 🤗[aisingapore/SEA-Instruct-2602](https://huggingface.co/datasets/aisingapore/SEA-Instruct-2602) (Only for ms, my, ta, fil)
168
+ - 🤗[allenai/Dolci-Instruct-SFT](https://huggingface.co/datasets/allenai/Dolci-Instruct-SFT) (Filtered for invalid conversations)
169
+ - 🤗[Agent-Ark/Toucan-1.5M](https://huggingface.co/datasets/Agent-Ark/Toucan-1.5M) (SFT Subset)
170
 
171
+ **Training Regime:** Our Post Training workflow consists of Instruction Fine Tuning and Distillation (from Apertus-70B-Instruct-2509).
 
 
 
 
 
 
 
 
 
 
172
 
173
  ## Evaluation
174
 
 
184
 
185
  Instruction-following and Multi-turn Chat
186
 
187
+ We evaluated the models on Instruction-Following and Multi-turn Chat capabilities with SEA-IFEval (based on [IFEval](https://arxiv.org/abs/2311.07911)) and SEA-MTBench (based on [MT-Bench](https://arxiv.org/abs/2306.05685)) respectively. The two datasets were originally in English, the linguists and native speakers in the team worked together to filter, localise and translate the datasets into the respective target languages to ensure that the examples remained reasonable, meaningful and natural.
188
 
189
  #### Factors
190
 
 
200
 
201
  SEA-MTBench
202
 
203
+ SEA-MTBench evaluates a model's ability to engage in Multi-turn (2 turns) conversations and respond in ways that align with human needs. We use `gpt-4.1-2025-04-14` as the judge model and compare against `gpt-4.1-2025-04-14` as the baseline model. The metric used is the weighted win rate against the baseline model (i.e. average win rate across each category: Math, Reasoning, STEM, Humanities, Roleplay, Writing, Extraction).
204
 
205
  #### Metrics
206