All Projects → thunlp → Jointnre

thunlp / Jointnre

Licence: mit
Joint Neural Relation Extraction with Text and KGs

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Jointnre

Tre
[AKBC 19] Improving Relation Extraction by Pre-trained Language Representations
Stars: ✭ 95 (-43.45%)
Mutual labels:  relation-extraction
Bertem
论文实现(ACL2019):《Matching the Blanks: Distributional Similarity for Relation Learning》
Stars: ✭ 146 (-13.1%)
Mutual labels:  relation-extraction
Tensorflow rlre
Reinforcement Learning for Relation Classification from Noisy Data(TensorFlow)
Stars: ✭ 150 (-10.71%)
Mutual labels:  relation-extraction
Copymtl
AAAI20 "CopyMTL: Copy Mechanism for Joint Extraction of Entities and Relations with Multi-Task Learning"
Stars: ✭ 97 (-42.26%)
Mutual labels:  relation-extraction
Atnre
Adversarial Training for Neural Relation Extraction
Stars: ✭ 108 (-35.71%)
Mutual labels:  relation-extraction
Hatt Proto
Code and dataset of AAAI2019 paper Hybrid Attention-Based Prototypical Networks for Noisy Few-Shot Relation Classification
Stars: ✭ 149 (-11.31%)
Mutual labels:  relation-extraction
Rcnn Relation Extraction
Tensorflow Implementation of Recurrent Convolutional Neural Network for Relation Extraction
Stars: ✭ 64 (-61.9%)
Mutual labels:  relation-extraction
Fox
Federated Knowledge Extraction Framework
Stars: ✭ 155 (-7.74%)
Mutual labels:  relation-extraction
Bran
Full abstract relation extraction from biological texts with bi-affine relation attention networks
Stars: ✭ 111 (-33.93%)
Mutual labels:  relation-extraction
Open Ie Papers
Open Information Extraction (OpenIE) and Open Relation Extraction (ORE) papers and data.
Stars: ✭ 150 (-10.71%)
Mutual labels:  relation-extraction
Intra Bag And Inter Bag Attentions
Code for NAACL 2019 paper: Distant Supervision Relation Extraction with Intra-Bag and Inter-Bag Attentions
Stars: ✭ 98 (-41.67%)
Mutual labels:  relation-extraction
Pytorch multi head selection re
BERT + reproduce "Joint entity recognition and relation extraction as a multi-head selection problem" for Chinese and English IE
Stars: ✭ 105 (-37.5%)
Mutual labels:  relation-extraction
Macadam
Macadam是一个以Tensorflow(Keras)和bert4keras为基础,专注于文本分类、序列标注和关系抽取的自然语言处理工具包。支持RANDOM、WORD2VEC、FASTTEXT、BERT、ALBERT、ROBERTA、NEZHA、XLNET、ELECTRA、GPT-2等EMBEDDING嵌入; 支持FineTune、FastText、TextCNN、CharCNN、BiRNN、RCNN、DCNN、CRNN、DeepMoji、SelfAttention、HAN、Capsule等文本分类算法; 支持CRF、Bi-LSTM-CRF、CNN-LSTM、DGCNN、Bi-LSTM-LAN、Lattice-LSTM-Batch、MRC等序列标注算法。
Stars: ✭ 149 (-11.31%)
Mutual labels:  relation-extraction
Relation extraction
Relation Extraction using Deep learning(CNN)
Stars: ✭ 96 (-42.86%)
Mutual labels:  relation-extraction
R Bert
Pytorch implementation of R-BERT: "Enriching Pre-trained Language Model with Entity Information for Relation Classification"
Stars: ✭ 150 (-10.71%)
Mutual labels:  relation-extraction
Distre
[ACL 19] Fine-tuning Pre-Trained Transformer Language Models to Distantly Supervised Relation Extraction
Stars: ✭ 75 (-55.36%)
Mutual labels:  relation-extraction
Information Extraction Chinese
Chinese Named Entity Recognition with IDCNN/biLSTM+CRF, and Relation Extraction with biGRU+2ATT 中文实体识别与关系提取
Stars: ✭ 1,888 (+1023.81%)
Mutual labels:  relation-extraction
Ruijin round2
瑞金医院MMC人工智能辅助构建知识图谱大赛复赛
Stars: ✭ 159 (-5.36%)
Mutual labels:  relation-extraction
Deeplearning nlp
基于深度学习的自然语言处理库
Stars: ✭ 154 (-8.33%)
Mutual labels:  relation-extraction
Kg Baseline Pytorch
2019百度的关系抽取比赛,使用Pytorch实现苏神的模型,F1在dev集可达到0.75,联合关系抽取,Joint Relation Extraction.
Stars: ✭ 149 (-11.31%)
Mutual labels:  relation-extraction

