--- 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 ---

🤗 Hugging Face  |   💾 GGUF

MiniTranslator-2B — 多语种翻译,2B 参数

# MiniTranslator-2B ## 模型介绍 MiniTranslator-2B 是基于 [MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B) 的 2B 多语种翻译模型,支持中文、英文及另外 20 种语言之间的互译,并能遵循中英文翻译 指令。模型面向通用翻译场景,也可用于端侧和边缘设备部署。 MiniTranslator-2B 提供 BF16 权重与四档 GGUF(F16 / Q8_0 / Q6_K / Q4_K_M),可在 transformers、vLLM、SGLang 与 llama.cpp 上运行。 ## 评测结果 翻译结果均为贪心解码(`temperature=0`)下的 XCOMET 分数(越高越好);指令遵循结果 采用各基准的规则打分。 ### 翻译 ![翻译 benchmark 对比](imgs/results_translation.png) MiniTranslator-2B 在 FLORES-200、NTREX-128 与 WMT24++ 上与 Hy-MT2-1.8B 基本持平, HardMTBench 领先 3.1 分;WMT25 的长文与结构化内容是相对 7B/30B-A3B 的主要差距。 ### 指令遵循 ![指令遵循 benchmark 对比](imgs/results_instruction.png) ## 模型链接 | 模型 | 说明 | 下载 | |---|---|---| | MiniTranslator-2B | BF16 权重 | [🤗 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) | ## 翻译任务指令示例(中英对照) *说明:以下示例中的 `source_lang` 与 `target_lang` 应使用完整语言名称;中文提示词 用中文名,英文提示词用英文名。* | 类型 | 中文提示词 | 英文提示词 | |---|---|---| | **默认翻译** | 将以下文本翻译为 `{target_lang}`,只输出译文:

`{source_text}` | Translate the following text into `{target_lang}`. Output only the translation:

`{source_text}` | | **术语** | *参考下面的翻译:*
`{text}` 翻译成 `{text}`
`{text}` 翻译成 `{text}`

将以下文本翻译为 `{target_lang}`,只输出译文:

`{source_text}` | *Reference the following translations:*
`{text}` translates to `{text}`
`{text}` translates to `{text}`

Translate the following text into `{target_lang}`. Output only the translation:

`{source_text}` | | **风格** | 请将以下文本翻译为 `{target_lang}`。
翻译风格要严格符合【**`{target_style}`**】

`{source_text}` | Please translate the following text into `{target_lang}`. The translation style must strictly conform to [**`{target_style}`**]:

`{source_text}` | | **个性化** | *【待翻译文本】*
`{source_text}`

*【翻译任务】*
1、**`{user_preferences}`**
2、**`{user_preferences}`**
3、……
4、将【待翻译文本】翻译为 `{target_lang}`。 | *[Source Text]*
`{source_text}`

*[Translation Tasks]*
1. **`{user_preferences}`**
2. **`{user_preferences}`**
3. ...
4. Translate the [Source Text] into `{target_lang}`. | | **分隔符** | 请将以下文本准确翻译为 `{target_lang}`。
你必须在译文中**保留等量的分隔符,绝对不可遗漏、转义或翻译该符号,并注意分隔符的位置**。

`{source_text}` | Please accurately translate the following text into `{target_lang}`.
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**.

`{source_text}` | | **结构化数据** | *# 任务目标*
将下方 `{source_text}` 中的 `{format_type}` 格式数据翻译为 `{target_lang}`。

*# 严格约束*
1. **结构锁定**:绝对保持原有的 `{format_type}` 数据结构、缩进和层级完全不变。
2. **选择性翻译**:仅翻译面向用户展示的可见文本内容。
3. **禁止修改**:**严禁**翻译或更改任何代码标签、键名(Key)、变量占位符(如 `{{var}}`、`${var}`、`%s`、`%d` 等)或代码属性。

*# 数据输入*
`{source_text}` | *### Task*
Translate the user-facing text within the following `{format_type}` data into `{target_lang}`.

*### Strict Rules*
1. **Structure Preservation:** You MUST preserve the original `{format_type}` data structure, nesting, hierarchy, and indentation exactly as they are.
2. **Selective Translation:** Translate ONLY the visible, user-facing text content/values.
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.

*### Source Data*
`{source_text}` | | **背景信息** | *【背景信息】*
`{background_text}`

请结合背景信息将以下文本翻译为 `{target_lang}`。

*【待翻译文本】*
`{source_text}` | *[Background Information]*
`{background_text}`

Please translate the following text into `{target_lang}`, taking the provided background information into consideration.

*[Source Text]*
`{source_text}` | --- ## 推理与部署 推荐解码参数如下。模型没有默认 system prompt。 ```json { "temperature": 0, "top_p": 0.95, "max_tokens": 4096 } ``` 翻译建议使用贪心解码(`temperature=0`);如需采样,使用较低温度(0.2–0.3)与 `top_p=0.9`。 chat template 支持思考模式,但翻译时应关闭:transformers 传 `enable_thinking=False`,llama.cpp 加 `--reasoning off`,OpenAI 兼容请求传 `chat_template_kwargs: {"enable_thinking": false}`。 ### 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 }' ``` 不支持 `--reasoning` 的 llama.cpp 构建,去掉该参数,并在请求体加 `"chat_template_kwargs": {"enable_thinking": false}`。 ## 量化 | 文件 | 量化 | 大小(字节) | 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` | 权重由 `llama.cpp/convert_hf_to_gguf.py` 转换,并用 `llama-quantize` 量化;转换与 使用细节见 GGUF 模型仓库。 ## 支持语种 | 语言 | 缩写 | 中文名 | |---|---|---| | 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 | 乌克兰语 | 基座模型还支持上表之外的语言;低资源方向的质量存在波动,建议在业务数据上验证。 ## 许可证 以 **Apache License 2.0** 发布。本模型是 [openbmb/MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B) 的派生模型, 署名见 `NOTICE`。"MiniCPM" 名称及 OpenBMB 相关标识归其所有者。