This repo contains code to recreate the experiments in Abstraction Alignment: Comparing Model-Learned and Human-Encoded Conceptual Relationships. To explore the case studies in an live interactive interface instead, check out the abstraction alignment interface.
To explore abstraction alignment, check out the example notebooks.
In cifar_abstraction_alignment.ipynb
we use abstraction alignment to interpret image classification models, in language_model_abstraction_alignment.ipynb
we benchmark langugage model specificity, and in mimic_abstraction_alignment.ipynb
we analyze medical dataset encodings.
# Data storage
./cifar/ # Stores the CIFAR model and output data files
./wordnet/ # Stores the S-TEST data and the output data files
./mimic/ # Stores the MIMIC-III data and the output data files
# Code to extract interface data files
./extract_cifar_data.py
./extract_mimic_data.py
./extract_wordnet_data.py
# Notebooks to explore abstraction alignment
./cifar_abstraction_alignment.ipynb
./language_model_abstraction_alignment.ipynb
./mimic_abstraction_alignment.ipynb
# Supporting data files to compute abstraction alignment
metrics.py # abstraction alignment metrics
...
The CIFAR-100 data will autmatically download during analysis in the notebooks.
- Follow instructions to download the S-TEST dataset. Put it in a folder called
S-TEST
in theabstraction-alignment
repo. - Run
python S-TEST/scripts/run_experiments.py
to compute the model's output on the data. - Update the paths in
./extract_wordnet_data.py
to match your file structure.
- Request access to MIMIC-III via PhysioNet.
- Download the MIMIC-III dataset and update the paths in
./extract_mimic_data.py
to point to it.
To explore abstraction alignment, check out the example notebooks.
In cifar_abstraction_alignment.ipynb
we use abstraction alignment to interpret image classification models, in language_model_abstraction_alignment.ipynb
we benchmark langugage model specificity, and in mimic_abstraction_alignment.ipynb
we analyze medical dataset encodings.
The code in extract_{cifar/wordnet/mimic}_data.py
creates the data files needed to run the abstraction alignment interface. Run these if you'd like to run the abstraction alignment interface locally or reference them for the data file set up to run the interface with your own data.