Coder Social home page Coder Social logo

youarerare / second_order_sdp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wangxinyu0922/second_order_sdp

0.0 1.0 0.0 580 KB

Second-Order Semantic Dependency Parsing with End-to-End Neural Networks

License: Apache License 2.0

Python 100.00%

second_order_sdp's Introduction

Second Order SDP

Second Order Parser for Semantic Dependency Parsing

This repo contains the code forked from Parser-v3 and used for the semantic dependency parser in Wang et al. (2019), Second-Order Semantic Dependency Parsing with End-to-End Neural Networks and CoNLL 2019 shared task (SDP part only).

Requirements

python3
tensorflow-gpu>=1.12.0

How to use

Training

Our second order parser can be trained by simply running

python3 -u main.py train GraphParserNetwork --config_file config/sec_order.cfg --noscreen

This config file will run Mean Field Variational Inference for second order parts, and if you want to run with Loopy Belief Propagation, run

python3 -u main.py train GraphParserNetwork --config_file config/sec_order_LBP.cfg --noscreen

Training with Bert Embedding

Our second order parser can be trained with bert. First clone the bert repository:

git clone https://github.com/google-research/bert

Download bert model: BERT-Large, Uncased (Whole Word Masking)

To train with bert, simply run

python3 -u main.py train GraphParserNetwork --config_file config_gen/bert_large_glove_previous_layer_100linear_01lr_5decay_dm_switch_new1.cfg --noscreen

If you want to fine tune bert model, set is_training=True in BertVocab

Parsing

A trained model can be run by calling

python3 main.py --save_dir $SAVEDIR run $DATADIR --output_dir results 

The parsed result will be saved results/ directory. The $SAVEDIR is the directory of the model, for example, if you trained with config/sec_order.cfg, the model will be saved in saves/SemEval15/DM/MF_dm_3iter. The $DATADIR is the directory of the data in CONLLU format.

OOM issue

To avoid out of memory in training phase, our parser should be trained with 12GB gpu memory, and no longer than 60 words for each sentence. The number of iterations for mean field variational inference is at most 3 and at most 2 for loopy belief propagation in a 12GB Titan X gpu. If you have a larger gpu, such as Tesla P40 24GB, loopy belief propation can be also trained with 3 iterations. To set the number of iterations, set num_iteration in SecondOrderGraphIndexVocab or SecondOrderGraphLBPVocab of the config file. Another way is reduce the training batch_size in CoNLLUTrainset of the config file.

Details

If you want to see some details of our parser, the source code for our parser is in parser/structs/vocabs/second_order_vocab.py for Mean Field Variational Inference and second_order_LBP_vocab.py for Loopy Belief Propagation in the same directory.

Cite

If you find our code is useful, please cite:

@inproceedings{wang-etal-2019-second,
    title = "Second-Order Semantic Dependency Parsing with End-to-End Neural Networks",
    author = "Wang, Xinyu  and
      Huang, Jingxian  and
      Tu, Kewei",
    booktitle = "Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics",
    month = jul,
    year = "2019",
    address = "Florence, Italy",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/P19-1454",
    pages = "4609--4618",}
@inproceedings{Wan:Liu:Jia:19,
  author = {Wang, Xinyu and Liu, Yixian and Jia, Zixia
            and Jiang, Chengyue and Tu, Kewei},
  title = {{ShanghaiTech} at {MRP}~2019:
           {S}equence-to-Graph Transduction with Second-Order Edge Inference
           for Cross-Framework Meaning Representation Parsing},
  booktitle = CONLL:19:U,
  address = L:CONLL:19,
  pages = {\pages{--}{55}{65}},
  year = 2019
}

Contact

If you have any questions, feel free to contact with me through email.

second_order_sdp's People

Contributors

wangxinyu0922 avatar

Watchers

James Cloos avatar

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.