Extract most important words from model
Hi, I was wondering if it is possible to extract the most positive word or the most negative word from a sentence. Say, we have a movie review like, “This movie is amazing” and the most relevant word for sentiment classification would be the word “amazing”. Is it possible to use a trained BERT model to extract/return such most prominent words from a sentence?Thanks.
2021-11-17T16:38:37Z
Hi,Yes that’s possible. There are some cool libraries out there that can be used to do that:ELI5:GitHub - TeamHG-Memex/eli5: A library for debugging/inspecting machine learning classifiers and explaining their predictionsLIME:GitHub - marcotcr/lime: Lime: Explaining the predictions of any machine learning classifierI believe it requires some tweaks to make it work on Transformer-based models, but I did this myself some time last year, so it’s definitely possible.Edit:this Github threadmight be helpful.
2021-11-17T16:51:14Z
Thanks a lot for the quick response. The github thread has a lot of useful pointers.Thanks!
2023-02-06T13:51:29Z
Update, another useful package isTransformers-interpret.