Help with using Interpret with Basic Classifier?


I’m new to AllenNLP and just built a text classifier using the text_classification_json dataset reader and basic_classifier model. I loved the Interpret and Attack demo for Sentiment Analysis and would love to use them to better understand my own model. I’ve looked over the demo code and tried to replicate what was done for the Sentiment Analysis example but, unfortunately, haven’t been able to work for my model so far.

Using the following code, I can get results from interpreter for the demo Sentiment Analysis model with GloVe embeddings . However, the exact same code returns nothing for the interpreter with my own model, though up to prediction works fine.

Does anyone have any idea what I might be doing wrong or suggestions for what I could try ? Thanks in advance for your time !


Here’s the interpreter output for the demo model :


And the interpret output for my own model:


I think the most common reason that you might see this is that your embedding layer has requires_grad=False set somehow. See and for some more detail on this. If those don’t solve your problem, I’m going to need some more info about what exactly your model looks like in order to help you.

Thank you for the suggestions! I’ll try these out and see if they help.

Changing trainable to true for token embedding helped. Thank you so much for pointing me in the right direction !

A note – something that might cause confusion for other newbies trying to get started is that the config file for the Sentiment Analysis model provided on github has trainable set to false. I was following along with this, so wouldn’t have thought that would cause a problem.