* Add ReutersTrainer, ReutersEvaluator options in Factory classes * Add Reuters to Kim-CNN command line arguments * Fix SST dataset path according to changes in Kim-CNN args The dataset path in args.py was made to point at the dataset folder rather than dataset/SST folder. Hence SST folder was added to paths in the SST dataset class * Add Reuters dataset class, and support in __main__ * Add Reuters dataset trainers and evaluators * Remove debug print statement in reuters_evaluator * Fix rounding bug in reuters_trainer and reuters_evaluator * Add LSTM for baseline text classification measurements * Add eval metrics for lstm_baseline * Set batch_first param in lstm_baseline * Remove onnx args from lstm_baseline * Pack padded sequences in LSTM_baseline * Add TensorBoardX support for Reuters trainer * Add Arxiv Academic Paper Dataset (AAPD) * Add Hidden Bottleneck Layer to BiLSTM * Fix packing of padded tensors in Reuters * Add cmdline args for Hidden Bottleneck Layer for BiLSTM * Include pre-padding lengths in AAPD dataset * Remove duplication of preprocessing code in AAPD * Remove batch_size condition in ReutersTrainer * Add ignore_lengths option to ReutersTrainer and ReutersEvaluator * Add AAPDCharQuantized and ReutersCharQuantized * Rename Reuters_hierarchical to ReutersHierarchical * Add CharacterCNN for document classification * Update README.md for CharacterCNN * Fix table in README.md for CharacterCNN * Add AAPDHierarchical for HAN * Update HAN for changes in Reuters dataset endpoints * Fix bug in CharCNN when running on CPU * Add AAPD dataset support for KimCNN * Fix dataset paths for SST-1 * Fix dimensions of FC1 in CharCNN * Add model checkpointing for Reuters based on F1 * Refactor LSTM baseline __main__ * Add precision, recall and F1 to Reuters evaluator * Checkpoint only at the end of an epoch for ReutersTrainer Add detailed log printing for dev evaluations * Fix log_template and dev_log_template in ReutersTrainer * Add IMDB dataset * Fix duplicate printing of header in ReutersTrainer * Add support for single_label datasets in ReutersTrainer * Add support for IMDB dataset in lstm_baseline and lstm_reg * Fix evaluator call in main method of HAN * Add IMDB for HAN * Fix for single_label * Fix evaluate_dataset method for single_label datasets * Reduce default patience to 5 epochs before early stopping * Revert change to save_state rather than the entire model * Add Yelp 2018 dataset * Integrate Yelp2018 with LSTM baseline * Replace Yelp2018 with Yelp2014 dataset * Add Yelp2014 to LSTM Baseline * Integrate Yelp14 into LSTM Regularization * Remove dropout in HBL for LSTM Baseline and Reg * Add Yelp for HAN * Fix the saving issue for HAN * Fix loading for HAN * Fix typo in ReutersEvaluator * Print to STDOUT rather than logger * Print XML-CNN eval to STDOUT rather than logger * Update max_length for IMDB dataset * Add single_label support for char_cnn * Fix evaluation method for char_cnn * Remove unwanted parameters from ReutersTrainer and ReutersEval * Fix code formatting in lstm_reg/args * Add support for IMDB and Yelp in KimCNN * Fix single_label incorporation * Remove unnecessary conditions * Fix num_classes in Yelp2014 * Add single_label support for XML-CNN * Fix call to evaluator in XML-CNN * Address PEP8 issues * Address PEP8 issues * Address PEP8 issues * Address PEP8 issues
Castor
This is the common repo for PyTorch deep learning models by the Data Systems Group at the University of Waterloo.
Models
Predictions Over One Input Text Sequence
For sentiment analysis, topic classification, etc.
- Kim CNN: baseline convolutional neural network for sentence classification (Kim, EMNLP 2014)
- conv-RNN: convolutional RNN (Wang et al., KDD 2017)
Predictions Over Two Input Text Sequences
For paraphrase detection, question answering, etc.
- SM-CNN: Siamese CNN for ranking texts (Severyn and Moschitti, SIGIR 2015)
- MP-CNN: Multi-Perspective CNN (He et al., EMNLP 2015)
- NCE: Noise-Contrastive Estimation for answer selection applied on SM-CNN and MP-CNN (Rao et al., CIKM 2016)
- VDPWI: Very-Deep Pairwise Word Interaction NNs for modeling textual similarity (He and Lin, NAACL 2016)
- IDF Baseline: IDF overlap between question and candidate answers
Each model directory has a README.md with further details.
Setting up PyTorch
If you are an internal Castor contributor using GPU machines in the lab, follow the instructions here.
Castor is designed for Python 3.6 and PyTorch 0.4. PyTorch recommends Anaconda for managing your environment. We'd recommend creating a custom environment as follows:
$ conda create --name castor python=3.6
$ source activate castor
And installing the packages as follows:
$ conda install pytorch torchvision -c pytorch
Other Python packages we use can be installed via pip:
$ pip install -r requirements.txt
Code depends on data from NLTK (e.g., stopwords) so you'll have to download them. Run the Python interpreter and type the commands:
>>> import nltk
>>> nltk.download()
Finally, run the following inside the utils directory to build the trec_eval tool for evaluating certain datasets.
$ ./get_trec_eval.sh
Data and Pre-Trained Models
If you are an internal Castor contributor using GPU machines in the lab, follow the instructions here.
To fully take advantage of code here, clone these other two repos:
Castor-data: embeddings, datasets, etc.Caster-models: pre-trained models
Organize your directory structure as follows:
.
├── Castor
├── Castor-data
└── Castor-models
For example (using HTTPS):
$ git clone https://github.com/castorini/Castor.git
$ git clone https://git.uwaterloo.ca/jimmylin/Castor-data.git
$ git clone https://git.uwaterloo.ca/jimmylin/Castor-models.git
After cloning the Castor-data repo, you need to unzip embeddings and run data pre-processing scripts. You can choose to follow instructions under each dataset and embedding directory separately, or just run the following script in Castor-data to do all of the steps for you:
$ ./setup.sh