神经机器翻译模型,用于将英语(en)翻译成意大利语(it)。
此模型是 OPUS-MT project 的一部分,该项目旨在使神经机器翻译模型普遍可用并可访问多种世界语言。所有模型最初是使用 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 = [
"He was always very respectful.",
"This cat is black. Is the dog, too?"
]
model_name = "pytorch-models/opus-mt-tc-big-en-it"
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:
# Era sempre molto rispettoso.
# Questo gatto e' nero, e' anche il cane?
您还可以使用transformers pipelines来使用OPUS-MT模型,例如:
from transformers import pipeline
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-big-en-it")
print(pipe("He was always very respectful."))
# expected output: Era sempre molto rispettoso.
| langpair | testset | chr-F | BLEU | #sent | #words |
|---|---|---|---|---|---|
| eng-ita | tatoeba-test-v2021-08-07 | 0.72539 | 53.9 | 17320 | 116336 |
| eng-ita | flores101-devtest | 0.59002 | 29.6 | 1012 | 27306 |
| eng-ita | newssyscomb2009 | 0.60759 | 31.2 | 502 | 11551 |
| eng-ita | newstest2009 | 0.60441 | 31.6 | 2525 | 63466 |
该工作得到 European Language Grid 的支持,作为 pilot project 2866 ,由 FoTran project 资助,资助机构为欧洲研究理事会(ERC)在欧洲联盟的Horizon 2020研究和创新计划下(授权协议编号为771113),以及 MeMAD project ,由欧洲联盟的Horizon 2020研究和创新计划在授权协议编号为780069下资助。我们还对 CSC -- IT Center for Science 提供的慷慨计算资源和IT基础设施表示感谢,芬兰。