==============================================================================
This directory contains code to reproduce:
1) The scalability analysis ("scalability" directory)
2) The dependency parsing experiments ("parsing" directory)

Note: For the latent structure recovery experiments we relied on
the official PyTorch implementation of "Gradient Estimation with
Stochastic Softmax Tricks" (https://github.com/choidami/sst)
==============================================================================

Requirements
============
- python 3.7
- pytorch 1.8.1
- torchvision
- nltk
- ray
- cython
- ad3 (https://github.com/andre-martins/ad3)
- sparsemap (https://github.com/vene/sparsemap)


1) Scalability analysis:
===================================

To reproduce the published results, choose the network size via the --hidden_dim parameter:
Setting the --hidden_dim parameter to be 16 will produce a neural network of 25K parameters, and 
multiplying it by two will also enlarge the number of parameters by two.

To optimize via NES, run:
python main.py --dataset FashionMNIST --binarize --validate --nes --n_perturb [number of samples]

To optimize via SST, run:
python main.py --dataset FashionMNIST --binarize --validate --sst


2) Dependency parsing:
======================

Given that the source domain is "galician-ctg" and the target domain is "galician-treegal",
we first train the model on the source domain in a supervised manner by running:

For projective dependency parsing -

python main.py --source galician-ctg --target galician-treegal  --ext_emb data/ext_emb/cc.gl.300.vec
--target_epochs 0

For non-projective dependency parsing -

python main.py --source galician-ctg --target galician-treegal  --ext_emb data/ext_emb/cc.gl.300.vec
--target_epochs 0 --non_projective

Then, to reproduce NES results, run:
------------------------------------
For projective dependency parsing -

python main.py --source galician-ctg --target galician-treegal  --ext_emb data/ext_emb/cc.gl.300.vec
--source_epochs 0 --pretrained_path results/supervised_s=galician-ctg_proj=True_lr=0.001_seed=0
--nes --freeze_decoder

For non-projective dependency parsing -

python main.py --source galician-ctg --target galician-treegal  --ext_emb data/ext_emb/cc.gl.300.vec
--source_epochs 0 --pretrained_path results/supervised_s=galician-ctg_proj=False_lr=0.001_seed=0
--nes --freeze_decoder --non_projective

and tune --target_lr by performing grid-search over the [5e-4, 1e-5] interval.

To reproduce DPP results, run:
------------------------------

python main.py --source galician-ctg --target galician-treegal  --ext_emb data/ext_emb/cc.gl.300.vec
--source_epochs 0 --pretrained_path results/supervised_s=galician-ctg_proj=True_lr=0.001_seed=0

and tune --target_lr by performing grid-search over the [5e-4, 1e-5] interval.

To reproduce sparseMAP results, run:
------------------------------------

python main.py --source galician-ctg --target galician-treegal  --ext_emb data/ext_emb/cc.gl.300.vec
--source_epochs 0 --pretrained_path results/supervised_s=galician-ctg_proj=False_lr=0.001_seed=0 --non_projective

and tune --target_lr by performing grid-search over the [5e-4, 1e-5] interval.



