神经机器翻译模型,用于将东斯拉夫语言(zle)翻译成德语(de)。
该模型是 OPUS-MT project 的一部分,旨在使神经机器翻译模型在世界上的许多语言中得到广泛使用和易于访问。所有模型最初是使用 Marian NMT 提供的出色框架进行训练的,这是一个用纯C++编写的高效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",
}
简短的示例代码:
from transformers import MarianMTModel, MarianTokenizer
src_text = [
"Это был по-настоящему прекрасный день.",
"Дождь кончился?"
]
model_name = "pytorch-models/opus-mt-tc-big-zle-de"
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:
# Es war ein wirklich schöner Tag.
# Ist der Regen vorbei?
您也可以使用transformers pipelines来使用OPUS-MT模型,例如:
from transformers import pipeline
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-big-zle-de")
print(pipe("Это был по-настоящему прекрасный день."))
# expected output: Es war ein wirklich schöner Tag.
| langpair | testset | chr-F | BLEU | #sent | #words |
|---|---|---|---|---|---|
| bel-deu | tatoeba-test-v2021-08-07 | 0.63720 | 44.8 | 551 | 4182 |
| rus-deu | tatoeba-test-v2021-08-07 | 0.69768 | 51.8 | 12800 | 98842 |
| ukr-deu | tatoeba-test-v2021-08-07 | 0.70860 | 54.7 | 10319 | 64646 |
| bel-deu | flores101-devtest | 0.47052 | 12.9 | 1012 | 25094 |
| rus-deu | flores101-devtest | 0.56159 | 26.1 | 1012 | 25094 |
| ukr-deu | flores101-devtest | 0.57251 | 28.1 | 1012 | 25094 |
| rus-deu | newstest2012 | 0.49257 | 19.8 | 3003 | 72886 |
| rus-deu | newstest2013 | 0.54015 | 25.2 | 3000 | 63737 |
该工作得到 European Language Grid 的支持,作为 pilot project 2866 ,以及 FoTran project 的资助,该项目由欧洲研究理事会(ERC)在欧洲联盟的Horizon 2020研究和创新计划(授权号771113)下资助,以及通过欧洲联盟Horizon 2020研究和创新计划(授权号780069)提供的 MeMAD project 的资助。我们还要感谢提供给 CSC -- IT Center for Science 的慷慨计算资源和IT基础设施,芬兰。