allenai / allennlp

An open-source NLP research library, built on PyTorch.
http://www.allennlp.org
Apache License 2.0
11.75k stars 2.24k forks source link

Graph convolutional network module for text #2739

Closed dchang56 closed 4 years ago

dchang56 commented 5 years ago

Is your feature request related to a problem? Please describe. In the past couple of years there's been an increase in application of graph convolutional networks in NLP, and it seems promising and interesting enough that it could be good to have a module for it to give researchers the option of incorporating it into their models.

Describe the solution you'd like A module that takes in a graph data structure (adjacency matrix, node/edge features, etc) and outputs updated graph data structure, and preferably be compatible with graph network implementations from Pytorch Geometric

DeNeutoy commented 5 years ago

This is not an area we've been working on, but it should be straightforward to implement a SparseFormatField in one of the more common sparse matrix formats. This could then be compatible with some GCN type encoders, such as those in Pytorch Geometric. It's somewhat unlikely the allennlp team will be working on this in the near future, but contributions or notifications of separate implementations where people can go to find GCN type support would be welcome!

dchang56 commented 5 years ago

Thank you, I'll keep an eye out and try to implement it in the near future. Any and all suggestions/ideas for implementing graph convolution within the AllenNLP framework would be greatly appreciated :)

matt-gardner commented 5 years ago

I know of some folks at Tel Aviv using GCNs inside of AllenNLP for some applications, though the paper using it is under review, so they haven't submitted code upstream. I'm not sure whether to recommend waiting for them or not. Just FYI.

dchang56 commented 5 years ago

@matt-gardner That's great to hear! Do you think it would be possible to put me in contact with them if it's not too much trouble?

matt-gardner commented 5 years ago

@dchang56, I sent an email to the folks who were working on this, and they may or may not comment here; we'll see.

benbogin commented 5 years ago

@dchang56 @matt-gardner Hey! Not sure if this is helpful, but actually in our implementation we simply use the following gist: https://github.com/pcyin/pytorch-gated-graph-neural-network/blob/master/gnn.py which implements Gated Graph Sequence Neural Networks. We pass it initial embeddings for each node, a list of adjacency pairs and the number of timesteps, and it outputs the updated encoding for each node, which was sufficient for our needs.

matt-gardner commented 5 years ago

Thanks @benbogin!

DeNeutoy commented 4 years ago

Closing, we probably shouldn't support this directly.

EazyReal commented 4 years ago

I know of some folks at Tel Aviv using GCNs inside of AllenNLP for some applications, though the paper using it is under review, so they haven't submitted code upstream. I'm not sure whether to recommend waiting for them or not. Just FYI.

@matt-gardner I am working on using GNN with allennlp too, is there a way I can contact them? Thanks a lot!

matt-gardner commented 4 years ago

@EazyReal, you can see the links above, and also check out this repo.

EazyReal commented 4 years ago

@matt-gardner , Thanks for your reply! I think I did not express my problem well enough, the point is that I want to use mini-batch on graphs (like in Pytorch Geometric, allennlp provides only (Dense)AdjacencyField). It seems that the implementation of the link (https://github.com/pcyin/pytorch-gated-graph-neural-network/blob/master/gnn.py) does not support batch training. And the repo you mentioned uses KnowledgeGraphField, which is not supported in allennlp 1.0. So I actually coded a SparseadjacencyField yesterday and it seems working well now. image image