-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to visulaize attentions for Hugging face custom models #676
Comments
To return values from predict_minibatch, need to convert that tensor([0.6403, 0.3597]) into a raw array of just [0.6403, 0.3597] as opposed to a tensor |
In which line of code? |
Not sure, you should check all your entries in batched_output to be sure they are normal python lists and not tensors. It might be the 'probas' entry that is the issue here. |
Updated the code but getting this warning not error. |
@jameswex how can I launch the app in jupyter notebook itself instead as web page? How can I modify above code to do it? |
@jameswex second question is, how to get gradient visulaization in salience maps. In the above code? |
When I change to PCA viz its gives |
To run in a notebook, in your jupyter notebook, create your dataset and model classes and then create a LitWidget object with those objects and call render on it. An example can be seen here https://colab.sandbox.google.com/github/PAIR-code/lit/blob/main/lit_nlp/examples/notebooks/LIT_sentiment_classifier.ipynb in colab, but the code would be the same in jupyter. If you want to see gradient-based salience methods in the LIT UI, then your model will need to have the apporpriate inputs and outputs to support them. See https://github.com/PAIR-code/lit/wiki/components.md#token-based-salience for details for having your model support the different salience methods. |
|
The model and dataset code shouldn't change for notebooks. It's just that you create a LitWidget with the model and datasets, instead of a Server. Then you call render on the widget object. I'm not sure about the root cause of that specific error. It's most likely that your predict_minibatch fn is returning some value for one of its fields for each example that isn't a basic, JSON-serializable type. |
Converted all to list. Still same error.
|
Can you print the contents of The error above:
Looks like the value is a complex number |
@iftenney here is the outputs. batched_outputs after for loop
batched_output key and value batched_output key and value
detached_outputs
|
Thanks, all of those values look okay although the indentation is very strange so I could be missing something. |
@pratikchhapolika |
Here is the code:
In the tool it gives the following error:
The text was updated successfully, but these errors were encountered: