Hi everyone,
I am working on the creation of saliency maps for MultiFiT classification models, with the ultimate goal of highlighting over the text those parts that are decisive in making a prediction.
In order to make the saliency maps, on the one hand I need to obtain the activations of a designated layer of the model using a hook, and on the other hand I need the tokenized text and its tensor form. In this way I can relate the activations to the input text that caused those activations.
The question is, how can i get the tokenized text and its corresponding input tensor that the MultiFiT model receives when doing a prediction?, taking into account that those operations are done internally by MultiFiT.
Hi Marcin, first of all, thanks for your reply.
Iâve had a look at text.interpret , and it looks pretty interesting.
Unfortunately Iâve been testing it with my trained multifit model, and at the moment I have not managed to get it to work.
When I try : interp = TextClassificationInterpretation.from_learner(my_learner) It gives me the following error: âIndexError: list index out of rangeâ.
However, multifit model is used following this repository(original) and works fairly good. Any idea of what could be happening? Maybe the text interpreter doesnât work well with multifit?
By default from_learner computes predictions on a validation set to use them in show_top_losses. Do you have any item in your validation set?
If youâre using an exported learner with an empty databunch and you care only about the intrinsic attention, you can try something like:
Thanks for this!
The default behaviour seem quite unintuitive. In my case I was looking show the attention for new phrases coming from users, so a validation set does not come into play.