Getting a fairseq error: ModuleNotFoundError: No module named 'fairseq.data.masked_lm_dictionary

619 Views Asked by At

I'm trying to implement MASS on Fairseq for Neural Machine Translation. Following the approach here https://github.com/microsoft/MASS/tree/master/MASS-supNMT, I'm trying to preprocess both the monolingual and bilingual data. I didn't get any errors while processing monolingual data; however, I'm getting the error while doing for bilingual.

from fairseq.data.masked_lm_dictionary import MaskedLMDictionary ModuleNotFoundError: No module named 'fairseq.data.masked_lm_dictionary'

I'm using Fairseq version 0.12.2. I'm unable to figure out the reason behind the error.

2

There are 2 best solutions below

1
On

According to this file, you could use the MaskedLMDictionary as a class. To import it you can use the following code:

from fairseq.data import Dictionary

This doesn't return the error you mentioned.

0
On

In the source code for xmasked_seq2seq, I changed from fairseq.data.masked_lm_dictionary to from fairseq.data.legacy.masked_lm_dictionary. This worked for me