fastNLP/reproduction/Char-aware_NLM
FengZiYjun 7514be6f30 - add validation loss into trainer.train
- restructure: move reproduction outside
- add evaluate in tester
2018-07-11 21:51:35 +08:00
..
__init__.py - add validation loss into trainer.train 2018-07-11 21:51:35 +08:00
LICENSE - add validation loss into trainer.train 2018-07-11 21:51:35 +08:00
model.py - add validation loss into trainer.train 2018-07-11 21:51:35 +08:00
README.md - add validation loss into trainer.train 2018-07-11 21:51:35 +08:00
test.py - add validation loss into trainer.train 2018-07-11 21:51:35 +08:00
test.txt - add validation loss into trainer.train 2018-07-11 21:51:35 +08:00
train.py - add validation loss into trainer.train 2018-07-11 21:51:35 +08:00
train.txt - add validation loss into trainer.train 2018-07-11 21:51:35 +08:00
utilities.py - add validation loss into trainer.train 2018-07-11 21:51:35 +08:00
valid.txt - add validation loss into trainer.train 2018-07-11 21:51:35 +08:00

PyTorch-Character-Aware-Neural-Language-Model

This is the PyTorch implementation of character-aware neural language model proposed in this paper by Yoon Kim.

Requiredments

The code is run and tested with Python 3.5.2 and PyTorch 0.3.1.

HyperParameters

HyperParam value
LSTM batch size 20
LSTM sequence length 35
LSTM hidden units 300
epochs 35
initial learning rate 1.0
character embedding dimension 15

Demo

Train the model with split train/valid/test data.

python train.py

The trained model will saved in cache/net.pkl. Test the model.

python test.py

Best result on test set: PPl=127.2163 cross entropy loss=4.8459

Acknowledgement

This implementation borrowed ideas from

https://github.com/jarfo/kchar

https://github.com/cronos123/Character-Aware-Neural-Language-Models