课程咨询: 400-996-5531 / 投诉建议: 400-111-8989
认真做教育 专心促就业
Facebook 10月19日开源了M2M-100模型的源代码,并称该算法是第一个能够在不依赖英语数据的情况下,在100种语言之间进行翻译的算法。也就是这说,无需通过英文做中介,该模型就可对这100种语言直接互译。
M2M-100基于Facebook的多语言模型XLM-R,使用ccAligned,ccMatrix和LASER等开源数据挖掘工具收集了包含100多种语言的超过75亿个句子,根据语言分类、地理和文化相似性等参数分为14种不同的语言组。在14个语言组中,每个语言会被标识一到三种“过渡语言”,然后将其作为翻译成不同语言组的基础。
生成数据
在应用SPM进行数据预处理之前,需要标记所有数据集。如果使用这些评估数据集,请引用其相关论文。
# WMT - use sacrebleu, example here:
sacrebleu -t wmt14 -l fr-en --echo src > wmt.test.fr-en.fr
sacrebleu -t wmt14 -l fr-en --echo ref > wmt.test.fr-en.en
# WAT
wget #/WAT/my-en-data/wat2019.my-en.zip
unzip wat2019.my-en.zip
# FLORES
# download from: https://github.com/facebookresearch/flores
# TED - need to detokenize with Moses!
# from: https://github.com/neulab/word-embeddings-for-nmt
wget #/data/ted_talks.tar.gz
# Autshumato
# request to download: #/handle/20.500.12185/397
# Tatoeba Challenge
# available here: https://github.com/Helsinki-NLP/Tatoeba-Challenge
训练数据
为了产生训练数据,结合使用CCMatrix和CCAligned。查看此处的说明下载原始数据。
数据预处理
下载原始数据后,需要对数据进行处理,然后应用SPM,然后进行二值化。
# preprocess data
# remove sentences with more than 50% punctuation
python /path/to/fairseq/examples/m2m_100/process_data/remove_too_much_punc.py
# deduplicate training data
paste /path/to/datadir/train.$src /path/to/datadir/train.$tgt | awk '!x[$0]++' > /path/to/datadir/train.dedup
echo "keeping $(wc -l /path/to/datadir/train.dedup) bitext out of $(wc -l /path/to/datadir/train.$src)"
cut -f1 /path/to/datadir/train.dedup > /path/to/datadir/train.$src
cut -f2 /path/to/datadir/train.dedup > /path/to/datadir/train.$tgt
# remove all instances of evaluation data from the training data
python /path/to/fairseq/examples/m2m_100/process_data/dedup_data.py
# frequency cleaning
wget #/m2m_100/histograms.tar.gz
tar -xvzf histograms.tar.gz
python /path/to/fairseq/examples/m2m_100/process_data/clean_histogram.py --src $src --tgt $tgt --src-file /path/to/source/file --tgt-file /path/to/output/file --src-output-file source_output.$src --tgt-output-file target_output.$tgt --histograms /path/to/histograms
# apply SPM
wget #/m2m_100/spm.128k.model
python /path/to/fairseq/scripts/spm_encode.py \
--model spm.128k.model \
--output_format=piece \
--inputs=/path/to/input/file/here \
--outputs=/path/to/output/file/here
# length ratio cleaning
perl mosesdecoder/scripts/training/clean-corpus-n.perl --ratio 3 /path/to/training/data/train.spm.$src-$tgt $src $tgt /path/to/output/directory/train.spm.$src-$tgt 1 250
# binarize data
wget #/m2m_100/data_dict.128k.txt
fairseq-preprocess \
--source-lang $src --target-lang $tgt \
--testpref spm.$src.$tgt \
--thresholdsrc 0 --thresholdtgt 0 \
--destdir data_bin \
--srcdict data_dict.128k.txt --tgtdict data_dict.128k.txt
训练脚本
为了重现模型训练,使用fairseq-py的多语言翻译任务进行训练。
生成
从该模型中生成,需遵循以下生成部分中的命令。
@article{fan2020beyond,
title={Beyond English-Centric Multilingual Machine Translation},
author={Fan, Angela and Bhosale, Shruti and Schwenk, Holger and Ma, Zhiyi and El-Kishky, Ahmed and Goyal, Siddharth and Baines, Mandeep and Celebi, Onur and Wenzek, Guillaume and Chaudhary, Vishrav and Goyal, Naman and Birch, Tom and Liptchinsky, Vitaliy and Edunov, Sergey and Grave, Edouard and Auli, Michael and Joulin, Armand},
journal={arXiv preprint},
year={2020}
}
@article{schwenk2019ccmatrix,
title={Ccmatrix: Mining billions of high-quality parallel sentences on the web},
author={Schwenk, Holger and Wenzek, Guillaume and Edunov, Sergey and Grave, Edouard and Joulin, Armand},
journal={arXiv preprint arXiv:1911.04944},
year={2019}
}
@article{el2019massive,
title={A Massive Collection of Cross-Lingual Web-Document Pairs},
author={El-Kishky, Ahmed and Chaudhary, Vishrav and Guzman, Francisco and Koehn, Philipp},
journal={arXiv preprint arXiv:1911.06154},
year={2019}
}
参考链接:
#/2020/10/19/facebooks-open-source-m2m-100-model-can-translate-between-100-different-languages/
#/2020/10/19/facebook-ai-open-sources-m2m-100-multilingual-model-improve-translation-accuracy/
选择的人多的机构就是好机构,达内每年近10万学员的选择,来达内给你一个不一样的培训体验。达内目前开设24大课程体系,Java编程、UI设计、网络营销、web前端培训等课程。达内每月开设免费课程试听训练营,欢迎来电预约免费试听,领取免费课程资料。来合肥IT培训,让你的人生有不一样的精彩。
【免责声明】本文系本网编辑部分转载,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如涉及作品内容、版权和其它问题,请在30日内与管理员联系,我们会予以更改或删除相关文章,以保证您的权益!