j0ma / mrl_nmt22 Goto Github PK
View Code? Open in Web Editor NEWNMT for Morphologically Rich Languages
NMT for Morphologically Rich Languages
Multilingual training in fairseq requires a joint subword vocabulary for all the languages. Since it can be difficult to train huge SentencePiece models, it seems common to use pre-trained ones that come packaged with large multilingual models, e.g. mBART or mBART50.
This is problematic when working with a language like Inuktitut that uses its own script, as the character set is completely disjoint from what the model saw at training time.
Since we can't add IU characters to the SPM model dictionaries, every surface-level token is an UNK as far as sentencepiece is concerned. By default, SPM outputs these OOV tokens as is as noted in #5 . Thus, fairseq-preprocess
sees a near-unsegmeted Inuktitut corpus.
The way to get around this is to decompose all OOVs to bytes. This can be accomplished by setting byte_fallback=True
---something which the multilingual models did not do.
How to get around this? Maybe by using the python module like this
Multilingual corpora tend to get large, and higher-resourced languages can overpower lower-resourced ones.
To get around this, need functionality to subsample corpora. Should be easy to specify in a YAML config.
Need to take bilingual baselines and improve upon them using (iterative) backtranslation.
Started work on this by training a German to English reverse model on HPCC (ongoing)
Random comment: damn SLURM jobs getting preempted :D
Approach to implementing the logic will follow the backtranslation example from .
TODO: summarize bilingual baselines here
While training a bilingual EN-RU model, OOM occurs. This slows down training a lot.
As mjpost noted on Twitter, models often have large vocabs.
I noticed that this is happening here too. Here are SP model counts grepped from logs of fairseq-preprocess
:
./data-bin/en-cs/en_sp32k_cs_sp32k/default-train/preprocess.log:[cs] Dictionary: 43696 types
./data-bin/en-cs/en_sp32k_cs_sp32k/wmt-early/preprocess.log:[cs] Dictionary: 43696 types
./data-bin/en-cs/en_sp32k_cs_sp32k/wmt-late/preprocess.log:[cs] Dictionary: 43696 types
./data-bin/en-de/en_sp32k_de_sp32k/default-train/preprocess.log:[de] Dictionary: 53648 types
./data-bin/en-de/en_sp32k_de_sp32k/wmt-early/preprocess.log:[de] Dictionary: 53648 types
./data-bin/en-de/en_sp32k_de_sp32k/wmt-late/preprocess.log:[de] Dictionary: 53648 types
./data-bin/en-et/en_sp32k_et_sp32k/default-train/preprocess.log:[et] Dictionary: 42712 types
./data-bin/en-fi/en_sp32k_fi_sp32k/default-train/preprocess.log:[fi] Dictionary: 34904 types
./data-bin/en-fi/en_sp32k_fi_sp32k/newstest-2018/preprocess.log:[fi] Dictionary: 34904 types
./data-bin/en-fi/en_sp32k_fi_sp32k/newstest-2019/preprocess.log:[fi] Dictionary: 34904 types
./data-bin/en-iu/en_sp1k_iu_sp1k/hansard/preprocess.log:[iu] Dictionary: 1008 types
./data-bin/en-iu/en_sp1k_iu_sp1k/wmt20/preprocess.log:[iu] Dictionary: 1008 types
./data-bin/en-iu/en_sp32k_iu_sp32k/hansard/preprocess.log:[iu] Dictionary: 32008 types
./data-bin/en-iu/en_sp32k_iu_sp32k/wmt20/preprocess.log:[iu] Dictionary: 32008 types
./data-bin/en-ru/en_sp32k_ru_sp32k/default-train/preprocess.log:[ru] Dictionary: 148016 types
./data-bin/en-ru/en_sp32k_ru_sp32k/wmt-18-20/preprocess.log:[ru] Dictionary: 148016 types
./data-bin/en-tr/en_sp32k_tr_sp32k/default-train/preprocess.log:[tr] Dictionary: 37240 types
./data-bin/en-uz/en_sp32k_uz_sp32k/default-train/preprocess.log:[uz] Dictionary: 32200 types
./data-bin/en-vi/en_sp32k_vi_sp32k/default-train/preprocess.log:[vi] Dictionary: 39824 types
./data-bin/en-vi/en_sp32k_vi_sp32k/default-train-tokenized/preprocess.log:[vi] Dictionary: 39824 types
Problem? Maybe not, but certainly not optimal. Consider rerunning bilingual baselines later with better vocabs once multilingual / multi-task is running (resources are limited)
The current design is intended to be used so that each split of a corpus will have one CorpusSplit
object associated with it.
Another approach that requires no changes to code would be to list the various shards as different splits (shard1
, shard2
, ...) but that is cumbersome in terms of writing YAML and defeats the purpose of using an input file regex anyway`.
Maybe I could just accept an iterable of CorpusSplit
s here?
When preprocesing the raw Inuktitut data, the dev and test sets seem to contains an abnormally high <unk>
replacement ratio:
(fairseq-py3.8) [jonnesaleva@gpu-1-1 hansard]$ cat preprocess.log
Namespace(align_suffix=None, alignfile=None, all_gather_list_size=16384, bf16=False, bpe=None, checkpoint_shard_count=1, checkpoint_suffix='', cpu=True, criterion='cross_entropy', dataset_impl='mmap', destdir='data-bin/en-iu/en_sp32k_iu_sp32k/hansard', empty_cache_freq=0, fp16=False, fp16_init_scale=128, fp16_no_flatten_grads=False, fp16_scale_tolerance=0.0, fp16_scale_window=None, joined_dictionary=False, log_format=None, log_interval=100, lr_scheduler='fixed', memory_efficient_bf16=False, memory_efficient_fp16=False, min_loss_scale=0.0001, model_parallel_size=1, no_progress_bar=False, nwordssrc=-1, nwordstgt=-1, only_source=False, optimizer=None, padding_factor=8, profile=False, quantization_config_path=None, scoring='bleu', seed=1, source_lang='en', srcdict=None, target_lang='iu', task='translation', tensorboard_logdir=None, testpref='/home/jonnesaleva/datasets/mrl_nmt22/processed/en-iu/en_sp32k_iu_sp32k/hansard/en-iu.test', tgtdict=None, threshold_loss_scale=None, thresholdsrc=0, thresholdtgt=0, tokenizer=None, tpu=False, trainpref='/home/jonnesaleva/datasets/mrl_nmt22/processed/en-iu/en_sp32k_iu_sp32k/hansard/en-iu.train', user_dir=None, validpref='/home/jonnesaleva/datasets/mrl_nmt22/processed/en-iu/en_sp32k_iu_sp32k/hansard/en-iu.dev', workers=40)
[en] Dictionary: 32096 types
[en] /home/jonnesaleva/datasets/mrl_nmt22/processed/en-iu/en_sp32k_iu_sp32k/hansard/en-iu.train.en: 1293439 sents, 22538091 tokens, 0.0% replaced by <unk>
[en] Dictionary: 32096 types
[en] /home/jonnesaleva/datasets/mrl_nmt22/processed/en-iu/en_sp32k_iu_sp32k/hansard/en-iu.dev.en: 2674 sents, 74173 tokens, 4.0% replaced by <unk>
[en] Dictionary: 32096 types
[en] /home/jonnesaleva/datasets/mrl_nmt22/processed/en-iu/en_sp32k_iu_sp32k/hansard/en-iu.test.en: 3602 sents, 98545 tokens, 4.06% replaced by <unk>
[iu] Dictionary: 32256 types
[iu] /home/jonnesaleva/datasets/mrl_nmt22/processed/en-iu/en_sp32k_iu_sp32k/hansard/en-iu.train.iu: 1293439 sents, 16342339 tokens, 0.0% replaced by <unk>
[iu] Dictionary: 32256 types
[iu] /home/jonnesaleva/datasets/mrl_nmt22/processed/en-iu/en_sp32k_iu_sp32k/hansard/en-iu.dev.iu: 2674 sents, 56715 tokens, 33.5% replaced by <unk>
[iu] Dictionary: 32256 types
[iu] /home/jonnesaleva/datasets/mrl_nmt22/processed/en-iu/en_sp32k_iu_sp32k/hansard/en-iu.test.iu: 3602 sents, 80675 tokens, 34.3% replaced by <unk>
Wrote preprocessed data to data-bin/en-iu/en_sp32k_iu_sp32k/hansard
Training on this data yields clearly degenerate BLEU scores even on hansard-dev:
iu-BLEU-13a-mixed 2.17573
iu-BLEU-intl-mixed 2.15823
iu-BLEU-char-mixed 0.96862
iu-BLEU-spm-mixed 1.52165
iu-BLEU-none-mixed 0.03631
iu-BLEU-13a-lc 2.17573
iu-BLEU-intl-lc 2.15823
iu-BLEU-char-lc 0.96862
iu-BLEU-spm-lc 1.52213
iu-BLEU-none-lc 0.03631
iu-CHRF3-min1-max6 4.43602
iu-CHRF2-char6-word0 3.17176
TODO: fix the preprocessing so the <unk>
replacement is minimized.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.