神经机器翻译模型,用于将匈牙利语(hu)翻译为英语(en)。
该模型是 OPUS-MT project 的一部分,致力于为世界上许多语言提供广泛可用且易于获取的神经机器翻译模型。所有模型最初都是使用 Marian NMT 的出色框架进行训练的,该框架是用纯 C++ 编写的高效 NMT 实现。使用 transformers 库的 pyTorch 将模型转换为 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 = [ "Bárcsak ne láttam volna ilyen borzalmas filmet!", "Iskolában van." ] model_name = "pytorch-models/opus-mt-tc-big-hu-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: # I wish I hadn't seen such a terrible movie. # She's at school.
您还可以使用 transformers 的 pipelines 来使用 OPUS-MT 模型,例如:
from transformers import pipeline pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-big-hu-en") print(pipe("Bárcsak ne láttam volna ilyen borzalmas filmet!")) # expected output: I wish I hadn't seen such a terrible movie.
langpair | testset | chr-F | BLEU | #sent | #words |
---|---|---|---|---|---|
hun-eng | tatoeba-test-v2021-08-07 | 0.66644 | 50.4 | 13037 | 94699 |
hun-eng | flores101-devtest | 0.61974 | 34.6 | 1012 | 24721 |
hun-eng | newssyscomb2009 | 0.52563 | 24.7 | 502 | 11818 |
hun-eng | newstest2009 | 0.51698 | 23.4 | 2525 | 65399 |
这项工作得到 European Language Grid 的支持,作为 pilot project 2866 ,以及 FoTran project ,该项目由欧洲研究理事会(ERC)根据欧盟的Horizon 2020研究和创新计划(授予协议编号771113)资助,以及 MeMAD project ,该项目由欧盟的Horizon 2020研究和创新计划根据授予协议编号780069资助。我们还感谢 CSC -- IT Center for Science 提供的慷慨的计算资源和IT基础设施,芬兰。