A Multi-Stage Framework Combining Siamese Contrastive Learning and Domain-Adaptive BERT for Thai Lyrics Emotion Classification

Main Article Content

Natdanai Maichum
ปรวัฒน์ วิสูตรศักดิ์

บทคัดย่อ

Emotion recognition from song lyrics plays a crucial role in music information retrieval, recommendation systems, and affective computing. However, Thai song lyrics present unique linguistic challenges, including ambiguous word segmentation, figurative expressions, and culturally embedded meanings, which limit the effectiveness of existing multilingual and general-purpose language models. This study proposes a multi-stage deep learning pipeline for emotion classification in Thai song lyrics by integrating domain-adaptive language modeling and metric learning into a hybrid neural architecture. A balanced dataset of Thai song lyrics, comprising four primary emotional categories (Happy, Sadness, Anger, and Relaxed), was curated to include 12,000 balanced verse-level instances (3,000 samples per class) annotated using Russell's Circumplex Model of Affect. To enhance domain-specific representation learning, Domain-Adaptive Masked Language Modeling (MLM) was first applied to WangchanBERTa using a large corpus of Thai song lyrics. Subsequently, a Siamese Contrastive Learning framework incorporating a targeted hard-negative mining strategy was executed to optimize the geometric proximity of identical emotional states and untangle semantic overlaps between neighboring concepts (e.g., Happy vs. Relaxed). The adapted and contrastively-refined embeddings were subsequently processed by a hybrid architecture that combines a Bidirectional Long Short-Term Memory (BiLSTM) with an attention mechanism to capture long-range contextual dependencies and emotionally salient terms. To ensure rigorous evaluation validity and prevent data leakage, the pipeline was thoroughly evaluated using a stratified 5-fold cross-validation protocol. Experimental results demonstrate that the proposed approach significantly outperforms baseline models, including mBERT, XLM-RoBERTa, LaBSE, and the original WangchanBERTa. The proposed model achieves an overall accuracy of 96.24% and a macro-averaged F1-score of 0.9623, demonstrating robust, balanced performance across all emotion classes. These findings underscore the importance of domain adaptation, contrastive alignment, and hybrid architectures for effective emotion classification in low-resource, culturally nuanced languages such as Thai.

Downloads

Download data is not yet available.

Article Details

ประเภทบทความ
บทความวิจัย

เอกสารอ้างอิง

Visutsak, P.; Loungna, J.; Sopromrat, S.; Jantip, C.; Soponkittikunchai, P.; Liu, X. Mood-Based Music Discovery: A System for Generating Personalized Thai Music Playlists Using Emotion Analysis. Appl. Syst. Innov. 2025, 8, 37. https://doi.org/10.3390/asi8020037

Praveena, S. Emotion Classification Using BERT: A Comprehensive Study. J. Propuls. Technol. 2024, 45(4), 3337–3345.

Peng, H.; Gu, X.; Li, J.; Wang, Z.; Xu, H. Text-Centric Multimodal Contrastive Learning for Sentiment Analysis. Electronics 2024, 13, 1149. https://doi.org/10.3390/electronics13061149

Patkar, A.; Chandrashekhar, S.; Kadiyala, R. M. R. RoBERTa-Based Emotion Classification of Essays: Improving Performance on Imbalanced Data. In Proceedings of the WASSA Shared Task; 2023.

Nieminen, M. The Transformer Model and Its Impact on the Field of Natural Language Processing; Bachelor’s Thesis, Bachelor’s Programme in Computer Science, 2023.

Zhang, D.; Yuan, Z.; Liu, Y.; Liu, H.; Zhuang, F.; Xiong, H.; Chen, H. Domain-Oriented Language Modeling with Adaptive Hybrid Masking and Optimal Transport Alignment. In Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining; 2021; pp 2145–2153. https://doi.org/10.1145/3447548.3467215

Gao, T.; Yao, X.; Chen, D. SimCSE: Simple Contrastive Learning of Sentence Embeddings. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing (EMNLP); 2021. https://doi.org/10.18653/v1/2021.emnlp-main.552

Lowphansirikul, L.; Polpanumas, C.; Jantrakulchai, N.; Nutanong, S. WangchanBERTa: Pretraining Transformer-Based Thai Language Models. PyThaiNLP and VISTEC, 2021.

Pasupa, K.; Seneewong Na Ayutthaya, T. Hybrid Deep Learning Models for Thai Sentiment Analysis. Cogn. Comput. 2022. 14, 167–193. https://doi.org/10.1007/s12559-020-09770-0

Sánchez-Ruiz, A. A. Analyzing the Similarity Learned by a Siamese Network with Contrastive Loss on the MNIST Dataset. 2020.

Koch, G.; Zemel, R.; Salakhutdinov, R. Siamese Neural Networks for One-Shot Image Recognition; University of Toronto, 2015.

Hochreiter, S.; Schmidhuber, J. Long Short-Term Memory. Neural Comput. 1997, 9(8), 1735–1780. https://doi.org/10.1162/neco.1997.9.8.1735

Russell, J. A. A Circumplex Model of Affect. J. Pers. Soc. Psychol. 1980, 39(6), 1161–1178. https://doi.org/10.1037/h0077714