-
Make sure you have Miniconda installed
- Conda is a package manager that sandboxes your project’s dependencies in a virtual environment
- Miniconda contains Conda and its dependencies with no extra packages by default (as opposed to Anaconda, which installs some extra packages)
-
cd into src, run
conda env create -f environment.yml
- This creates a Conda environment called
squad
- This creates a Conda environment called
-
Run
source activate squad
- This activates the
squad
environment - Do this each time you want to write/test your code
- This activates the
-
Run
python setup.py
- This downloads SQuAD 2.0 training and dev sets, as well as the GloVe 300-dimensional word vectors (840B)
- This also pre-processes the dataset for efficient data loading
- For a MacBook Pro on the Stanford network,
setup.py
takes around 30 minutes total
-
Browse the code in
train.py
- The
train.py
script is the entry point for training a model. It reads command-line arguments, loads the SQuAD dataset, and trains a model. - You may find it helpful to browse the arguments provided by the starter code. Either look directly at the
parser.add_argument
lines in the source code, or runpython train.py -h
.
- The
- Train
python train.py -n <name>
- this will generate log
log.txt
, tensorboard tfeventsevents.out.tfevents.*
and checkpointstep_N.pth.tar
,best.pth.tar
- this will generate log
- Test
python test.py -n <name> --load_path save/train/<name>-<ID>/best.pth.tar
- need to assign name
-n
or--name
- need to assign
--load_path
(just look up in thesave/train/<model name>-<ID>/best.pth.tar
)
- need to assign name
- Tracking progress in TensorBoard
- remote/local
tensorboard --logdir save --port 8889
http://localhost:8889
- port forwarding to local port 1234
ssh -N -f -L localhost:1234:localhost:8889 <user>@<remote>
http://localhost:1234
- remote/local
ssh -NfL 1234:localhost:8889 <user>@<remote> > /dev/null 2&>1
- BiDAF without character-level embedding layer (default baseline)
- Test on the best checkpoint:
Dev NLL: 03.22, F1: 59.96, EM: 56.70, AvNA: 66.95
- Common Command
- Train:
python train.py -n baseline -m BiDAF-baseline
- Train:
- Test on the best checkpoint:
- BiDAF-No-Answer (single model)
- Test on the best checkpoint:
Dev NLL: 02.89, F1: 63.36, EM: 59.84, AvNA: 70.04
- Common Command
- Train:
python train.py -n BiDAF-No-Answer -m BiDAF-w-char
- Train:
- Remarks
- I used Assignment 5 char model embedding module and share half
hidden_size
with original word embedding then concatenate them together as the new word representation
- I used Assignment 5 char model embedding module and share half
- Test on the best checkpoint:
- ...(more improvement)
util.py
class CheckpointSaver
(TODO)