Skip to content

This is a self-attention implement on cntk and was applied on text classification

License

Notifications You must be signed in to change notification settings

egg-west/Self-attention-on-text-calssification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using self-attention on text classification

This is a self-attentive model implementation on cntk. This repo applies it on text classification.

Prerequisites

  • python 3.6
  • cntk 2.4 for GPU
  • numpy

Dataset

The toy dataset used is ATIS, which is from cntk tutorial 202 Language Understanding with Recurrent Networks

Download ATIS training and test dataset

Another bigger dataset is AG's News Topic Classification Dataset

Model

Self-attentive-model

This implementation is based on paper A STRUCTURED SELF-ATTENTIVE SENTENCE EMBEDDING

Inspired by tensorflow implementation in this repo

  • Baseline: embeded + stabilizer + bi-GRU(150 for each direction) + fc + fc
  • Self-Attentive: embeded + stabilizer + bi-GRU(150 for each direction) + Self-Attentive + fc + fc

Result on toy dataset

Toy dataset train result

Loss

Error Rate

Result on AG's

loss

Error Rate

Run

unzip ag_data.zip
unzip toy_data.zip
python selfAtt.py --lr 0.03 --dataset toy --max_epoch 5 --batch_size 60 --self_attention

TODO

  • Add penalty

About

This is a self-attention implement on cntk and was applied on text classification

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages