神经机器翻译模型,用于将芬兰语(fi)翻译为英语(en)。
该模型是 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 = [ "Kolme kolmanteen on kaksikymmentäseitsemän.", "Heille syntyi poikavauva." ] model_name = "pytorch-models/opus-mt-tc-big-fi-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) )
您还可以使用transformers pipelines来使用OPUS-MT模型,例如:
from transformers import pipeline pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-big-fi-en") print(pipe("Kolme kolmanteen on kaksikymmentäseitsemän."))
langpair | testset | chr-F | BLEU | #sent | #words |
---|---|---|---|---|---|
fin-eng | tatoeba-test-v2021-08-07 | 0.72298 | 57.4 | 10690 | 80552 |
fin-eng | flores101-devtest | 0.62521 | 35.4 | 1012 | 24721 |
fin-eng | newsdev2015 | 0.56232 | 28.6 | 1500 | 32012 |
fin-eng | newstest2015 | 0.57469 | 29.9 | 1370 | 27270 |
fin-eng | newstest2016 | 0.60715 | 34.3 | 3000 | 62945 |
fin-eng | newstest2017 | 0.63050 | 37.3 | 3002 | 61846 |
fin-eng | newstest2018 | 0.54199 | 27.1 | 3000 | 62325 |
fin-eng | newstest2019 | 0.59620 | 32.7 | 1996 | 36215 |
fin-eng | newstestB2016 | 0.55472 | 27.9 | 3000 | 62945 |
fin-eng | newstestB2017 | 0.58847 | 31.1 | 3002 | 61846 |
该工作得到 European Language Grid 的支持,作为 pilot project 2866 ,由欧洲研究理事会(ERC)在欧洲联盟的Horizon 2020研究和创新计划(授权合同编号 771113)下资助,以及 FoTran project 的支持,由欧洲联盟的Horizon 2020研究和创新计划在授权合同编号 780069 下资助。我们还感谢芬兰的 CSC -- IT Center for Science 提供的慷慨计算资源和IT基础设施。