The repo proposes a method (encoder-decoder-attention network) to classify paragraphs of texts to hierarchical labels, from level 1 to level3. There are 9 labels in l1, 70 in l2 ad 219 in l3, each label in layer n has different distribution of labels in next layer n+1, it manifests a ladder structure resembling a n-gram model, so that the rnn-based decoder can be useful.
- Install the required packages,
pip install -r requirements.txt
- Train the network via,
python train.py [--csv classification_dataset.csv][--pairs_txt pairs.txt]
[--seed 1][--split 0.99][--logdir log/run][--checkpoint weight/run]
[--iters 75000][--saveIntervals 1000][--lr 0.01]
- View training progress via tensorboard,
tensorboard --logdir log/run
- Predict the new sentence via,
python predict.py [--weightE weight/run/encoder-75000.pth]
[--weightD weight/run/attn_decoder-75000.pth][--pairs_txt pairs.txt]
[--sentence 'He was a pupil of the painter Denis Calvaert, then of Guido Reni.']
Test Accuracy | Loss |
---|---|
Output (Ground Truth | |||
---|---|---|---|
Preprocessed Test Case | l1 | l2 | l3 |
bishop cathedral catholic church community diocesan diocese heart home know mother new parish present recently sacred seat well york | place | building | historicbuilding |
born footballer german marcel retire | agent | athlete | soccerplayer |
accepted also alumnus anonymous artist bachelor certificate college conjunction diploma doctor donation full graduate joint later master million music musical offering one performance professional program reveal school three twelve university yale | agent | person (educationalinstitution) | journalist (university) |
Test Accuracy | 93.08% | 85.04% | 77.02% |
Overall | 75.77% |