cdpierse / transformers-interpret

Model explainability that works seamlessly with 🤗 transformers. Explain your transformers model in just 2 lines of code.
Apache License 2.0
1.27k stars 96 forks source link

Make MultiLabelClassificationExplainer use sigmoid activation, added MultiClassClassificationExplainer, labels sorted according to label id #120

Closed SimonLinnebjerg closed 1 year ago

SimonLinnebjerg commented 1 year ago

Changed activation function applied to output logits in class MultiLabelClassificationExplainer. Is now using sigmoid. Added a class MultiClassClassificationExplainer that uses softmax on output logits like MultiLabelClassificationExplainer used to do.

Sorting of labels is done according to the label index instead of default sorting.

Motivation and Context

the multi-label class MultiLabelClassificationExplainer should be implemented with sigmoid instead of softmax on the output.

To keep the multi-class functionality, a new class MultiClassClassificationExplainer is created. (which might cause issues/confusion for existing users)

I also made a minor change to the ordering of labels (as i think theres a bug with these too). I believe the ordering of the labels should follow the ids in the label2id dict. without sorting based on the id, the labels are swapped in the output html file generated with the visualize() function References issue: #107

Tests and Coverage

Instantiated and vizualised MultiLabelClassificationExplainer and MultiClassClassificationExplainer and verified HTML output.

Types of changes

Final Checklist: