Git Product home page Git Product logo

gp-gnn's Introduction

Graph Neural Networks with Generated Parameters for Relation Extraction

Code and dataset of ACL2019 Paper Graph Neural Networks with Generated Parameters for Relation Extraction. paper

Citation

Please cite our paper if you find it helpful.

@inproceedings{zhu2019graph,
  title={Graph Neural Networks with Generated Parameters for Relation Extraction},
  author={Zhu, Hao and Lin, Yankai and Liu, Zhiyuan and Fu, Jie and Chua, Tat-Seng and Sun, Maosong},
  booktitle={Proceedings of ACL},
  year={2019}
}

This repository is mainly contributed by Hao Zhu, Chaojun Xiao. And this repository is developed based on ContextAware.

Dataset

Please download gpgnn_data.zip from Aliyun and unzip it as the data folder:

unzip gpgnn_data.zip

Requirements and Installation

This repository has been tested with Python 3.6,torch==1.4.0,sacred==0.8.1

pip3 install -r requirements.txt

Get Started

Directory structure

models/: Baseline models (LSTM, CNN, PCNN, ContextAware) in baselines.py and GPGNN model in our_models.py.

parsing/: APIs to convert graphs into tensors which can be fed into our models.

semanticgraph/: APIs to construct relation graphs from sentences.

utils/: APIs to load word embeddings, evaluate, and operate the graphs.

result/: Storage area for models and output results on the test set.

model_param.json: Hyper parameters for the GPGNN model.

Running

train:

The parameters of the function main are set in function main_config. You can modify the parameters in main_config to train different models. And the hyper parameters for the models are stored in model_params.json.

python3 train.py

test:

Before testing, you should choose proper version of the model by modifing the load_model in main_config.

python3 test.py

evaluate:

cd result
python3 test_accuracy.py --input (result_file_path)

gp-gnn's People

Contributors

prokil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gp-gnn's Issues

P@K

Hello, excuse me P@K Can the index code be published? Or how to calculate this index

你好!有一行代码不知道对应论文中的哪个公式想要请教一下

在our_models.py的107行中,您定义# rnn_output shape: batch * MAX_EDGES_PER_GRAPH, max_sent_len, hidden
我设置的是batch_size = 10 所以size = (720, 36, 512)
108行代码
rnn_result = torch.cat([rnn_output[:, -1, :self.p['units1']], rnn_output[:, 0, self.p['units1']:]], dim=1).view(sentence_input.size()[0], MAX_EDGES_PER_GRAPH, -1)
我的理解是: 在108行中, 相当于截取lstm中第35个word的前0到255的embedding,和第0个word的第256到512的embedding。经过tocrh,cat变成维度(720,2,256)最后再view一下变成(10, 72,512 ),view相当于把同一个sentence中的第一个word和最后1个word的各自256维度拼接。这个第一个词后半embedding后最后一个词的前半embedding的拼接。作为graph edge的value
我的问题:如果我理解的没有错,请问这样做有什么依据吗?它对应了论文中哪一条公式?

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.