Giter VIP home page Giter VIP logo

conceptshap's Introduction

This is an implementation of the paper "On Concept-Based Explanations in Deep Neural Networks" https://arxiv.org/abs/1910.07969. This specific implementation applies the ConceptSHAP technique to BERT and other transformer-based language models via the Huggingface Transformers library. This implementation was developed by members of Machine Learning @ Berkeley for Intuit's Machine Learning Futures Group in Spring 2020.

Installation & Requirements

  • git clone https://github.com/arnav-gudibande/intuit-project.git
  • pip3 install -r requirements.txt

Pipeline Components

  • data
    • data/imdb-dataloader.py -- dataloader for the IMDB Movie Sentiment Dataset, contains options to format test/train data
    • data/20news-dataloder.py -- dataloader for 20NewsGroups dataset
  • model
    • bert-20news.py and bert-imdb.py -- training scripts for huggingface bert language model
    • bert_inference.py -- outputs embeddings generated from a trained transformer model for a target dataset
  • clustering
    • generateClusters.py -- k-means clustering of output embeddings
    • Note: this was discarded from the intitial conceptSHAP paper, but can still be used to test classical unsupervised methods against conceptSHAP
  • conceptSHAP
    • conceptNet.py -- trainable subclass that learns concepts
    • train_eval.py -- training script for conceptNet.py
    • interpretConcepts.py -- post-training concept analysis and tensorboard plotting

Example Usage

IMDB Sentiment Dataset

  • Download and format IMDB Dataset: sh data/imdb-dataloader.sh
  • Train BERT model on IMDB: sh model/bert-imdb.sh
  • Generate and save BERT embeddings: sh model/bert-inference_imdb.sh
  • Run ConceptSHAP: sh conceptSHAP/train_eval_imdb.sh

20NewsGroups Dataset

  • Download and format 20News: sh data/20news-dataloader.sh
  • Train BERT model on 20News: python3 model/bert-20news.py
  • Generate and save BERT embeddings: sh model/bert-inference_20news.sh
  • Run ConceptSHAP: sh conceptSHAP/train_eval_20news.sh

Tensorboard

  • tensorboard --logdir=runs --port=6006

conceptshap's People

Contributors

alexlu876 avatar annamiraotoole avatar arnav-gudibande avatar ryanjiaxc avatar tonyzhaozh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.