Giter VIP home page Giter VIP logo

chap_amr_parser's Introduction

CHAP AMR Parser

This is the official implementation of AMR Parsing with Causal Hierarchical Attention and Pointers, presented at EMNLP 2023.

Installation

chmod +x install.sh
. ./install.sh

The installation script will create a new conda environment, named as chap_amr, and compile some c++ extension, developed based on Transformer Grammars.

Prepare data

First, prepare AMR graph banks using the script in amrlib: https://github.com/bjascob/amrlib/blob/master/scripts/33_Model_Parse_XFM/10_Collect_AMR_Data.py. You will obtain a directory tdata_xfm in amrlib's working directory. Move it to <project root>/data/AMR3.0/tdata_xfm (change to AMR2.0 if processing the AMR 2.0 graph bank; and you don't need this step when processing OOD data).

Then, run scripts/10_prepare_data.sh at the project root. It contains commands of processing all datasets. So you may just need some of them according to your usage.

Train

python src/train.py experiment=<model config>

# our best model
python src/train.py experiment=t2g_point2tgt_paware_strict_adapter

We use hydra to configure training and models. This project is based on the lightning-hydra-template. experiment will use the config files in configs/experiment, in which import the corresponding config files in configs/model. The config file name is organized as follows:

Model Config (configs/model/) Coref Layer Encode Pointer Tree Modeling
t2g_baseline - - -
t2g_inline_adapter - - CHA (adapter)
t2g_inline_inplace - - CHA (inplace)
t2g_point2tgt Yes - -
t2g_point2tgt_paware Yes Yes -
t2g_point2tgt_paware_strict* Yes Yes -
t2g_point2tgt_paware_strict_adapter* Yes Yes CHA (adapter)
  • strict means that the pointers of coref layer are constrained to valid values.

Evaluate

In the training script, a prediction on the test set will be stored under the working directory. To evaluate a trained model on other datasets, use the following command:

python src/eval.py experiment=<model config> data=<data config> ckpt_path=<ckpt path>

Then, you can use the scripts in amrlib to call BLINK to generate AMR graphs with wiki tags and compute the fine-grained metrics. The scripts could be found at https://github.com/bjascob/amrlib/blob/master/scripts/33_Model_Parse_XFM/.

License and Citing

This code is released under the MIT license.

If you use this work for research, please cite our paper:

@inproceedings{
lou2023amr,
title={{AMR} Parsing with Causal Hierarchical Attention and Pointers},
author={Chao Lou and Kewei Tu},
booktitle={The 2023 Conference on Empirical Methods in Natural Language Processing},
year={2023},
url={https://openreview.net/forum?id=SI2CXa5eok}
}

chap_amr_parser's People

Contributors

louchao98 avatar

Stargazers

 avatar  avatar

Watchers

 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.