Giter Club home page Giter Club logo

paie's Introduction

PAIE (Prompting Argument Interaction for Event Argument Extraction)

This is the implementation of the paper Prompt for Extraction? PAIE: Prompting Argument Interaction for Event Argument Extraction. ACL'2022.

Quick links

Overview

In this work we present PAIE: a simple, effective and low resource-required approach for sentence-/document-level event argument extraction. We formulate our contribution as follow.

  1. We formulate and investigate prompt tuning under extractive settings.
  2. We extract multiple roles using a joint prompt once a time. It not only considers the interaction among different roles but also reduce time complexity significantly.

Preparation

Environment

To run our code, please install all the dependency packages by using the following command:

pip install -r requirements.txt

Data

We conduct experiments on three common datasets: ACE05, RAMS and WIKIEVENTS.

  • ACE05: This dataset is not freely available. Access from LDC and preprocessing following EEQA (2020'EMNLP).
  • RAMS / WIKIEVENTS: We write a script for you for data processing. Run the following commands in the root directory of the repo.
bash ./data/download_dataset.sh

Please make sure your data folder structure as below.

data
  ├── ace_eeqa
  │   ├── train_convert.json
  │   ├── dev_convert.json
  │   └── test_convert.json
  ├── RAMS_1.0
  │   └── data
  │       ├── train.jsonlines
  │       ├── dev.jsonlines
  │       └── test.jsonlines
  ├── WikiEvent
  │   └── data
  │       ├── train.jsonl
  │       ├── dev.jsonl
  │       └── test.jsonl
  ├── prompts
  │   ├── prompts_ace_full.csv
  │   ├── prompts_wikievent_full.csv
  │   └── prompts_rams_full.csv
  └── dset_meta
      ├── description_ace.csv
      ├── description_rams.csv
      └── description_wikievent.csv

Run the model

Quick start

You could simply run PAIE with following commands:

bash ./scripts/train_{ace|rams|wikievent}.sh

Folders will be created automatically to store:

  1. Subfolder checkpoint: model parameters with best dev set result
  2. File log.txt: recording hyper-parameters, training process and evaluation result
  3. File best_dev_results.log/best_test_related_results.log: showing prediction results of checkpoints on every sample in dev/test set.

You could see hyperparameter setting in ./scripts/train_[dataset].sh and config_parser.py. We give most of hyperparameters a brief explanation in config_parser.py.

Above three scripts train models with BART-base. If you want to train models with BART-Large, please change --model_name_or_path from facebook/bart-base to facebook/bart-large or run following commands:

bash ./scripts/train_{ace|rams|wikievent}_large.sh

Experiments with multiple runs

Table.3 of our paper shows the fluctuation of results due to random seed and other hyperparameters (learning rate mainly). You could run experiments multiple times to get a more stable and reliable results.

for seed in 13 21 42 88 100
do
    for lr in 1e-5 2e-5 3e-5 5e-5
    do
        bash ./scripts/train_{ace|rams|wikievent}.sh $seed $lr
    done
done

Each run will take ~4h so we highly recommend you to execute above command in parallel way.

Without-bipartite-loss

You could run PAIE without bipartite matching loss by delete the command argument --bipartite or run following commands:

bash ./scripts/train_{ace|rams|wikievent}_nobipartite.sh

Joint-prompt-or-not

Unlike multiple prompt strategy in PAIE, you could also prompt argument using template containing only one role (single prompt). Try it by changing --model_type from paie to base and set proper hyperparameters: --max_span_num, --max_dec_seq_length and --th_delta. Alternatively you could run following commands directly with hyperparameters we tuned:

bash ./scripts/train_{ace|rams|wikievent}_singleprompt.sh

Manual-prompt-or-others

Besides manual prompt, provide another two joint-prompt choices as described in Section 3.2 of our paper. We concelude them in the following:

  1. (Default setting) Manual Prompt: All roles are connected manually with natural language
  2. Concatenation Prompt: To concatenate all role names belonging to one event type.
  3. Soft Prompt: Following previous work about continuous prompt, we connect different roles with learnable, role-specific pseudo tokens.

Run following commands if you want to try Concatenation Prompt:

bash ./scripts/train_{ace|rams|wikievent}_concatprompt.sh

Run following commands if you want to try Soft Prompt:

bash ./scripts/train_{ace|rams|wikievent}_softprompt.sh

Few-shot-setting

PAIE also performs well under low-annotation scenario. You could try it by set hyperparameters --keep_ratio to a number between 0 to 1, which controls the resampling rate from the original training examples. Simply you could also run scripts below:

KEEP_RATIO=0.2 bash ./scripts/train_{ace|rams|wikievent}_fewshot.sh

Note you could adjust the KEEP_RATIO value by yourself.

Citation

Please cite our paper if you use PAIE in your work:

@inproceedings{ma-etal-2022-prompt,
    title = "{P}rompt for Extraction? {PAIE}: {P}rompting Argument Interaction for Event Argument Extraction",
    author = "Ma, Yubo  and
      Wang, Zehao  and
      Cao, Yixin  and
      Li, Mukai  and
      Chen, Meiqi  and
      Wang, Kun  and
      Shao, Jing",
    booktitle = "Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
    month = may,
    year = "2022",
    address = "Dublin, Ireland",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2022.acl-long.466",
    doi = "10.18653/v1/2022.acl-long.466",
    pages = "6759--6774",
}

paie's People

Contributors

mayubo2333 avatar zehao-wang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

paie's Issues

关于Head-C 指标

您好,请问该指标只用判断 论元的head span正确就可以了吗?是否还要求角色也识别正确?
因为我看BartGen代码里似乎是head word span + role name

cuda device

hello,
how to chage the number of gpu?
It doesn't work when I add ''os.environ['CUDA_VISIBLE_DEVICES'] = "2"", and I didn't find where is the code that you set gpu.

How to learn pesudo tokens in soft prompt ?

It may be a silly question but haunts in my mind. As mentioned in the paper, pesudo tokens in soft prompts are learnable. However, I found the training process of PAIE with soft prompt is pretty similar to PAIE with manual prompts. They share the same model architecture which means, when backwarding, the loss object are from the same model. So how to learn pseudo tokens? In the paper, you mentioned that you follow two previous method, but how to implement them in PAIE code?

prompt full data

why the prompt template have "prompt start" and " end" ,which is not show in the paper . Is it get an better result ?

How to add a new dataset

Thanks for your code! I have some questions about how to add a new dataset. I think there are 3 steps to add a new dataset:

  1. Place the data in the ./data folder.
  2. Add data reading code in DSET_processor class in processor_base.py file. And modify some details such as arg parser and build_processor.
  3. Add the description file in ./data/dset_meta folder and the prompt file in ./data/prompts folder.
    Then I can run the code to train/infer on my own dataset. Are there any misunderstandings? Thank you!

About result comparison

Hello author,

Thanks for sharing the code. I have one question when reading the paper w.r.t. the result comparison with the baseline BART-Gen. Some results in Table 2 of your paper have mismatches with the results in the paper of BART-Gen. For example, the Arg-I Arg-C Head-C numbers for WIKIEVENTS are 66.8 62.4 65.4, but I can't find exactly the same numbers in either Table 5 or 6 in the paper of BART-Gen. Are these results reproduced by yourself? If so, it seems that they are very different from the numbers in the original paper.
no offense, but just confused about this issue. Did I miss some experimental details?

ACE05数据集

ACE05数据集在LDC网站上好像不是免费下载的,请问您是否可以提供一下这个数据集呢?希望能尽快得到您的回复!

Question about evaluation on RAMS dataset

Hello, nice work, and thanks for sharing the code!

I have a question about the RAMS dataset. It looks like some arguments get dropped because of the window size. Were the dropped arguments included in the final test set? Thank you very much!

How to learn pseudo tokens in soft prompts?

It may be a silly question but haunts in my mind. As mentioned in the paper, pesudo tokens in soft prompts are learnable. However, I found the training process of PAIE with soft prompt is pretty similar to PAIE with manual prompts. They share the same model architecture which means, when backwarding, the loss object are from the same model. So how to learn pseudo tokens? In the paper, you mentioned that you follow two previous method, but how to implement them in PAIE code?

Question about sentence segmentation

Hello, I don't understand why W should be divided by 2 in line 208 of the code below. I found that this will cause the position of event_trigger to become a negative value, so I think W should not be divided by 2 in line 208. I hope to get your answer. Thanks!

if sent_length > W+1:
if event_trigger['end'] <= W//2: # trigger word is located at the front of the sents
cut_text = full_text[:(W+1)]
else: # trigger word is located at the latter of the sents
offset = sent_length - (W+1)
min_s += offset
max_e += offset
event_trigger['start'] -= offset
event_trigger['end'] -= offset
event_trigger['offset'] = offset
cut_text = full_text[-(W+1):]

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.