Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

A TensorFlow implementation of Graph-based Biaffine Parser

Table of Contents


TensorFlow needs to be installed before running the training script. TensorFlow 1.0.0 or higher is supported. (TensorFlow 1.3.0 and 1.7.0 are tested)


Our architecture utilizes pre-trained word embedding vectors, GloveVectors. Run the following:


and save it to a sub-directory glovevector/.

Data Format

The biaffine parser takes as input a file in the Conllu+Supertag (conllustag) format, in which one column for supertags is added to the original conllu format at the end. See a sample.

Train a Parser

All you need to do is to create a new directory for your data in the conllustag format and a json file for the model configuration and data information. We provide a sample json file for the sample data directory. You can train a parser on the sample data by the following command:

python sample_data/config_demo.json

After running this command, you should be getting the following files and directories in sample_data/:

Directory/File Description
checkpoint.txt Contains information about the best model.
sents/ Contains the words in the one-sentence-per-line format
gold_pos/ Contains the gold POS tags in the one-sentence-per-line format
gold_stag/ Contains the gold supertags in the one-sentence-per-line format
arcs/ Contains the gold arcs in the one-sentence-per-line format
rels/ Contains the gold rels in the one-sentence-per-line format
predicted_arcs/ Contains the predicted arcs in the one-sentence-per-line format
predicted_rels/ Contains the gold rels in the one-sentence-per-line format
Parsing_Models/ Stores the best model.
conllu/sample.conllustag_stag Contains the predicted supertags in the conllustag format

Structure of the Code

File Description
utils/ Contains tools for preprocessing. Mainly for tokenizing and indexing words/tags. Gets imported to utils/
utils/ Reads training and test data and tokenize/index words, POS tags, stags, and characters.
utils/ Contains the Parsing_Model class that constructs our LSTM computation graph. The class has the necessary methods for training and testing. Gets imported to For more details, read README for utils.
utils/ Contains tensorflow LSTM equations. Gets imported to utils/ Contains functions that instantiate the Parsing_Model class and train/test a model. Gets imported to Main file to run experiments. Reads model and data options.
scripts/ Runs in bash according to the json file that gets passed.

Run a pre-trained TAG Parser

We provide a pre-trained TAG parser. To run the pretrained parser on your data, first download the model and place the Pretrained_Parser directory in the demo directory. Then, run

  • With tokenization
python demo/scripts/ --infile demo/sents/test.txt --tokenize
  • Without tokenization
python demo/scripts/ --infile demo/sents/test.tokenized.txt

You can replace these files by your own data. It prints out predicted elementary trees, parses, and PTB-style fine-grained POS tags in the conllu format. Note that we put elementary trees in the UPOS column.

Run a demo TAG Parser

Enjoy playing around with our TAG demo parser online!


If you use this tool for your research, please consider citing:

  author =  {Jungo Kasai and Robert Frank and Pauli Xu and William Merrill and Owen Rambow},
  title =   {End-to-end Graph-based TAG Parsing with Neural Networks},
  year =    {2018},  
  booktitle =   {Proceedings of NAACL},  
  publisher =   {Association for Computational Linguistics},