You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you use the code, please cite the following paper:
@article{han2021ptr,
title={PTR: Prompt Tuning with Rules for Text Classification},
author={Han, Xu and Zhao, Weilin and Ding, Ning and Liu, Zhiyuan and Sun, Maosong},
journal={arXiv preprint arXiv:2105.11259},
year={2021}
}
In this work, we propose prompt tuning with rules (PTR) for many-class text classification and apply logic rules to construct prompts with several sub-prompts. In this way, PTR is able to encode prior knowledge of each class into prompt tuning. You can find more details in our [paper](https://arxiv.org/pdf/2105.11259.pdf).
Requirements
The model is implemented using PyTorch. The versions of packages used are shown below.
numpy==1.18.0
scikit-learn==0.22.1
scipy==1.4.1
torch==1.4.0
tqdm==4.41.1
transformers==4.0.0
To set up the dependencies, you can run the following command:
pip install -r requirements.txt
Data Preparation
We have provided a scripts to download all the datasets we used in our paper. You can run the following command to download the datasets:
bash data/download.sh all
The above command will download all the datasets including
Retacred
Tacred
Tacrev
Semeval
If you only want to download a specific dataset, you can run the following command: