GithubHelp home page GithubHelp logo

andreabac3 / nlp-semantic-role-labeling Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 1.0 4.51 MB

NLP - Semantic Role Labeling using GCN, Bert and Biaffine Attention Layer. Developed in Pytorch

Home Page: https://github.com/SapienzaNLP/nlp2020-hw2

License: GNU General Public License v3.0

Dockerfile 0.38% Python 98.23% Shell 1.38%
gcn gcn-architecture graph-deep-learning nlp natural-language-processing semantic-role-labeling srl bert graph-convolutional-network biaffine-attention-layer

nlp-semantic-role-labeling's Introduction

Semantic Role labeling - Syntax-aware, BERT, Biaffine Attention Layer

This repository reports the research carried out in the field of Semantic Role Labeling during the Natural Language Processing course for the academic year 2019/2020 of Professor Roberto Navigli.

You can consult the report here and the slides used for the presentation here.

The code was developed with Pytorch.

My work got the highest macro f1 score of the whole class.

This model makes use of syntactic features via Graph Convolutional Network, Contextualized word embeddings (bert) and the Biaffine Attention Layer.

In this image you can see the final model: final model pic

GCN

To exploit the syntactic features I used the GCN layer from the work of Kipf & Welling as done by Marcheggiani et al.

I started from the information of the syntactic features contained in the dependency heads from which I built an indirect graph with self loops, in order to consider the node itself. I expressed this graph in matrix form, using an adjancency matrix. This adjacency matrix has been normalized to avoid the vanish & exploding gradient problem. Multiplying the adjacency matrix by its inverse degree matrix.

GCN Batch wise training

In order to support batches I used a block diagonal matrix, where all the adjacency matrix of a batch are present along the diagonal. As shown in the figure below. batch wise gcn

BERT

I used bert-base-cased to produce non-trainable contextualized word embeddings. As a pooling strategy I added the last 4 hidden layers. To manage the word pieces produced by a single word I took their average.

To avoid the excessive use of the ram I used the 16 bit representation of the tensors of the bert embeddings. The bert embeddings is placed in the CPU and only the portion of the batch is transferred to the GPU when used and then returned to the CPU.

To execute the project

You should download and extract the vocabs and pre-trained model from this link and place it into the model/ folder.

conda create -n nlp2020-hw2 python=3.7
conda activate nlp2020-hw2
pip3 install -r requirements.txt
conda activate nlp2020-hw2
bash test.sh data/baseline.json

Authors

nlp-semantic-role-labeling's People

Contributors

andreabac3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

topliftarm

nlp-semantic-role-labeling's Issues

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.