Fast.ai library Text.py/NLP.py no longer working for lang_model.ipynb

I’m trying to redo a variant of the sentiment analysis task that we implemented as part of lesson 4 using text.py and I’m running into an issue.

If I try using nlp.py I’m running into an issue when I call learner.lr_find() or learner.fit() where the model expects a target size that doesn’t take batch size into account.

ValueError: Expected target size (40, 200), got torch.Size([40, 12, 200])

I tried switching over to the text.py variant, but the structure of the data loader has changed significantly and I don’t have any frame of reference as to what the parameters are that I need to fill in.

----> 1 md = LanguageModelData(PATH, TEXT, **FILES, bs=bs, bptt=bptt, min_freq=30)
TypeError: init() missing 3 required positional arguments: ‘nt’, ‘trn_dl’, and ‘val_dl’

Are there notebooks available that make use of text.py and load the data from text files? Flagging @jeremy as i’m not sure who else to reach out to.

I’ve updated both my version of the library and pytorch. I’ve event tried redownloading from scratch, so I’m guessing other students are running into this as well.

1 Like

It seems like RNN_Encoder(nn.Module): is somehow not taking batch size into account.

   self.bs = 1

Batchsize is being hardcoded to 1, which is causing the model to fail when it’s passed a batch.

It used to without issue, so i’m not sure what’s going on here. :frowning:

Are you up to date with fastai and the python packages?

I’ve verified it’s an issue. In the migration to text.py (the new version of nlp.py) the library underwent significant changes that broke the language model examples that use nlp.py.

I’ve managed to get it working by rolling the library back to the PR before the NLP changes were made. I’m guessing by V2 Jeremy will have it sorted out, but in the meantime it’s a simple fix to just checkout the older version of the library.