castorini / castor

PyTorch deep learning models for text processing
http://castor.ai/
Apache License 2.0
178 stars 58 forks source link

Add CharacterCNN for Document Classification #155

Closed achyudh closed 5 years ago

achyudh commented 5 years ago

Implementation of Char-CNN from Character-level Convolutional Networks for Text Classification (http://papers.nips.cc/paper/5782-character-level-convolutional-networks-for-text-classification.pdf)

Quick Start

To run the model on Reuters dataset, just run the following from the Castor working directory:

python -m char_cnn --dataset Reuters --gpu 1 --batch_size 128 --lr 0.001

To test the model, you can use the following command.

python -m char_cnn --trained_model kim_cnn/saves/Reuters/best_model.pt

Dataset

We experiment the model on the following datasets.

Settings

Adam is used for training.

Dataset Results

RCV-1

python -m char_cnn --dataset Reuters --gpu 1 --batch_size 128 --lr 0.001
  Accuracy Avg. Precision Avg. Recall Avg. F1
Char-CNN (Dev) 0.585 0.702 0.569 0.628
Char-CNN (Test) 0.589 0.691 0.552 0.614

AAPD

python -m char_cnn --dataset AAPD --gpu 1 --batch_size 128 --lr 0.001
  Accuracy Avg. Precision Avg. Recall Avg. F1
Char-CNN (Dev) 0.305 0.681 0.537 0.600
Char-CNN (Test) 0.294 0.681 0.526 0.593
achyudh commented 5 years ago

@Impavidity Sorry for so many PRs. Can you please take a look whenever you have the time? This makes a bunch of changes to ReutersTrainer and ReutersEvaluator classes so merging this before any other changes by @Ashutosh-Adhikari would help me ensure that the code doesn't break.