Multilingual_translation error at inference
See original GitHub issueFor the preprocessing, you can use the same commands in the documentation for each language pair, for example:
fairseq-preprocess --source-lang de --target-lang en
–trainpref $TEXT/train --validpref $TEXT/valid --testpref $TEXT/test
–destdir data-bin/
then you execute the same command for the second language pair:
fairseq-preprocess --source-lang it --target-lang en
–trainpref $TEXT/train --validpref $TEXT/valid --testpref $TEXT/test
–destdir data-bin/
As for the training, here is a sample command that I used:
python train.py \raw-data\data-bin --task multilingual_translation --criterion label_smoothed_cross_entropy --arch multilingual_transformer --max-epoch 26 --lr 1.0 --wd 0.5 --lang-pairs de-en,it-en --encoder-layers 2 --decoder-layers 2 --save-dir data\checkpoints --optimizer sgd
Inference:
fairseq-interactive \raw-data\data-bin --task multilingual_translation --source-lang it --target-lang en --path \checkpoints\checkpoint20.pt --input \raw-data\test.it --beam 5
For the inference however, I am stuck at this error: Traceback (most recent call last):
File “c:.…\lib\site-packages\fairseq_cli\interactive.py”, line 82, in main args.path.split('😂, task, model_arg_overrides=eval(args.model_overrides), File “c:.…\lib\site-packages\fairseq\utils.py”, line 164, in load_ensemble_for_inference model = task.build_model(args) File “c:.…\lib\site-packages\fairseq\tasks\multilingual_translation.py”, line 180, in build_model model = models.build_model(args, self) File “c:.…\lib\site-packages\fairseq\models_init_.py”, line 33, in build_model return ARCH_MODEL_REGISTRY[args.arch].build_model(args, task) File “c:.…\lib\site-packages\fairseq\models\multilingual_transformer.py”, line 162, in build_model encoders[lang_pair] = shared_encoder if shared_encoder is not None else get_encoder(src) File “c:.…\lib\site-packages\fairseq\models\multilingual_transformer.py”, line 137, in get_encoder task.dicts[lang], args.encoder_embed_dim, args.encoder_embed_path KeyError: ‘de’
It seems like it requires the second source language (de), but I really don’t know why, and how to solve this. I hope someone tells me what I am missing.
_Originally posted by @AyaNsar in https://github.com/pytorch/fairseq/issues/497#issuecomment-462551184_
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (7 by maintainers)
Top GitHub Comments
Thanks for reporting the error. This is a bug, and I will fix the problem shortly.
can’t thank you enough! It works like a charm