talktomodel

TalkToModel gives anyone with the powers of XAI through natural language conversations 💬!

https://github.com/dylan-slack/talktomodel

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.8%) to scientific vocabulary

Keywords

ai conversational-ai conversationalxai dialogue-systems explainability explainable-artificial-intelligence explainable-ml explanation interpretability interpretable-machine-learning machine-learning-library machine-learning-papers ml paper-implementation papers xai
Last synced: 6 months ago · JSON representation ·

Repository

TalkToModel gives anyone with the powers of XAI through natural language conversations 💬!

Basic Info
Statistics
  • Stars: 120
  • Watchers: 5
  • Forks: 25
  • Open Issues: 4
  • Releases: 3
Topics
ai conversational-ai conversationalxai dialogue-systems explainability explainable-artificial-intelligence explainable-ml explanation interpretability interpretable-machine-learning machine-learning-library machine-learning-papers ml paper-implementation papers xai
Created over 3 years ago · Last pushed over 2 years ago
Metadata Files
Readme License Citation

README.md

drawing

TalkToModel: Explaining Machine Learning Models with Interactive Natural Language Conversations

Python application arXiv

Welcome to the TalkToModel paper page! The goal of this project is to enable anyone to understand the predictions of a trained machine learning model through a natural language conversation. Ultimately, it is a platform for conversational XAI!

    drawing

Links

If you found this work useful, please cite us!

