神经机器翻译模型,用于将希伯来语(he)翻译成英语(en)。
该模型是 OPUS-MT project 的一部分,旨在使神经机器翻译模型在世界上的许多语言中广泛可用和易于访问。所有模型均使用纯C++编写的令人惊叹的 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", }
简短的示例代码:
from transformers import MarianMTModel, MarianTokenizer src_text = [ "היא שכחה לכתוב לו.", "אני רוצה לדעת מיד כשמשהו יקרה." ] model_name = "pytorch-models/opus-mt-tc-big-he-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: # She forgot to write to him. # I want to know as soon as something happens.
您还可以使用 transformers pipeline 使用 OPUS-MT 模型,例如:
from transformers import pipeline pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-big-he-en") print(pipe("היא שכחה לכתוב לו.")) # expected output: She forgot to write to him.
langpair | testset | chr-F | BLEU | #sent | #words |
---|---|---|---|---|---|
heb-eng | tatoeba-test-v2021-08-07 | 0.68565 | 53.8 | 10519 | 77427 |
heb-eng | flores101-devtest | 0.68116 | 44.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基础设施。