Instructions to use aisingapore/Apertus-SEA-LION-v4-8B-IT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aisingapore/Apertus-SEA-LION-v4-8B-IT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="aisingapore/Apertus-SEA-LION-v4-8B-IT") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("aisingapore/Apertus-SEA-LION-v4-8B-IT") model = AutoModelForCausalLM.from_pretrained("aisingapore/Apertus-SEA-LION-v4-8B-IT", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use aisingapore/Apertus-SEA-LION-v4-8B-IT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "aisingapore/Apertus-SEA-LION-v4-8B-IT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aisingapore/Apertus-SEA-LION-v4-8B-IT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/aisingapore/Apertus-SEA-LION-v4-8B-IT
- SGLang
How to use aisingapore/Apertus-SEA-LION-v4-8B-IT with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "aisingapore/Apertus-SEA-LION-v4-8B-IT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aisingapore/Apertus-SEA-LION-v4-8B-IT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "aisingapore/Apertus-SEA-LION-v4-8B-IT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aisingapore/Apertus-SEA-LION-v4-8B-IT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use aisingapore/Apertus-SEA-LION-v4-8B-IT with Docker Model Runner:
docker model run hf.co/aisingapore/Apertus-SEA-LION-v4-8B-IT
Update README.md
Browse files
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
|
| 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):**
|
| 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 |
-
|
| 83 |
-
|
| 84 |
-
```
|
| 85 |
-
|
| 86 |
-
```
|
| 87 |
-
# The code is adopted from Apertus example
|
| 88 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 89 |
|
| 90 |
-
|
| 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 |
-
|
| 97 |
-
).
|
| 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 |
-
|
| 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 |
-
{
|
|
|
|
|
|
|
|
|
|
| 139 |
]
|
| 140 |
|
| 141 |
tools = [
|
|
@@ -173,63 +132,43 @@ tools = [
|
|
| 173 |
}
|
| 174 |
]
|
| 175 |
|
| 176 |
-
|
| 177 |
-
messages,
|
| 178 |
-
|
| 179 |
-
return_tensors="pt",
|
| 180 |
-
add_generation_prompt=True
|
| 181 |
).to(model.device)
|
| 182 |
|
| 183 |
-
|
| 184 |
-
input_ids,
|
| 185 |
-
max_new_tokens=512,
|
| 186 |
-
do_sample=False,
|
| 187 |
-
)
|
| 188 |
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
).replace("<end_of_turn>", "").strip()
|
| 193 |
|
| 194 |
-
|
|
|
|
| 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 |
-
##
|
| 216 |
|
| 217 |
-
|
|
|
|
| 218 |
|
| 219 |
-
-
|
| 220 |
-
-
|
|
|
|
| 221 |
|
| 222 |
-
|
| 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
|
| 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
|
| 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 |
|