An open API service indexing awesome lists of open source software.

https://github.com/zcemycl/seq2seq-labelladder


https://github.com/zcemycl/seq2seq-labelladder

encoder-decoder-model hierarchical-attention-networks nlp pytorch seq2seq

Last synced: 5 months ago
JSON representation

Awesome Lists containing this project

README

          

## Sequence-to-sequence Hierarchical Categories Classification
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.

### How to run?
1. Install the required packages,
```
pip install -r requirements.txt
```
2. 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]
```
3. View training progress via tensorboard,
```
tensorboard --logdir log/run
```
4. 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.']
```

### Results
|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%