Code Monkey home page Code Monkey logo

genpt's Introduction

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.

genpt's People

Contributors

hanjiale avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.