用于将英语(en)翻译成塞尔维亚-克罗地亚语(sh)的神经机器翻译模型。
该模型是 OPUS-MT project 的一部分,旨在使神经机器翻译模型在世界上许多语言中广泛可用且易于访问。所有模型最初是使用 Marian NMT 的惊人框架进行训练的,它是用纯C++编写的高效NMT实现。使用 transformers 库由 huggingface 转换为 pyTorch。训练数据来自于 OPUS ,训练流程使用了 OPUS-MT-train 的方法。模型描述:
这是一个具有多个目标语言的多语言翻译模型。需要通过 >>id<< 的形式提供句子的起始语言标记(id = 有效的目标语言ID),例如: >>bos_Latn<<
此模型可用于翻译和文本生成。
内容警告:读者应意识到该模型是在可能包含令人不安、冒犯和传播历史和现实偏见的各种公共数据集上进行训练的。
已经进行了大量研究来探索语言模型的偏差和公平性问题(参见,例如, Sheng et al. (2021) 和 Bender et al. (2021) )。
以下是一个简短的示例代码:
from transformers import MarianMTModel, MarianTokenizer
src_text = [
">>hrv<< You're about to make a very serious mistake.",
">>hbs<< I've just been too busy."
]
model_name = "pytorch-models/opus-mt-tc-base-en-sh"
tokenizer = MarianTokenizer.from_pretrained(model_name)
model = MarianMTModel.from_pretrained(model_name)
translated = model.generate(**tokenizer(src_text, return_tensors="pt", padding=True))
for t in translated:
print( tokenizer.decode(t, skip_special_tokens=True) )
# expected output:
# Ti si o tome napraviti vrlo ozbiljnu pogrešku.
# [4]
您也可以使用 transformers pipelines 来使用 OPUS-MT 模型,例如:
from transformers import pipeline
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-base-en-sh")
print(pipe(">>hrv<< You're about to make a very serious mistake."))
# expected output: Ti si o tome napraviti vrlo ozbiljnu pogrešku.
| langpair | testset | chr-F | BLEU | #sent | #words |
|---|---|---|---|---|---|
| eng-bos_Latn | tatoeba-test-v2021-08-07 | 0.666 | 46.3 | 301 | 1650 |
| eng-hbs | tatoeba-test-v2021-08-07 | 0.631 | 42.1 | 10017 | 63927 |
| eng-hrv | tatoeba-test-v2021-08-07 | 0.691 | 49.7 | 1480 | 9396 |
| eng-srp_Cyrl | tatoeba-test-v2021-08-07 | 0.645 | 45.1 | 1580 | 9152 |
| eng-srp_Latn | tatoeba-test-v2021-08-07 | 0.613 | 39.8 | 6656 | 43729 |
| eng-hrv | flores101-devtest | 0.586 | 28.7 | 1012 | 22423 |
| eng-hrv | flores200-dev | 0.57963 | 28.1 | 997 | 21567 |
| eng-hrv | flores200-devtest | 0.58652 | 28.9 | 1012 | 22423 |
| eng-srp_Cyrl | flores101-devtest | 0.59874 | 31.7 | 1012 | 23456 |
| eng-srp_Cyrl | flores200-dev | 0.60096 | 32.2 | 997 | 22384 |
| eng-srp_Cyrl | flores200-devtest | 0.59874 | 31.7 | 1012 | 23456 |
@inproceedings{tiedemann-thottingal-2020-opus,
title = "{OPUS}-{MT} {--} Building open translation services for the World",
author = {Tiedemann, J{\"o}rg and Thottingal, Santhosh},
booktitle = "Proceedings of the 22nd Annual Conference of the European Association for Machine Translation",
month = nov,
year = "2020",
address = "Lisboa, Portugal",
publisher = "European Association for Machine Translation",
url = "https://aclanthology.org/2020.eamt-1.61",
pages = "479--480",
}
@inproceedings{tiedemann-2020-tatoeba,
title = "The Tatoeba Translation Challenge {--} Realistic Data Sets for Low Resource and Multilingual {MT}",
author = {Tiedemann, J{\"o}rg},
booktitle = "Proceedings of the Fifth Conference on Machine Translation",
month = nov,
year = "2020",
address = "Online",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2020.wmt-1.139",
pages = "1174--1182",
}
本工作得到 European Language Grid 的支持,作为 pilot project 2866 ,并且由 FoTran project 资助,该资助来自欧洲研究理事会(ERC)根据欧洲联盟的Horizon 2020研究和创新计划(授予协议号771113),以及 MeMAD project 资助,该资助来自欧洲联盟的Horizon 2020研究和创新计划(授予协议号780069)。我们还感谢芬兰的 CSC -- IT Center for Science 提供的慷慨计算资源和IT基础设施。