This repository is the official implementation of our ACL'24 Findings paper Contrastive Instruction Tuning.
Experiments are run in the following environment:
| Package | Version |
|---|---|
| conda | 22.9.0 |
| Python | 3.8 |
| CUDA | 11.8 |
conda create -n coin python=3.8
conda activate coin
pip install -r requirements.txt
The original data source of our new dataset is the FLAN collection, specifically from Muennighoff/flan on Huggingface. The model we used is Alpaca trained with LoRA. We used code from Alpaca-LoRA as a starting point and added our implementations. We follow the steps discussed in section 3.2 of the paper to curate dataset for CoIN, which is available here.
original_instruction)paraphrased_instruction)targets)Parameters are defined in run_contrastive.sh. Check ContrastiveLlamaTrainingArgument in run_contrastive_llama.py for more details regarding default values of all parameters.
bash scripts/run_contrastive.sh
do_contrastive to FALSE.In this project, we follow PromptBench to add perturbations to instructions. All perturbed instructions for 10 GLUE tasks are available here. To evaluate a model, please:
checkpoint_dir to the path of your checkpoint/output directorybash scripts/eval_contrastive.sh
perturb_method and promptbench_eval_task to evaluate the model on different perturbation methods and evaluation tasks. Supported perturbation methods and tasks are available in the bash script and UnseenInstructionEvalArgs in run_contrastive_llama.py.To obtain average accuracy(exact match) and standard deviation of the model on the perturbed instructions for each task, please run:
python promptbench/postprocessing.py --output_dir "YOUR_OUTPUT_DIR"
preds under your model's checkpoint directory.YOUR_OUTPUT_DIR with the path where the outputs are stored (e.g. output/CoIN/preds).unseen_instruction_acc.csv under YOUR_OUTPUT_DIR.@inproceedings{yan2024contrastive,
title={Contrastive Instruction Tuning},
author={Yan, Lorena Tianyi and Wang, Fei and Huang, James Y and Zhou, Wenxuan and Yin, Fan and Galstyan, Aram and Yin, Wenpeng and Chen, Muhao},
booktitle={ACL - Findings},
year={2024}
}
4 commits
1 commits
Python
99.8%
This repository is the official implementation of our ACL'24 Findings paper Contrastive Instruction Tuning.
Experiments are run in the following environment:
| Package | Version |
|---|---|
| conda | 22.9.0 |
| Python | 3.8 |
| CUDA | 11.8 |
conda create -n coin python=3.8
conda activate coin
pip install -r requirements.txt
The original data source of our new dataset is the FLAN collection, specifically from Muennighoff/flan on Huggingface. The model we used is Alpaca trained with LoRA. We used code from Alpaca-LoRA as a starting point and added our implementations. We follow the steps discussed in section 3.2 of the paper to curate dataset for CoIN, which is available here.
original_instruction)paraphrased_instruction)targets)Parameters are defined in run_contrastive.sh. Check ContrastiveLlamaTrainingArgument in run_contrastive_llama.py for more details regarding default values of all parameters.
bash scripts/run_contrastive.sh
do_contrastive to FALSE.In this project, we follow PromptBench to add perturbations to instructions. All perturbed instructions for 10 GLUE tasks are available here. To evaluate a model, please:
checkpoint_dir to the path of your checkpoint/output directorybash scripts/eval_contrastive.sh
perturb_method and promptbench_eval_task to evaluate the model on different perturbation methods and evaluation tasks. Supported perturbation methods and tasks are available in the bash script and UnseenInstructionEvalArgs in run_contrastive_llama.py.To obtain average accuracy(exact match) and standard deviation of the model on the perturbed instructions for each task, please run:
python promptbench/postprocessing.py --output_dir "YOUR_OUTPUT_DIR"
preds under your model's checkpoint directory.YOUR_OUTPUT_DIR with the path where the outputs are stored (e.g. output/CoIN/preds).unseen_instruction_acc.csv under YOUR_OUTPUT_DIR.@inproceedings{yan2024contrastive,
title={Contrastive Instruction Tuning},
author={Yan, Lorena Tianyi and Wang, Fei and Huang, James Y and Zhou, Wenxuan and Yin, Fan and Galstyan, Aram and Yin, Wenpeng and Chen, Muhao},
booktitle={ACL - Findings},
year={2024}
}
4 commits
1 commits
Python
99.8%