robinvanschaik / interpret-flair Goto Github PK
View Code? Open in Web Editor NEWA small repository to test Captum Explainable AI with a trained Flair transformers-based text classifier.
License: MIT License
A small repository to test Captum Explainable AI with a trained Flair transformers-based text classifier.
License: MIT License
Flair offers multiple types of text classification models.
From transformers-based models via huggingface (currently implemented) to word embeddings.
Restructuring to allow for other types models would be nice.
Hi Robin,
I found an error when I test with the pre-trained sentiment model from Flair. Simply loading with
classifier = TextClassifier.load('sentiment')
flair_model_wrapper = ModelWrapper(classifier)
And the rest is the same as yours. I got this error when I call the function interpret_sentence.
I test and print out the device. It turns out that the variable input_ids in function interpret_sentence is on cpu. My clumsy solution is to add
input_ids = input_ids.to(device)
after line
input_ids = flair_model_wrapper.tokenizer.encode(...)
There might be other internal solutions.
BTW, this work helps a lot!
I was unable to upload the best-model.pt file as it larger than 100MB. I am looking into GitHub LFS.
The readme.md does not show the red / green word importances in the table.
Replace the table with a screenshot.
As target_label only accept single values, making it work on multi class problems is not so simple. I have written a simple looping function to iterate over the correct target labels, but as on Flair 0.8post1, I find that predictions of the interpret_sentence class deviate from the orginal multi class model (i.e. wrong class prediction).
On personal note: I think you have done a really good job in building this solution. It has worked wonders for multi label problems already.
This branch tracks the progress of adding the SHAP explainer to the repo.
Currently running into some bugs.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.