神经机器翻译模型,用于将英语(en)翻译为东斯拉夫语言(zle)。
该模型是 OPUS-MT project 的一部分,旨在使神经机器翻译模型在世界上许多语言中广泛可用和易于访问。所有模型都是使用神奇的 C++ 纯编写的高效 NMT 实现 Marian NMT 在训练初期进行训练的。使用了transformers库由huggingface将这些模型转换为pyTorch。训练数据取自 OPUS ,训练流水线使用 OPUS-MT-train 的程序。
@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",
}
这是一个具有多个目标语言的多语言翻译模型。需要使用表单中的句子初始语言标记作为>>id<<(id = 有效目标语言ID),例如>>bel<<
一个简短的示例代码:
from transformers import MarianMTModel, MarianTokenizer
src_text = [
">>rus<< Are they coming as well?",
">>rus<< I didn't let Tom do what he wanted to do."
]
model_name = "pytorch-models/opus-mt-tc-big-en-zle"
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:
# Они тоже приедут?
# Я не позволил Тому сделать то, что он хотел.
您还可以使用transformers流程使用OPUS-MT模型,例如:
from transformers import pipeline
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-big-en-zle")
print(pipe(">>rus<< Are they coming as well?"))
# expected output: Они тоже приедут?
| langpair | testset | chr-F | BLEU | #sent | #words |
|---|---|---|---|---|---|
| eng-bel | tatoeba-test-v2021-08-07 | 0.50345 | 24.9 | 2500 | 16237 |
| eng-rus | tatoeba-test-v2021-08-07 | 0.66182 | 45.5 | 19425 | 134296 |
| eng-ukr | tatoeba-test-v2021-08-07 | 0.60175 | 37.7 | 13127 | 80998 |
| eng-bel | flores101-devtest | 0.42078 | 11.2 | 1012 | 24829 |
| eng-rus | flores101-devtest | 0.59654 | 32.7 | 1012 | 23295 |
| eng-ukr | flores101-devtest | 0.60131 | 32.1 | 1012 | 22810 |
| eng-rus | newstest2012 | 0.62842 | 36.8 | 3003 | 64790 |
| eng-rus | newstest2013 | 0.54627 | 26.9 | 3000 | 58560 |
| eng-rus | newstest2014 | 0.68348 | 43.5 | 3003 | 61603 |
| eng-rus | newstest2015 | 0.62621 | 34.9 | 2818 | 55915 |
| eng-rus | newstest2016 | 0.60595 | 33.1 | 2998 | 62014 |
| eng-rus | newstest2017 | 0.64249 | 37.3 | 3001 | 60253 |
| eng-rus | newstest2018 | 0.61219 | 32.9 | 3000 | 61907 |
| eng-rus | newstest2019 | 0.57902 | 31.8 | 1997 | 48147 |
| eng-rus | newstest2020 | 0.52939 | 25.5 | 2002 | 47083 |
| eng-rus | tico19-test | 0.59314 | 33.7 | 2100 | 55843 |
该工作得到 European Language Grid 以 pilot project 2866 的支持,由 FoTran project 资助,该项目由欧洲研究理事会 (ERC) 在欧洲联盟的Horizon 2020研究和创新计划 (授予协议编号771113) 下实施,以及 MeMAD project ,由欧盟的Horizon 2020研究和创新计划在授予协议编号780069下实施。我们还感谢 CSC -- IT Center for Science ,芬兰为我们提供慷慨的计算资源和IT基础设施。