模型概述
模型特點
模型能力
使用案例
🚀 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 進行使用示例的查看,同時注意模型在未見過的語言對上的表現可能不穩定。



