Code and datasets for our paper "AutoCAD: Automatically Generating Counterfactuals for Mitigating Shortcut Learning"
[Oct 13 2022] Code released
- python >= 3.8
pip install -r requirements.txt
- Run
unzip data.zip
Before running the code, please change the WORKING_DIR
in the script according to your own path.
bash scripts/train.sh
-
get gradient-based saliency scores:
bash scripts/saliency.sh
-
get rationale-corrupted data:
python tools/highlight.py
- train a counterfactual generator on the rationale-corrupted data:
bash scripts/train_generator.sh
- generate counterfactuals on the label-flipped rationale-corrupted data:
bash scripts/generate.sh
- predict the label of the generated counterfactuals with the fine-tuned classifier:
bash scripts/predict.sh