神经机器翻译模型,用于从塞尔维亚-克罗地亚语(sh)翻译到英语(en)。
此模型是 OPUS-MT project 的一部分,旨在使神经机器翻译模型在世界上许多语言中广泛可用和易于访问。所有模型都是使用纯C++编写的高效NMT实现框架 Marian 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 = [
"Ispostavilo se da je istina.",
"Ovaj vikend imamo besplatne pozive."
]
model_name = "pytorch-models/opus-mt-tc-big-sh-en"
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:
# Turns out it's true.
# We got free calls this weekend.
您还可以使用transformers pipelines使用OPUS-MT模型,例如:
from transformers import pipeline
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-big-sh-en")
print(pipe("Ispostavilo se da je istina."))
# expected output: Turns out it's true.
| langpair | testset | chr-F | BLEU | #sent | #words |
|---|---|---|---|---|---|
| bos_Latn-eng | tatoeba-test-v2021-08-07 | 0.80010 | 66.5 | 301 | 1826 |
| hbs-eng | tatoeba-test-v2021-08-07 | 0.71744 | 56.4 | 10017 | 68934 |
| hrv-eng | tatoeba-test-v2021-08-07 | 0.73563 | 58.8 | 1480 | 10620 |
| srp_Cyrl-eng | tatoeba-test-v2021-08-07 | 0.68248 | 44.7 | 1580 | 10181 |
| srp_Latn-eng | tatoeba-test-v2021-08-07 | 0.71781 | 58.4 | 6656 | 46307 |
| hrv-eng | flores101-devtest | 0.63948 | 37.1 | 1012 | 24721 |
该工作得到 European Language Grid 的支持作为 pilot project 2866 ,得到 FoTran project 的支持,该项目由欧洲研究理事会(ERC)在欧洲联盟的“Horizon 2020”研究与创新计划(授权协议号:771113)以及 MeMAD project 的支持,该项目由欧洲联盟的“Horizon 2020”研究与创新计划(授权协议号:780069)资助。我们还感谢芬兰的 CSC -- IT Center for Science 提供慷慨的计算资源和IT基础设施。