Practical overview
When it fits
Use it when you want a code-based starting point for training and evaluating a hierarchical-attention text classifier, and can work with the repository’s listed Python and PyTorch versions.
Who it is for
- Developers and researchers building document-classification models with Python and PyTorch
- Practitioners evaluating text classifiers on datasets with matching class labels
Documented uses
- Train a hierarchical-attention document classifier on a dataset
- Evaluate a trained model against a test set with the same classes
- Adjust batch size, learning rate and word2vec initialization for experiments
Requirements & limits
- The stated dependencies include Python 3.6 and PyTorch 0.4, alongside TensorBoard and NumPy.
- Evaluation requires the test dataset to use the model’s class set; the README specifies reusing the training word2vec file.
- TensorBoardX is only required when using SummaryWriter.
- The README reports that batch size and learning rate can affect convergence, and that early stopping is based on test loss.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Train and test a document classifier
Use the documented commands to train a model and evaluate it on a test dataset with the same classes.
Before you start
- Python 3.6 and PyTorch 0.4
- TensorBoard, NumPy and, when using SummaryWriter, TensorBoardX
- A training dataset and a test dataset with the same set of classes
- For word2vec-based evaluation, the same embedding file used for training
Steps
Run the command below to train with default parameters, or set batch size and learning rate with the command below.
python train.pypython train.py --batch_size batch_size --lr learning_rateTo select an embedding file, pass
--word2vec_path path/to/your/word2vecto the training command.Run the command below to test a trained model, using the same word2vec file as in training.
python test.py --word2vec_path path/to/your/word2vec
Expected outcome
A trained document-classification model can be evaluated on test data whose class set matches the model’s.
Guide limitations
- The README says batch size and learning rate affect convergence and may need to be chosen for the dataset and embedding dimension.
- The documented testing command specifies the word2vec path and does not describe other test-file arguments.
- The README’s results table includes entries marked “updated soon.”
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 15 November 2026
- Original website title
- vietnh1009/Hierarchical-attention-networks-pytorch · Official homepage title · retained in its source language

