Sentiment Analysis (SA) holds considerable significance in comprehending public perspectives and conducting precise opinion-based evaluations, making it a prominent theme in natural language processing research. With the increasing trend of online shopping and social media usage, there is a constant influx of diverse data types such as images, videos, audio, and text. Notably, text stands out as the most crucial form of unstructured data, demanding heightened attention from researchers. Given the voluminous nature of data, various methodologies have been proposed to effectively mine big datasets for valuable insights. The challenge of accurately identifying polarity in extensive customer evaluations persists due to the intricacies associated with handling large textual datasets derived from reviews, comments, tweets, and posts. This study addresses this challenge by presenting a straightforward architecture, the Double Path Transformer Network (DPTN), designed to model both global and local information for comprehensive review categorization. To enhance the synergy between the attention path and the convolutional path, the study advocates a parallel design that combines a robust self-attention mechanism with a convolutional network. The research employs the gaining-sharing knowledge optimization (GSK) approach to fine-tune hyperparameters, thereby improving the model's classification accuracy. Additionally, the investigation demonstrates that optimization algorithms and deep learning collaboratively manage class imbalances with finesse, even in the absence of explicit measures for such concerns. In the experiment analysis of the proposed model ultimately achieved an accuracy of 95.