All Projects → malllabiisc → Reside

malllabiisc / Reside

Licence: apache-2.0
EMNLP 2018: RESIDE: Improving Distantly-Supervised Neural Relation Extraction using Side Information

Projects that are alternatives of or similar to Reside

Oie Resources
A curated list of Open Information Extraction (OIE) resources: papers, code, data, etc.
Stars: ✭ 283 (+27.48%)
Mutual labels:  natural-language-processing, relation-extraction
Usc Ds Relationextraction
Distantly Supervised Relation Extraction
Stars: ✭ 378 (+70.27%)
Mutual labels:  natural-language-processing, relation-extraction
Languagecrunch
LanguageCrunch NLP server docker image
Stars: ✭ 281 (+26.58%)
Mutual labels:  natural-language-processing, relation-extraction
Tacred Relation
PyTorch implementation of the position-aware attention model for relation extraction
Stars: ✭ 271 (+22.07%)
Mutual labels:  natural-language-processing, relation-extraction
Rex
REx: Relation Extraction. Modernized re-write of the code in the master's thesis: "Relation Extraction using Distant Supervision, SVMs, and Probabalistic First-Order Logic"
Stars: ✭ 21 (-90.54%)
Mutual labels:  natural-language-processing, relation-extraction
Fewrel
A Large-Scale Few-Shot Relation Extraction Dataset
Stars: ✭ 526 (+136.94%)
Mutual labels:  natural-language-processing, relation-extraction
Gcn Over Pruned Trees
Graph Convolution over Pruned Dependency Trees Improves Relation Extraction (authors' PyTorch implementation)
Stars: ✭ 312 (+40.54%)
Mutual labels:  natural-language-processing, relation-extraction
Deeplearning nlp
基于深度学习的自然语言处理库
Stars: ✭ 154 (-30.63%)
Mutual labels:  natural-language-processing, relation-extraction
Knowledge Graphs
A collection of research on knowledge graphs
Stars: ✭ 845 (+280.63%)
Mutual labels:  natural-language-processing, relation-extraction
Awesome Relation Extraction
📖 A curated list of awesome resources dedicated to Relation Extraction, one of the most important tasks in Natural Language Processing (NLP).
Stars: ✭ 656 (+195.5%)
Mutual labels:  natural-language-processing, relation-extraction
Exemplar
An open relation extraction system
Stars: ✭ 46 (-79.28%)
Mutual labels:  natural-language-processing, relation-extraction
Pytorch graph Rel
A PyTorch implementation of GraphRel
Stars: ✭ 204 (-8.11%)
Mutual labels:  natural-language-processing, relation-extraction
Conllu
A CoNLL-U parser that takes a CoNLL-U formatted string and turns it into a nested python dictionary.
Stars: ✭ 207 (-6.76%)
Mutual labels:  natural-language-processing
Lit
The Language Interpretability Tool: Interactively analyze NLP models for model understanding in an extensible and framework agnostic interface.
Stars: ✭ 2,721 (+1125.68%)
Mutual labels:  natural-language-processing
Hardware Aware Transformers
[ACL 2020] HAT: Hardware-Aware Transformers for Efficient Natural Language Processing
Stars: ✭ 206 (-7.21%)
Mutual labels:  natural-language-processing
Minerva
Meandering In Networks of Entities to Reach Verisimilar Answers
Stars: ✭ 205 (-7.66%)
Mutual labels:  natural-language-processing
Practical 1
Oxford Deep NLP 2017 course - Practical 1: word2vec
Stars: ✭ 220 (-0.9%)
Mutual labels:  natural-language-processing
Visdial
[CVPR 2017] Torch code for Visual Dialog
Stars: ✭ 215 (-3.15%)
Mutual labels:  natural-language-processing
Pytorch Beam Search Decoding
PyTorch implementation of beam search decoding for seq2seq models
Stars: ✭ 204 (-8.11%)
Mutual labels:  natural-language-processing
Character Based Cnn
Implementation of character based convolutional neural network
Stars: ✭ 205 (-7.66%)
Mutual labels:  natural-language-processing

RESIDE

Improving Distantly-Supervised Neural Relation Extraction using Side Information

Overview of RESIDE ...

RESIDE first encodes each sentence in the bag by concatenating embeddings (denoted by ⊕) from Bi-GRU and Syntactic GCN for each token, followed by word attention. Then, sentence embedding is concatenated with relation alias information, which comes from the Side Information Acquisition Section, before computing attention over sentences. Finally, bag representation with entity type information is fed to a softmax classifier. Please refer to paper for more details.

Also includes implementation of PCNN, PCNN+ATT, CNN, CNN+ATT, and BGWA models.

Dependencies

  • Compatible with TensorFlow 1.x and Python 3.x.
  • Dependencies can be installed using requirements.txt.

Dataset:

  • We use Riedel NYT and Google IISc Distant Supervision (GIDS) dataset​ for evaluation.

  • Datasets in json list format with side information can be downloaded from here: RiedelNYT and GIDS.

  • The processed version of the datasets can be downloaded from RiedelNYT and GIDS. The structure of the processed input data is as follows.

    {
        "voc2id":   {"w1": 0, "w2": 1, ...},
        "type2id":  {"type1": 0, "type2": 1 ...},
        "rel2id":   {"NA": 0, "/location/neighborhood/neighborhood_of": 1, ...}
        "max_pos": 123,
        "train": [
            {
                "X":        [[s1_w1, s1_w2, ...], [s2_w1, s2_w2, ...], ...],
                "Y":        [bag_label],
                "Pos1":     [[s1_p1_1, sent1_p1_2, ...], [s2_p1_1, s2_p1_2, ...], ...],
                "Pos2":     [[s1_p2_1, sent1_p2_2, ...], [s2_p2_1, s2_p2_2, ...], ...],
                "SubPos":   [s1_sub, s2_sub, ...],
                "ObjPos":   [s1_obj, s2_obj, ...],
                "SubType":  [s1_subType, s2_subType, ...],
                "ObjType":  [s1_objType, s2_objType, ...],
                "ProbY":    [[s1_rel_alias1, s1_rel_alias2, ...], [s2_rel_alias1, ... ], ...]
                "DepEdges": [[s1_dep_edges], [s2_dep_edges] ...]
            },
            {}, ...
        ],
        "test":  { same as "train"},
        "valid": { same as "train"},
    }
    
    • voc2id is the mapping of word to its id
    • type2id is the maping of entity type to its id.
    • rel2id is the mapping of relation to its id.
    • max_pos is the maximum position to consider for positional embeddings.
    • Each entry of train, test and valid is a bag of sentences, where
      • X denotes the sentences in bag as the list of list of word indices.
      • Y is the relation expressed by the sentences in the bag.
      • Pos1 and Pos2 are position of each word in sentences wrt to target entity 1 and entity 2.
      • SubPos and ObjPos contains the position of the target entity 1 and entity 2 in each sentence.
      • SubType and ObjType contains the target entity 1 and entity 2 type information obtained from KG.
      • ProbY is the relation alias side information (refer paper) for the bag.
      • DepEdges is the edgelist of dependency parse for each sentence (required for GCN).

Evaluate pretrained model:

  • reside.py contains TensorFlow (1.x) based implementation of RESIDE (proposed method).
  • Download the pretrained model's parameters from RiedelNYT and GIDS (put downloaded folders in checkpoint directory).
  • Execute evaluate.sh for comparing pretrained RESIDE model against baselines (plots Precision-Recall curve).

Side Information:

  • Entity Type information for both the datasets is provided in side_info/type_info.zip.
    • Entity type information can be used directly in the model.
  • Relation Alias Information for both the datasets is provided in side_info/relation_alias.zip.
    • The preprocessing code for using relation alias information: rel_alias_side_info.py.
    • Following figure summarizes the method:

Training from scratch:

  • Execute setup.sh for downloading GloVe embeddings.
  • For training RESIDE run:
    python reside.py -data data/riedel_processed.pkl -name new_run
    
  • The above model needs to be further trained with SGD optimizer for few epochs to match the performance reported in the paper. For that execute

    python reside.py -name new_run -restore -opt sgd -lr 0.001 -l2 0.0 -epoch 4
    
  • Finally, run python plot_pr.py -name new_run to get the plot.

Baselines:

  • The repository also includes code for PCNN, PCNN+ATT, CNN, CNN+ATT, BGWA models.

  • For training PCNN+ATT:

    python pcnnatt.py -data data/riedel_processed.pkl -name new_run -attn # remove -attn for PCNN
    
  • Similarly for training CNN+ATT:

    python cnnatt.py -data data/riedel_processed.pkl -name new_run # remove -attn for CNN
    
  • For training BGWA:

    python bgwa.py -data data/riedel_processed.pkl -name new_run
    

Preprocessing a new dataset:

  • preproc directory contains code for getting a new dataset in the required format (riedel_processed.pkl) for reside.py.
  • Get the data in the same format as followed in riedel_raw or gids_raw for Riedel NYT dataset.
  • Finally, run the script preprocess.sh. make_bags.py is used for generating bags from sentence. generate_pickle.py is for converting the data in the required pickle format.

Running pretrained model on new samples:

  • The code for running pretrained model on a sample is included in online directory.

  • A flask based server is also provided. Use python online/server.py to start the server.

Citation:

Please cite the following paper if you use this code in your work.

@inproceedings{reside2018,
  author = 	"Vashishth, Shikhar and 
  		Joshi, Rishabh and
		Prayaga, Sai Suman and
		Bhattacharyya, Chiranjib and
		Talukdar, Partha",
  title = 	"{RESIDE}: Improving Distantly-Supervised Neural Relation Extraction using Side Information",
  booktitle = 	"Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing",
  month = 	oct # "-" # nov,
  address = 	"Brussels, Belgium",
  year = 	"2018",
  publisher = 	"Association for Computational Linguistics",
  pages = 	"1257--1266",
  url = 	"http://aclweb.org/anthology/D18-1157"
}

For any clarification, comments, or suggestions please create an issue or contact Shikhar.

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].