模型简介
模型特点
模型能力
使用案例
🚀 xTower13B 模型卡片
xTower13B 是一个用于解释和纠正翻译错误的语言模型,它基于多语言数据训练,具备处理不同语言对翻译问题的能力,为翻译工作提供了有效的辅助。
🚀 快速开始
对于一个简单的使用示例,请查看这个 notebook,它使用 VLLM 对 xTower 进行了调用。
此外,你可以使用 🤗 Transformers 库中的 pipeline()
函数来运行该模型:
# Install transformers from source - only needed for versions <= v4.34
# pip install git+https://github.com/huggingface/transformers.git
# pip install accelerate
import torch
from transformers import pipeline
pipe = pipeline("text-generation", model="sardinelab/xTower13B", device_map="auto")
messages = [
{
"role": "user",
"content": "your_prompt"
},
]
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
outputs = pipe(prompt, max_new_tokens=1024, do_sample=False)
✨ 主要特性
- 多语言支持:支持英语、葡萄牙语、西班牙语、法语、德语、荷兰语、意大利语、韩语、中文、俄语等多种语言。
- 错误解释与纠正:能够以自然语言解释翻译错误,并提供翻译建议以纠正错误。
- 混合提示处理:可以处理无参考和基于参考的 k-shot 提示。
📦 安装指南
若使用版本 <= v4.34,需要从源代码安装 transformers:
pip install git+https://github.com/huggingface/transformers.git
pip install accelerate
💻 使用示例
基础用法
# Install transformers from source - only needed for versions <= v4.34
# pip install git+https://github.com/huggingface/transformers.git
# pip install accelerate
import torch
from transformers import pipeline
pipe = pipeline("text-generation", model="sardinelab/xTower13B", device_map="auto")
messages = [
{
"role": "user",
"content": "your_prompt"
},
]
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
outputs = pipe(prompt, max_new_tokens=1024, do_sample=False)
📚 详细文档
模型详情
xTower13B 是一个语言模型,它通过对 TowerBase 进行微调得到,用于解释和纠正翻译错误。
xTower 在一个包含由 GPT - 4 生成的解释(有参考和无参考提示)的数据集上进行了微调,同时还结合了来自 TowerBlocks 的机器翻译数据。我们将所有可用数据组合起来训练了一个单一的多语言模型,并在训练期间采用了混合提示设置(零样本、少样本)。因此,xTower 可以处理无参考和基于参考的 k-shot 提示。
我们的训练超参数和配置遵循了用于训练 TowerInstruct 的设置。
属性 | 详情 |
---|---|
开发者 | Unbabel、Instituto Superior Técnico、CentraleSupélec University of Paris - Saclay |
模型类型 | 一个具有 130 亿参数的模型,在与翻译相关任务的公开可用合成数据集、对话数据集和代码指令的混合数据上进行了微调。 |
支持语言(NLP) | 英语、葡萄牙语、西班牙语、法语、德语、荷兰语、意大利语、韩语、中文、俄语 |
许可证 | CC - BY - NC - 4.0,Llama 2 根据 LLAMA 2 Community License 许可,版权所有 © Meta Platforms, Inc. 保留所有权利。 |
微调基础模型 | TowerBase |
预期用途与局限性
该模型的预期用途有两个方面:
- 用自然语言解释翻译错误。
- 通过提供翻译建议来纠正翻译错误。
该模型在 en - de、en - ru 和 zh - en 语言对的解释数据上进行了训练。尽管它具有多语言基础,但 xTower 在未见过的语言对上的表现可能好也可能不好。
偏差、风险和局限性
xTower 尚未与人类偏好对齐,因此该模型可能会生成有问题的输出(例如,幻觉内容、有害内容或虚假陈述)。
提示格式
xTower 使用 ChatML 提示模板进行训练,没有使用任何系统提示。以下是一个示例:
<|im_start|>user
You are provided with a Source, Translation, Translation quality analysis, and Translation quality score (weak, moderate, good, excellent, best). The Translation quality analysis contain a translation with marked error spans with different levels of severity (minor or major). Additionally, we may provide a **reference translation**. Given this information, generate an explanation for each error and a fully correct translation.
English source: All were wearing avalanche beacons.
German translation: Alle trugen Lawinenschilder.
Translation quality analysis: Alle trugen <error1 severity=“major”>Lawinenschilder</error1>.
Translation quality score: weak
<|im_end|>
<|im_start|>assistant
之后,模型应该生成类似以下的内容:
Explanation for error1: The term “Lawinenschilder” translates to “avalanche signs”, which is a significant mistranslation of “avalanche beacons”. Avalanche beacons are specific devices used to locate people trapped under snow after an avalanche, not signs. This error changes the meaning of the sentence and introduces confusion about the context.
Translation correction: Alle trugen Lawinensuchgeräte.
<|im_end|>
也就是说,输出由每个错误的解释列表和最终的翻译纠正组成。
引用
@article{treviso2024xtower,
title={xTower: A Multilingual LLM for Explaining and Correcting Translation Errors},
author={Treviso, Marcos and Guerreiro, Nuno M and Agrawal, Sweta and Rei, Ricardo and Pombal, José and Vaz, Tania and Wu, Helena and Silva, Beatriz and van Stigt, Daan and Martins, André FT},
journal={arXiv preprint arXiv:2406.19482},
year={2024}
}
⚠️ 重要提示
xTower 尚未与人类偏好对齐,可能会生成有问题的输出,如幻觉内容、有害内容或虚假陈述。
💡 使用建议
可参考提供的 notebook 进行使用示例的查看,同时注意模型在未见过的语言对上的表现可能不稳定。



