Skip to content
/ GenPT Public

[Findings of EMNLP 2022] Code of paper Generative Prompt Tuning for Relation Classification. https://arxiv.org/abs/2210.12435

Notifications You must be signed in to change notification settings

hanjiale/GenPT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GenPT

[Findings of EMNLP 2022] Generative Prompt Tuning for Relation Classification.

Requirements

  • python 3.6
  • PyTorch 1.7.1
  • transformers 4.10.1
  • numpy 1.19.2

Install dependencies

Please install all the dependency packages using the following command:

conda env create -f genpt.yaml
conda activate genpt

Prepare the data

We experiment our model on four relation classification datasets,

  1. TACRED
  2. TACREV
  3. Re-TACRED
  4. Wiki80

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.

Training

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.

Cite

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.

About

[Findings of EMNLP 2022] Code of paper Generative Prompt Tuning for Relation Classification. https://arxiv.org/abs/2210.12435

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published