Piecewise Convolution Neural Network is one kind of architecture for Relation Extraction task in NLP.
Applying one traditional single layer Convolution on sentence embeddings can capture n-gram features. After max pooling, only the strongest feature return, which is insufficient for Relation Extraction tasks.
The PCNN architecture divide one sentence into three parts according to entities positions. This modification improve the capability of Relation Extraction.
The original architecture of PCNN is designed as follows.
This project re-implement the paper, Distant Supervision for Relation Extraction via Piecewise Convolutional Neural Networks, in Tensorflow.
Since it is still unsupported to split tensors into variable lengths in Tensorflow. The architecture is modified slightly as follows.
- Python3(build with 3.6)
Install python package in virtual environment
pip install -r requirements
To shuffle dataset, shuf is needed. And it is already installed on Linux.
Usage
shuf -o ./path/to/shuf_data ./path/to/origin_data
On OS X, gshuf is alternative.
brew install coreutils
gshuf -o ./path/to/shuf_data ./path/to/origin_data
You can configure ./model/config.py
to set parameters.
make download
Run this project.
make run
Using tensorboard
tensorboard --logdir="./graph" --port 6006
Open browser in http://localhost:6006/
This project is licensed under the Apache License - see the LICENSE.txt file for details
@inproceedings{Zeng2015DistantSF,
title={Distant Supervision for Relation Extraction via Piecewise Convolutional Neural Networks},
author={Daojian Zeng and Kang Liu and Yubo Chen and Jun Zhao},
booktitle={EMNLP},
year={2015}
}