英文

opus-mt-tc-big-en-pt

神经机器翻译模型,用于将英语(en)翻译成葡萄牙语(pt)。

该模型是 OPUS-MT project 的一部分,旨在使神经机器翻译模型在全球多种语言中广泛可用和可访问。所有模型最初使用纯C++编写的令人惊叹的 Marian NMT 框架进行训练。使用转换器库(由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",
}

模型信息

这是一个多语言翻译模型,具有多个目标语言。需要以表单形式提供句子的初始语言令牌,例如 >>id<<(id = 有效的目标语言ID),例如 >>pob<<

使用方法

简短示例代码:

from transformers import MarianMTModel, MarianTokenizer

src_text = [
    ">>por<< Tom tried to stab me.",
    ">>por<< He has been to Hawaii several times."
]

model_name = "pytorch-models/opus-mt-tc-big-en-pt"
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:
#     O Tom tentou esfaquear-me.
#     Ele já esteve no Havaí várias vezes.

您还可以使用transformers pipelines来使用OPUS-MT模型,例如:

from transformers import pipeline
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-big-en-pt")
print(pipe(">>por<< Tom tried to stab me."))

# expected output: O Tom tentou esfaquear-me.

基准测试

langpair testset chr-F BLEU #sent #words
eng-por tatoeba-test-v2021-08-07 0.69320 49.6 13222 105265
eng-por flores101-devtest 0.71673 50.4 1012 26519

致谢

这项工作得到了 European Language Grid 的支持,作为 pilot project 2866 ,由 FoTran project 资助,该项目由欧洲研究理事会(ERC)在欧洲联盟的Horizon 2020研究与创新计划(资助协议号:771113)和 MeMAD project 资助。我们还感谢 CSC -- IT Center for Science 提供的慷慨的计算资源和IT基础设施,芬兰。

模型转换信息

  • transformers 版本:4.16.2
  • OPUS-MT git哈希值:3405783
  • 转换时间:Wed Apr 13 17:48:54 EEST 2022
  • 转换机器:LM0-400-22516.local