Integrating dense layers with residual connections into transformers for enhanced sentiment classification
摘要
Sentiment analysis is a critical task in natural language processing (NLP), driven by the exponential growth of user-generated content across social media and review platforms. Transformer-based models such as BERT have significantly advanced the field by capturing contextual nuances, yet they often struggle with subtle sentiment, sarcasm, and long-range dependencies common in movie reviews. We propose Dense Residual Attention Network (DRANet), a model designed to enhance transformer-based architectures for binary sentiment classification on IMDb and MR datasets. DRANet integrates a pre-trained BERT encoder with a customized classification head that employs dense (fully connected) layers and residual connections to improve gradient flow and feature propagation, enabling the capture of intricate cross-layer patterns. In addition, we introduce an attention-averaging mechanism that consolidates attention across heads in the final transformer layer, applying the aggregated weights to hidden states to emphasize sentiment-bearing tokens while down-weighting irrelevant context. Given the computational intensity of large transformer encoders and multi-layer residual heads, training and deployment at scale naturally require high-performance computing (HPC) resources. To assess scalability, we benchmarked DRANet under single and dual GPU settings. On IMDb (long-form reviews, 294 tokens), per-epoch training time dropped from 12.09 to 6.18 min (1.95