Attention for text classification, circa 2017
A straightforward TensorFlow implementation of hierarchical attention for document classification, with a side of Russian sentiment analysis.

What it does
Implements the attention mechanism from Yang et al.’s “Hierarchical Attention Networks for Document Classification” paper in TensorFlow. Feed it text, get classification output plus attention weights you can visualize. The repo includes a working example with the IMDB dataset and a link to a live visualization demo.
The interesting bit
The author actually shipped this for a bachelor’s thesis on Russian sentiment classification — so there’s battle-tested code beyond the standard English IMDB toy example. The attention weights are exposed and visualizable, which in 2017 was still worth calling out explicitly.
Key highlights
- Implements word-level and sentence-level attention (the “hierarchical” part)
- Ships with a working IMDB example and attention visualization
- Python 2.6+ and TensorFlow 1.0+ — very much of its era
- Author’s thesis repo extends this to Russian-language sentiment analysis
- ~750 stars suggests it was a useful reference implementation in the TF 1.x era
Caveats
- TensorFlow 1.x only; will need porting for modern TF/PyTorch workflows
- README is minimal — no usage examples, no performance numbers, no tests visible
- Keras dependency is specifically for dataset loading, not model definition
Verdict
Worth a look if you’re studying attention mechanisms historically or need to understand the Yang et al. paper concretely. Skip if you want production-ready code or modern framework support — this is a clean reference implementation, not a maintained library.