Translation
Transformers
Safetensors
GGUF
llama
text-generation
minicpm
minicpm5
on-device
text-generation-inference
Instructions to use Caldalis/MiniTranslator-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Caldalis/MiniTranslator-2B with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("translation", model="Caldalis/MiniTranslator-2B")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Caldalis/MiniTranslator-2B") model = AutoModelForCausalLM.from_pretrained("Caldalis/MiniTranslator-2B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 10,063 Bytes
727585b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | ---
language:
- zh
- en
- ja
- ko
- ar
- de
- fr
- es
- ru
- bn
- cs
- et
- fa
- he
- id
- kn
- ro
- ta
- te
- tl
- tr
- uk
library_name: transformers
license: apache-2.0
base_model: openbmb/MiniCPM5-2B
base_model_relation: finetune
pipeline_tag: translation
tags:
- translation
- minicpm
- minicpm5
- gguf
- on-device
---
<p align="center">
🤗 <a href="https://huggingface.co/Caldalis/MiniTranslator-2B"><b>Hugging Face</b></a> |
💾 <a href="https://huggingface.co/Caldalis/MiniTranslator-2B-GGUF"><b>GGUF</b></a>
</p>
<p align="center">
<img src="imgs/banner.png" alt="MiniTranslator-2B — multilingual translation, 2B parameters" width="100%">
</p>
# MiniTranslator-2B
## Model Introduction
MiniTranslator-2B is a 2B multilingual translation model built on
[MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B). It supports translation
among Chinese, English, and 20 additional languages, and follows translation
instructions in both Chinese and English. The model is designed for general
translation workloads as well as on-device and edge deployment.
MiniTranslator-2B is released in BF16 and in four GGUF variants (F16 / Q8_0 / Q6_K /
Q4_K_M), so the same model can run with transformers, vLLM, SGLang, or llama.cpp.
## Results
All translation results use greedy decoding (`temperature=0`) and XCOMET (higher is
better). Instruction-following results use the benchmark's rule-based scoring.
### Translation

MiniTranslator-2B is competitive with Hy-MT2-1.8B on FLORES-200, NTREX-128, and
WMT24++, and leads on HardMTBench by 3.1 points. WMT25 long-form and structured
content remains the largest gap to the 7B and 30B-A3B models.
### Instruction Following

