In this project, I have implemented the following research papers:
- the arc-standard algorithm
- feature extraction
- the neural network architecture including activation function
- loss function
This project is implemented in python 3.6 and tensorflow 2.0. Follow these steps to setup your environment:
- Download and install Conda
- Create a Conda environment with Python 3.6
conda create -n nlp-hw3 python=3.6
- Activate the Conda environment. You will need to activate the Conda environment in each terminal in which you want to use this code.
conda activate nlp-hw3
- Install the requirements:
pip install -r requirements.txt
- Download glove wordvectors:
./download_glove.sh
The training, development and test set for dependency parsing is in conll format. The train.conll
and dev.conll
are labeled whereas test.conll
is unlabeled.
For quick code development/debugging, there is a small fixture dataset. You can use this as training and development dataset while working on the code.
There are three scripts in the repository train.py
, predict.py
and evaluate.py
for training, predicting and evaluating a Dependency Parsing Model. You can supply -h
flag to each of these to figure out how to use these scripts.
Here we show how to use the commands with the defaults.
python train.py data/train.conll data/dev.conll
# stores the model by default at : serialization_dirs/default
python predict.py serialization_dirs/default \
data/dev.conll \
--predictions-file dev_predictions.conll
python evaluate.py serialization_dirs/default \
data/dev.conll \
dev_predictions.conll
-
lib.model:
Defines the main model class of the neural dependency parser. -
lib.data.py
: Code dealing with reading, writing connl dataset, generating batches, extracting features and loading pretrained embedding file. -
lib.dependency_tree.py
: The dependency tree class file. -
lib.parsing_system.py
: This file contains the class for a transition-based parsing framework for dependency parsing. -
lib.configuration.py
: The configuration class file. Configuration reflects a state of the parser. -
lib.util.py
: This file contain function to load pretrained Dependency Parser. -
constants.py
: Sets project-wide constants for the project.
I have tried different things for this task including changing the :
- activations (cubic vs tanh vs sigmoid)
- pretrained embeddings (GloVe embeddings vs using no embeddings)
- tunability of embeddings (trainable embeddings vs frozen embeddings)
The findings are included in report.pdf.
The file experiments.sh
enlists the commands you will need to train and save these models. In all you will need ~5 training runs, each taking about 30 minutes on cpu. See colab_notes.md
to run experiments on gpu.
As shown in the experiments.sh
, you can use --experiment-name
argument in the train.py
to store the models at different locations in serialization_dirs
. You can also use --cache-processed-data
and --use-cached-data
flags in train.py
to not generate the training features everytime. Please look at training script for details. Lastly, after training your dev results will be stored in serialization directory of the experiment with name metric.txt
.