/PCNN-ATT-pytorch

Pytorch reimplementation of PCNN-ATT model from Lin et. al. (2016)

Primary LanguagePython

PCNN-ATT Model for Relation Extraction

This repo contains the pytorch code for paper Neural Relation Extraction with Selective Attention over Instances..

Requirements

  • Python 2 (tested on 2.7)
  • PyTorch (tested on 0.4.1)

Dataset

Use data from Lin et. al. (2016), and put all training, test, vocab and relation files under the same directory.

Training

Train a PCNN-ATT model with:

CUDA_VISIBLE_DEVICES=0 python train.py --data_dir data/ --lr 0.001 --num_epoch 15 --save_dir saved_models/

Model checkpoints and logs will be saved to ./saved_models/.

Evaluation

Run held-out evaluation on the test set with:

CUDA_VISIBLE_DEVICES=0 python eval.py --model_dir saved_models/ --model best_model.tar --data_dir data/

Use --model checkpoint_epoch_10.tar to specify a model checkpoint file of 10th training epoch. Add --out saved_models/pr.dump to write model precision/recall output to a file.

Reference

[Lin et al., 2016] Yankai Lin, Shiqi Shen, Zhiyuan Liu, Huanbo Luan, and Maosong Sun. Neural Relation Extraction with Selective Attention over Instances. In Proceedings of ACL. Original C++ code for PCNN-ATT