DSWE-GRNN: Multi-class Review Rating Classification
This model reproduces the DSWE-GRNN (Domain-Specific Word Embeddings with Gated Recurrent Neural Network) architecture from the paper:
"Multi-class Review Rating Classification using Deep Recurrent Neural Network"
Junaid Hassan, Umar Shoaib
Neural Computing and Applications (Springer), 2019
DOI: 10.1007/s11063-019-10125-6
Architecture
- Embedding Layer: Domain-specific CBOW word embeddings (32-dimensional), trained on the corpus vocabulary
- GRU Layers: 2 stacked GRU layers with 14 hidden units
- Dropout: 0.15 (85% retention)
- Output: Dense layer with softmax for multi-class classification
- Optimizer: Adam
- Loss: Cross-entropy with class weighting for imbalance handling
Datasets
Hotel Reviews
- Source: TripAdvisor hotel reviews (
jniimi/tripadvisor-review-rating) - Classes: 5 (1β5 star ratings)
- Samples: 14,895 total, 5,000 used for fast experimentation
- Preprocessing: Lowercasing, punctuation removal, word tokenization
IMDB (planned)
- Classes: 10 (1β10 scale)
- Samples: 50,000
Results
Our Implementation (Hotel Reviews, 5K subset)
| Metric | Value |
|---|---|
| Accuracy | 0.629 |
| F1 (weighted) | 0.618 |
| F1 (macro) | 0.518 |
Paper Baselines (Hotel Reviews)
| Method | Accuracy |
|---|---|
| WE-SimpleNN | 0.8024 |
| CNN | 0.7877 |
| LSTM | 0.8092 |
| CNN-LSTM | 0.7843 |
| DSWE-GRNN (paper) | 0.8132 |
Gap Analysis
Our reproduction achieves 62.9% accuracy on a 5K subset vs the paper's 81.32% on the full 14,895 samples. Key factors:
- Dataset size: 5,000 vs 14,895 samples
- Downsampling strategy: Paper used class balancing; our best results use class-weighted loss on imbalanced data
- Training epochs: CPU constraints limited experiments
- Sequence length:
max_len=128-200vs paper's full review lengths
Usage
import torch
from dswe_grnn import DSWE_GRNN, TextPreprocessor, Vocabulary
# Load model checkpoint
checkpoint = torch.load("dswe_grnn_hotel_5k.pt")
model = DSWE_GRNN(
vocab_size=10489,
embedding_dim=32,
hidden_dim=64,
num_classes=5,
num_layers=2,
dropout=0.2
)
model.load_state_dict(checkpoint)
model.eval()
# Preprocess text
preprocessor = TextPreprocessor()
tokens = preprocessor.preprocess("Great hotel, amazing service and beautiful rooms!")
Files
dswe_grnn.pyβ Core model implementationrun_experiment.pyβ Training scriptresults_hotel_5k.jsonβ Evaluation metricsdswe_grnn_hotel_5k.ptβ Model weights
Citation
@article{hassan2019multicl ass,
title={Multi-class Review Rating Classification using Deep Recurrent Neural Network},
author={Hassan, Junaid and Shoaib, Umar},
journal={Neural Computing and Applications},
year={2019},
publisher={Springer},
doi={10.1007/s11063-019-10125-6}
}