bibtex @Article{Slack2023, author={Slack, Dylan and Krishna, Satyapriya and Lakkaraju, Himabindu and Singh, Sameer}, title={Explaining machine learning models with interactive natural language conversations using TalkToModel}, journal={Nature Machine Intelligence}, year={2023}, month={Jul}, day={27}, abstract={Practitioners increasingly use machine learning (ML) models, yet models have become more complex and harder to understand. To understand complex models, researchers have proposed techniques to explain model predictions. However, practitioners struggle to use explainability methods because they do not know which explanation to choose and how to interpret the explanation. Here we address the challenge of using explainability methods by proposing TalkToModel: an interactive dialogue system that explains ML models through natural language conversations. TalkToModel consists of three components: an adaptive dialogue engine that interprets natural language and generates meaningful responses; an execution component that constructs the explanations used in the conversation; and a conversational interface. In real-world evaluations, 73{\%} of healthcare workers agreed they would use TalkToModel over existing systems for understanding a disease prediction model, and 85{\%} of ML professionals agreed TalkToModel was easier to use, demonstrating that TalkToModel is highly effective for model explainability.}, issn={2522-5839}, doi={10.1038/s42256-023-00692-8}, url={https://doi.org/10.1038/s42256-023-00692-8} }

[UPDATE] This work won an honorable mention outstanding paper at the TSRML Workshop at NeurIPS 🎉

We additionally wrote a precursor paper about domain experts needs for understanding models, that helped inspire this work. It's called Rethinking Explainability as a Dialogue: A Practitioner's Perspective. Check that out as well!

Table of Contents

Overview

Here follows a brief overview of the purpose and scope of the system.

Purpose

As machine learning models are being increasingly integrated in our day-to-day lives, it becomes important that anyone can interact with and understand them. TalkToModel helps realize this goal and enables anyone to chat with a machine learning model to understand the model's predictions.

Please read our paper for more motivation and details about how the system works.

Scope

TalkToModel supports tabular models and datasets. For example, you could use the system to chat with a random forest trained on a loan prediction task but not BERT trained on a sentiment analysis task, in the system's current form.

Installation

To run TalkToModel, you can either setup a conda environment or use Docker to directly run the Flask App.

Note, for GPU inference, the environment requires CUDA 11.3. If you do not have cuda 11.3 and try and run the docker application, it will crash! One way around this is to switch to cpu inference. It will be a bit slower (instructions), but should work.

Docker

If you want to use Docker, you can skip this setup step ⏭️

Conda

Create the environment and install dependencies.

shell conda create -n ttm python=3.9 conda activate ttm

Install the requirements

shell pip install -r requirements.txt

Nice work 👍

Running A Pre-Configured TalkToModel Demo

Next, we discuss how to run the Flask Application on one of the datasets and models from the paper. These include a diabetes, crime, and credit prediction task.

Configuration

Here, we talk about choosing a demo + parsing model. If you just want to run the demo on the diabetes dataset, you can skip to Running With Conda or Running With Docker.

Choosing a Demo & Parsing Model

This software is configured using gin-config. Global parameters are stored in ./global_config.gin and demo specific parameters are stored in the ./configs directory, e.g., ./configs/diabetes-config.gin for the diabetes prediction demo.

This repo comes configured using a fine-tuned t5-small model for the diabetes prediction task, but this can be changed by modifying ./global_config.gin:

shell GlobalArgs.config = "./configs/{demo}-config.gin"

and changing {demo} to one of diabetes, compas, or german respectively. Further, we provide our best fine-tuned t5-small and t5-large parsing models on the huggingface hub. These can be selected by modifying ./configs/{demo}-config.gin:

```shell

For the t5 small model

ExplainBot.parsingmodelname = "ucinlp/{demo}-t5-small"

For the t5 large model

ExplainBot.parsingmodelname = "ucinlp/{demo}-t5-large" ```

and the respective parsing model will be downloaded from the hub automatically.

GPU Availability

By default, the system will try to push the models to a cuda device and will crash if one isn't available. To switch to CPU inference or to use a different cuda device, modify ./parsing/t5/gin_configs/t5-large.gin

shell load_t5_params.device = "{device}"

where {device} is the device you want (e.g., cpu).

Running With Conda

If you installed the conda environment, to launch the Flask web app you can run shell python flask_app.py

Running With Docker

If you want to run with Docker, you can build the docker app

shell sudo docker build -t ttm .

And then run the image

shell sudo docker run -d -p 4000:4000 ttm

Use It!

It might take a minute or two to build the application. The reason is that we cache a fair number of computations (mostly explanations) beforehand to improve the realtime user experience. For reference, on my M1 macbook pro, building from scratch takes about 5 minutes. However, after your first time running a demo, these computations will be stored in the ./cache folder, and it is not necessary to compute them again, so startup should be very quick.

That's it! The app should be running 💥

Experiments

Here, we discuss running experiments from the paper. For these experiments, make sure to set

ExplainBot.skip_prompts = False

in each of the diabetes, german, and compas gin config files, so that the system generates the prompts for each dataset. We set this to True for the fine-tuned demo parsing models, because it is unnecessary in this case and speeds up the startup time significantly.

Fine-tuning Models

To fine-tune a parsing model, run

shell python parsing/t5/start_fine_tuning.py --gin parsing/t5/gin_configs/t5-{small, base, large}.gin --dataset {diabetes, german, compas}

where {small, base, large} and {diabetes, german, compas} are one of the values in the set. Note, these experiments require use Weights & Biases to track training and the best validation model.

For simplicity, we also provide all the best validation pre-trained models for download on huggingface: https://huggingface.co/dslack/all-finetuned-ttm-models. You can download these models from the provided zip file, and unzip the models to ./parsing/t5/models.

Evaluating Gold Parsing Accuracy

With all the models downloaded, you can compute the parsing accuracies by running

shell python experiments/generate_parsing_results.py

The results will be deposited in the ./experiments/results_store directory.

Running on Your Own Model & Dataset

Please see the tutorial ./tutorials/running-on-your-own-model.ipynb for a step-by-step walk-through about how to do this, and the different options you have for setting up the conversation.

Development

TalkToModel can be extended to include new functionality pretty easily. Please see ./tutorials/extending-ttm.md for a walk-through on how to extend the system.

Testing

You can run the tests by running pytest from the base directory.

Citation

Cite us 🫶

bibtex @Article{Slack2023, author={Slack, Dylan and Krishna, Satyapriya and Lakkaraju, Himabindu and Singh, Sameer}, title={Explaining machine learning models with interactive natural language conversations using TalkToModel}, journal={Nature Machine Intelligence}, year={2023}, month={Jul}, day={27}, abstract={Practitioners increasingly use machine learning (ML) models, yet models have become more complex and harder to understand. To understand complex models, researchers have proposed techniques to explain model predictions. However, practitioners struggle to use explainability methods because they do not know which explanation to choose and how to interpret the explanation. Here we address the challenge of using explainability methods by proposing TalkToModel: an interactive dialogue system that explains ML models through natural language conversations. TalkToModel consists of three components: an adaptive dialogue engine that interprets natural language and generates meaningful responses; an execution component that constructs the explanations used in the conversation; and a conversational interface. In real-world evaluations, 73{\%} of healthcare workers agreed they would use TalkToModel over existing systems for understanding a disease prediction model, and 85{\%} of ML professionals agreed TalkToModel was easier to use, demonstrating that TalkToModel is highly effective for model explainability.}, issn={2522-5839}, doi={10.1038/s42256-023-00692-8}, url={https://doi.org/10.1038/s42256-023-00692-8} }

Contact

You can reach out to dslack@uci.edu with any questions or issues you're running into.

Please do reach out or submit an issue, because I would love to help you get it running, especially on your own models and data ❤️!

Owner

  • Name: Dylan Slack
  • Login: dylan-slack
  • Kind: user

UC Irvine CS PhD student working on making machine learning models more robust and interpretable.

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this research, please cite it as below."
authors:
- family-names: "Slack"
  given-names: "Dylan"
- family-names: "Krishna"
  given-names: "Satyapriya"
- family-names: "Lakkaraju"
  given-names: "Himabindu"
- family-names: "Singh"
  given-names: "Sameer"
title: "TalkToModel: Explaining Machine Learning Models with Interactive Natural Language Conversations"
date-released: 2022-08-27
url: "https://github.com/dylan-slack/TalkToModel"
preferred-citation:
  type: article
  authors:
  - family-names: "Slack"
    given-names: "Dylan"
  - family-names: "Krishna"
    given-names: "Satyapriya"
  - family-names: "Lakkaraju"
    given-names: "Himabindu"
  - family-names: "Singh"
    given-names: "Sameer"
  journal: "TSRML @ NeurIPS"
  archivePrefix: "tsrml"
  eprint: "2207.04154"
  title: "TalkToModel: Explaining Machine Learning Models with Interactive Natural Language Conversations"
  year: 2022

GitHub Events

Total
  • Issues event: 2
  • Watch event: 11
  • Pull request event: 2
  • Fork event: 3
Last Year
  • Issues event: 2
  • Watch event: 11
  • Pull request event: 2
  • Fork event: 3

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 2
  • Total pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: 4 minutes
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: 4 minutes
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • alex-berman (2)
Pull Request Authors
  • divyansh4014-png (1)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

requirements.txt pypi
  • Flask ==2.0.3
  • GitPython ==3.1.27
  • Jinja2 ==3.1.1
  • MarkupSafe ==2.1.1
  • Pillow ==9.0.1
  • PyJWT ==2.3.0
  • PyWavelets ==1.3.0
  • PyYAML ==6.0
  • Werkzeug ==2.0.3
  • attrs ==21.4.0
  • boto3 ==1.21.27
  • botocore ==1.24.27
  • certifi ==2021.10.8
  • charset-normalizer ==2.0.12
  • click ==8.0.4
  • cloudpickle ==2.1.0
  • cycler ==0.11.0
  • dice-ml ==0.7.2
  • docker-pycreds ==0.4.0
  • et-xmlfile ==1.1.0
  • filelock ==3.6.0
  • fonttools ==4.31.2
  • gin-config ==0.5.0
  • gitdb ==4.0.9
  • gunicorn ==20.1.0
  • h5py ==3.6.0
  • huggingface-hub ==0.4.0
  • idna ==3.3
  • imageio ==2.16.1
  • inflect ==5.4.0
  • iniconfig ==1.1.1
  • itsdangerous ==2.1.2
  • jmespath ==1.0.0
  • joblib ==1.1.0
  • jsonschema ==4.4.0
  • kiwisolver ==1.4.0
  • lark ==1.1.2
  • lime ==0.2.0.1
  • llvmlite ==0.39.0
  • matplotlib ==3.5.1
  • networkx ==2.7.1
  • nltk ==3.7
  • numba ==0.56.0
  • numpy ==1.21.6
  • openai ==0.16.0
  • openpyxl ==3.0.9
  • packaging ==21.3
  • pandas ==1.4.1
  • pandas-stubs ==1.2.0.53
  • pathtools ==0.1.2
  • patsy ==0.5.2
  • pluggy ==1.0.0
  • promise ==2.3
  • protobuf ==3.20.1
  • psutil ==5.9.1
  • py ==1.11.0
  • pyparsing ==3.0.7
  • pyrsistent ==0.18.1
  • pytest ==7.1.1
  • python-dateutil ==2.8.2
  • pytz ==2022.1
  • regex ==2022.3.15
  • requests ==2.27.1
  • s3transfer ==0.5.2
  • sacremoses ==0.0.49
  • scikit-image ==0.19.2
  • scikit-learn ==1.0.2
  • scipy ==1.8.0
  • sentence-transformers ==2.2.0
  • sentencepiece ==0.1.95
  • sentry-sdk ==1.9.5
  • setproctitle ==1.3.2
  • shap ==0.40.0
  • shortuuid ==1.0.9
  • six ==1.16.0
  • sklearn ==0.0
  • slicer ==0.0.7
  • smmap ==5.0.0
  • statsmodels ==0.13.2
  • threadpoolctl ==3.1.0
  • tifffile ==2022.3.25
  • tokenizers ==0.11.6
  • tomli ==2.0.1
  • torch ==1.12.1
  • torchvision ==0.13.1
  • tqdm ==4.63.1
  • transformers ==4.17.0
  • twilio ==7.8.0
  • typing_extensions ==4.1.1
  • urllib3 ==1.26.12
  • wandb ==0.13.2
  • word2number ==1.1
  • wordninja ==2.0.0
.github/workflows/python-app.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
Dockerfile docker
  • python 3.9.7 build