[Findings of EMNLP 2022] Generative Prompt Tuning for Relation Classification.
python 3.6
PyTorch 1.7.1
transformers 4.10.1
numpy 1.19.2
Please install all the dependency packages using the following command:
conda env create -f genpt.yaml
conda activate genpt
We experiment our model on four relation classification datasets,
Please download data from the official links and put it under the ./data/
.
The expected structure of files is:
GenPT
|-- data
| |-- tacred
| | |-- train.json
| | |-- dev.json
| | |-- test.json
| | |-- rel2id.json
| |-- tacrev
| | |-- ...
| |-- retacred
| | |-- ...
| |-- wiki80
| | |-- ...
Then use the following command to generate the few-shot data we need. Take the generation of k=8 on TACRED as an example,,
python code/generate_k_shot_data.py --data_dir data/tacred --output_dir data/tacred --k 8
The sampled few-shot data will be in data/tacred/k-shot
.
To run our model, use command in the root directory
bash scripts/run_tacred_bart.sh
The experiments can be conducted with one NVIDIA Quadro RTX 8000 with 48GB memory.
Please cite the following paper: "Generative Prompt Tuning for Relation Classification". Jiale Han, Shuai Zhao, Bo Cheng, Shengkun Ma, and Wei Lu. Findings of EMNLP, 2022.