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
- Host: GitHub
- URL: https://github.com/zcemycl/seq2seq-labelladder
- Owner: zcemycl
- Created: 2021-12-02T11:06:29.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-02T12:08:45.000Z (about 4 years ago)
- Last Synced: 2025-08-30T11:49:36.828Z (5 months ago)
- Topics: encoder-decoder-model, hierarchical-attention-networks, nlp, pytorch, seq2seq
- Language: Python
- Homepage:
- Size: 158 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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%