allenai / vampire

Variational Methods for Pretraining in Resource-limited Environments
Apache License 2.0
174 stars 33 forks source link

Incorrect mask type in Seq2Seq encoder #68

Open david-waterworth opened 3 years ago

david-waterworth commented 3 years ago

The seq2seq implementation of mean and max pooling crashes using allennlp 2.7 and pytorch 1,8

The issue is that both mean and max pooling mask the encoded output by converting the original mask from bool to float and multiplying. This masked tensor is then passed to masked_mean or masked_max along with the float mask, but masked_mean or masked_max require a bool mask, 'masked_max` fails on the first line

vector.masked_fill(~mask, min_value_of_dtype(vector.dtype))

It seems unnecessary in the first place to mask the embeddings since that's done in masked_mean or masked_max