## Model Links
| Model | Description | Download |
|---|---|---|
| MiniTranslator-2B | BF16 weights | [🤗 Model](https://huggingface.co/Caldalis/MiniTranslator-2B) |
| MiniTranslator-2B-GGUF | F16 / Q8_0 / Q6_K / Q4_K_M | [🤗 Model](https://huggingface.co/Caldalis/MiniTranslator-2B-GGUF) |
## Translation Task Instruction Examples (Chinese-English Comparison)
*Note: both `source_lang` and `target_lang` should use full language names. Use
Chinese names in Chinese prompts and English names in English prompts.*
| Type | Chinese prompt | English prompt |
|---|---|---|
| **Default Translation** | 将以下文本翻译为 `{target_lang}`,只输出译文:<br><br>`{source_text}` | Translate the following text into `{target_lang}`. Output only the translation:<br><br>`{source_text}` |
| **Terminology** | *参考下面的翻译:*<br>`{text}` 翻译成 `{text}`<br>`{text}` 翻译成 `{text}`<br><br>将以下文本翻译为 `{target_lang}`,只输出译文:<br><br>`{source_text}` | *Reference the following translations:*<br>`{text}` translates to `{text}`<br>`{text}` translates to `{text}`<br><br>Translate the following text into `{target_lang}`. Output only the translation:<br><br>`{source_text}` |
| **Style** | 请将以下文本翻译为 `{target_lang}`。<br>翻译风格要严格符合【**`{target_style}`**】<br><br>`{source_text}` | Please translate the following text into `{target_lang}`. The translation style must strictly conform to [**`{target_style}`**]:<br><br>`{source_text}` |
| **Personalization** | *【待翻译文本】*<br>`{source_text}`<br><br>*【翻译任务】*<br>1、**`{user_preferences}`**<br>2、**`{user_preferences}`**<br>3、……<br>4、将【待翻译文本】翻译为 `{target_lang}`。 | *[Source Text]*<br>`{source_text}`<br><br>*[Translation Tasks]*<br>1. **`{user_preferences}`**<br>2. **`{user_preferences}`**<br>3. ...<br>4. Translate the [Source Text] into `{target_lang}`. |
| **Delimiters** | 请将以下文本准确翻译为 `{target_lang}`。<br>你必须在译文中**保留等量的分隔符,绝对不可遗漏、转义或翻译该符号,并注意分隔符的位置**。<br><br>`{source_text}` | Please accurately translate the following text into `{target_lang}`.<br>You must **retain the exact same number of delimiters in the translation. Strictly do not omit, escape, or translate these symbols, and pay close attention to their placement**.<br><br>`{source_text}` |
| **Structured Data** | *# 任务目标*<br>将下方 `{source_text}` 中的 `{format_type}` 格式数据翻译为 `{target_lang}`。<br><br>*# 严格约束*<br>1. **结构锁定**:绝对保持原有的 `{format_type}` 数据结构、缩进和层级完全不变。<br>2. **选择性翻译**:仅翻译面向用户展示的可见文本内容。<br>3. **禁止修改**:**严禁**翻译或更改任何代码标签、键名(Key)、变量占位符(如 `{{var}}`、`${var}`、`%s`、`%d` 等)或代码属性。<br><br>*# 数据输入*<br>`{source_text}` | *### Task*<br>Translate the user-facing text within the following `{format_type}` data into `{target_lang}`.<br><br>*### Strict Rules*<br>1. **Structure Preservation:** You MUST preserve the original `{format_type}` data structure, nesting, hierarchy, and indentation exactly as they are.<br>2. **Selective Translation:** Translate ONLY the visible, user-facing text content/values.<br>3. **Strict Non-Translation:** NEVER translate or alter code tags, keys, properties, object names, or variable placeholders. Leave them exactly in their original English/code form.<br><br>*### Source Data*<br>`{source_text}` |
| **Background Information** | *【背景信息】*<br>`{background_text}`<br><br>请结合背景信息将以下文本翻译为 `{target_lang}`。<br><br>*【待翻译文本】*<br>`{source_text}` | *[Background Information]*<br>`{background_text}`<br><br>Please translate the following text into `{target_lang}`, taking the provided background information into consideration.<br><br>*[Source Text]*<br>`{source_text}` |
---
## Inference and Deployment
Recommended decoding parameters. The model does not have a default system prompt.
```json
{
"temperature": 0,
"top_p": 0.95,
"max_tokens": 4096
}
```
Greedy decoding (`temperature=0`) is recommended for translation. If sampling is
needed, use a low temperature (0.2–0.3) and `top_p=0.9`.
Thinking mode is supported by the chat template but should be disabled for
translation: pass `enable_thinking=False` in transformers, `--reasoning off` in
llama.cpp, or `chat_template_kwargs: {"enable_thinking": false}` in an
OpenAI-compatible request.
### transformers
`transformers>=5.6.0`
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_path = "Caldalis/MiniTranslator-2B"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
model_path,
dtype=torch.bfloat16,
device_map="auto",
)
model.eval()
prompt = "将以下文本翻译成英语,只输出译文:\n\n今天天气真好。"
messages = [{"role": "user", "content": prompt}]
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
enable_thinking=False,
return_tensors="pt",
).to(model.device)
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=4096, do_sample=False)
response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True)
print(response)
```
### vLLM
```bash
vllm serve Caldalis/MiniTranslator-2B --tensor-parallel-size 1
```
### SGLang
```bash
python3 -m sglang.launch_server --model Caldalis/MiniTranslator-2B --tp 1
```
### llama.cpp
```bash
llama-server -m MiniTranslator-2B-Q4_K_M.gguf -c 4096 --reasoning off --port 8080
```
```bash
curl http://127.0.0.1:8080/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"messages": [{"role": "user", "content": "将以下文本翻译成英语,只输出译文:\n\n今天天气真好。"}],
"temperature": 0,
"max_tokens": 4096
}'
```
On llama.cpp builds without `--reasoning`, omit the server flag and add
`"chat_template_kwargs": {"enable_thinking": false}` to the request body.
## Quantization
| File | Quantization | Size (bytes) | SHA-256 |
|---|---|---:|---|
| `MiniTranslator-2B-F16.gguf` | F16 | 5,039,006,496 | `236b69f8d40370ac390ff6f48283349d66318d654094a643d3641f148aa8e958` |
| `MiniTranslator-2B-Q8_0.gguf` | Q8_0 | 2,679,710,496 | `5999502dd1e520b18fcfa5bade61b64b7b119fa991d16f15b816f4f3b46d1997` |
| `MiniTranslator-2B-Q6_K.gguf` | Q6_K | 2,070,225,696 | `df7895713c691700c36b1db458a8998cb2ac8cd60e8cff1cb8976a3fe500dd93` |
| `MiniTranslator-2B-Q4_K_M.gguf` | Q4_K_M | 1,561,318,176 | `e7ebfd5120803c59163ed0cb44725c1e43e97be8434b031474c36ef32a867114` |
Weights are converted with `llama.cpp/convert_hf_to_gguf.py` and quantized with
`llama-quantize`. See the GGUF model repository for conversion and usage details.
## Supported Languages
| Language | Abbr. | Chinese Name |
|---|---|---|
| Chinese | zh | 中文 |
| English | en | 英语 |
| Japanese | ja | 日语 |
| Korean | ko | 韩语 |
| Arabic | ar | 阿拉伯语 |
| German | de | 德语 |
| French | fr | 法语 |
| Spanish | es | 西班牙语 |
| Russian | ru | 俄语 |
| Bengali | bn | 孟加拉语 |
| Czech | cs | 捷克语 |
| Estonian | et | 爱沙尼亚语 |
| Persian | fa | 波斯语 |
| Hebrew | he | 希伯来语 |
| Indonesian | id | 印尼语 |
| Kannada | kn | 卡纳达语 |
| Romanian | ro | 罗马尼亚语 |
| Tamil | ta | 泰米尔语 |
| Telugu | te | 泰卢固语 |
| Filipino | tl | 菲律宾语 |
| Turkish | tr | 土耳其语 |
| Ukrainian | uk | 乌克兰语 |
The base model supports additional languages beyond this list. Quality on
low-resource directions varies and should be validated on in-domain data.
## License
Released under the **Apache License 2.0**. This model is a derivative of
[openbmb/MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B); see `NOTICE` for
attribution. "MiniCPM" and any OpenBMB marks remain the property of
their owners.
|