神经机器翻译模型,用于将英语(en)翻译成罗马尼亚语(ro)。
该模型是 OPUS-MT project 的一部分,该项目旨在使神经机器翻译模型在世界上的许多语言中得到广泛使用和访问。所有模型都是使用 Marian NMT 的出色框架进行训练的, Marian NMT 是一个用纯C++编写的高效NMT实现。这些模型已经使用huggingface的transformers库将其转换为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 = [
">>ron<< A bad writer's prose is full of hackneyed phrases.",
">>ron<< Zero is a special number."
]
model_name = "pytorch-models/opus-mt-tc-big-en-ro"
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:
# Proza unui scriitor prost este plină de fraze tocite.
# Zero este un număr special.
您还可以使用transformers的pipelines来使用OPUS-MT模型,例如:
from transformers import pipeline
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-big-en-ro")
print(pipe(">>ron<< A bad writer's prose is full of hackneyed phrases."))
# expected output: Proza unui scriitor prost este plină de fraze tocite.
| langpair | testset | chr-F | BLEU | #sent | #words |
|---|---|---|---|---|---|
| eng-ron | tatoeba-test-v2021-08-07 | 0.68606 | 48.6 | 5508 | 40367 |
| eng-ron | flores101-devtest | 0.64876 | 40.4 | 1012 | 26799 |
| eng-ron | newsdev2016 | 0.62682 | 36.4 | 1999 | 51300 |
| eng-ron | newstest2016 | 0.60702 | 34.0 | 1999 | 48945 |
该工作得到 European Language Grid 和 pilot project 2866 的支持,由 FoTran project 资助,该项目由欧洲研究理事会(ERC)在欧洲联盟的Horizon 2020研究和创新计划(授予协议号771113)下,以及 MeMAD project 在欧洲联盟的Horizon 2020研究和创新计划(授予协议号780069)下资助。我们还要感谢 CSC -- IT Center for Science 提供的慷慨计算资源和IT基础设施,芬兰。