Git Product home page Git Product logo

joint_entity_and_relation_extraction's Introduction

Multi-head Attention with Hint Mechanisms for Joint Extraction of Entity and Relation

Multi-head Attention with Hint Mechanisms for Joint Extraction of Entity and Relation

The paper accept by MobiSocial2021


Requirements

  • Python 3.7.3
  • pytorch 1.2.0
  • transformers 2.3.0
  • numpy 1.16.2
  • scikit-learn 0.20.3
  • tqdm 4.31.1

Task

Given a raw text, (i) give the entity tag of each word (e.g., NER) and (ii) the relations between the entities in the sentence.


Data

Download data and put them in their respective folders in the path /data/ .


Preprocessing

Preprocess the data to the form the model can train.

python3 process_conll04.py
python3 process_ADE.py
python3 process_ACE04.py
python3 process_ACE05.py

Train

For each dataset

python3 main.py --CUDA_device 0 --dataset conll04 --word_dropout 0.25 
python3 main.py --CUDA_device 0 --dataset ADE --n_r_head 16 --n_iter 100 --scheduler_step 15
python3 main.py --CUDA_device 0 --dataset ACE04 --n_iter 125 --scheduler_step 20
python3 main.py --CUDA_device 0 --dataset ACE05 --batch_size 30 --word_dropout 0.25 --rel_dropout 0.15 --pair_dropout 0.15 --pair_out 400 --n_iter 150 --scheduler_step 20

Eval

For each dataset, change parameters --dataset and --model_dict.

python3 main.py --CUDA_device 0 --train_eval_predict eval --dataset conll04 --silent False --model_dict NER_RE_best.conll04.XLNet_base.32.nobi.backward.Pw_hint.pkl

Predict

After training, give any sentence and predict the NER and RE.

For each dataset, change parameters --dataset and --model_dict.

python3 main.py --CUDA_device 0 --train_eval_predict predict --dataset conll04 --silent False --model_dict NER_RE_best.conll04.XLNet_base.32.nobi.backward.Pw_hint.pkl

Notes

Please cite our work when using this software.

joint_entity_and_relation_extraction's People

Contributors

jojowither avatar

Stargazers

 avatar

Watchers

 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.