JointNRE

Codes and datasets for our paper "Neural Knowledge Acquisition via Mutual Attention between Knowledge Graph and Text"

Some Introduction

This implementation is a fast and stable version.

We have made some simplifications for the original model so that to train a joint model just needs around 15min.

We also encapsulate more neural architectures into our framework to encode sentences.

The code and datasets mainly for the task relation extraction.

Data

We provide the datasets used for the task relation extraction.

New York Times Corpus: The data used in relation extraction from text is published by "Modeling relations and their mentions without labeled text". The data should be obtained from [LDC] first.

Datasets are required in the folder data/ in the following format, containing at least 4 files:

  • kg/train.txt: the knowledge graph for training, format (e1, e2, rel).

  • text/relation2id.txt: the relation needed to be predicted for RE, format (rel, id).

  • text/train.txt: the text for training, format (e1, e2, name1, name2, rel, sentence).

  • text/vec.txt: the initial word embeddings.

  • [Download (Baidu Cloud)]

  • [Download (Tsinghua Cloud)]

For FB15K-NYT, we directly give the data for our code [Download (Tsinghua Cloud)], as we cannot release the original data limited by the license of LDC.

Run the experiments

To run the experiments, unpack the datasets first:

unzip origin_data.zip -d origin_data/
mkdir data/
python initial.py

Run the corresponding python scripts to train models:

cd jointE
bash make.sh
python train.py

Change the corresponding python code to set hyperparameters:

tf.app.flags.DEFINE_float('nbatch_kg',100,'entity numbers used each training time')
tf.app.flags.DEFINE_float('margin',1.0,'entity numbers used each training time')
tf.app.flags.DEFINE_float('learning_rate_kg',0.001,'learning rate for kg')
tf.app.flags.DEFINE_float('ent_total',lib.getEntityTotal(),'total of entities')
tf.app.flags.DEFINE_float('rel_total',lib.getRelationTotal(),'total of relations')
tf.app.flags.DEFINE_float('tri_total',lib.getTripleTotal(),'total of triples')
tf.app.flags.DEFINE_float('katt_flag', 1, '1 for katt, 0 for att')

tf.app.flags.DEFINE_string('model', 'cnn', 'neural models to encode sentences')
tf.app.flags.DEFINE_float('max_length',config['fixlen'],'maximum of number of words in one sentence')
tf.app.flags.DEFINE_float('pos_num', config['maxlen'] * 2 + 1,'number of position embedding vectors')
tf.app.flags.DEFINE_float('num_classes', config['textual_rel_total'],'maximum of relations')

tf.app.flags.DEFINE_float('hidden_size',230,'hidden feature size')
tf.app.flags.DEFINE_float('pos_size',5,'position embedding size')

tf.app.flags.DEFINE_float('max_epoch',20,'maximum of training epochs')
tf.app.flags.DEFINE_float('batch_size',160,'entity numbers used each training time')
tf.app.flags.DEFINE_float('learning_rate',0.5,'learning rate for nn')
tf.app.flags.DEFINE_float('weight_decay',0.00001,'weight_decay')
tf.app.flags.DEFINE_float('keep_prob',0.5,'dropout rate')

tf.app.flags.DEFINE_string('model_dir','./model/','path to store model')
tf.app.flags.DEFINE_string('summary_dir','./summary','path to store summary_dir')

Run the corresponding python scripts to test models:

cd jointE
bash make.sh
python test.py

Note that the hyperparameters in the train.py and the test.py must be the same.

Run the corresponding python script to get PR-curve results:

cd jointE
python pr_plot.py

Citation

 @inproceedings{han2018neural,
   title={Neural Knowledge Acquisition via Mutual Attention between Knowledge Graph and Text},
   author={Han, Xu and Liu, Zhiyuan and Sun, Maosong},
   booktitle={Proceedings of AAAI},
   year={2018}
 }
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].