A Hybrid Transformer and CNN-Based Approach for Classifying Mental Health Disorders from Social Media Data

Authors

  • Muhammad Alamzeb Khan Department of Computer Science, University of Science and Technology, Bannu, Pakistan
  • Muhammad Owais Khan Department of Computer Science, University of Science and Technology, Bannu, Pakistan
  • Haseena Noureen Department of Computer Science, University of Malakand, Pakistan
  • Muhammad Shoaib Khan University of Science and Technology Beijing, China
  • Muhammad Fawad Department of Computer Science, Govt Degree College, Thana, Pakistan

Keywords:

Hybrid Transformer, CNN, Mental Health, Social Media, Depression, Anxiety, PTSD, BPD, PsychBERT, MetaBERT, NLP, Text Classification

Abstract

Mental health disorders are a significant global concern, with increasing prevalence on social media platforms where individuals often share their experiences and emotions. This research presents a novel approach for classifying mental health disorders, specifically depression, anxiety, borderline personality disorder (BPD), and post-traumatic stress disorder (PTSD), using social media text. We propose a hybrid architecture that combines domain-specific transformer models, such as PsychBERT and MetaBERT, with Convolutional Neural Networks (CNNs) to enhance the model’s ability to understand mental health-related language and metaphorical expressions. The transformer models, pretrained on mental health and symbolic data, generate embeddings that capture the unique linguistic features in social media posts. These embeddings are processed through cascaded CNN layers to extract deep features, which are then concatenated and classified into mental illness categories. The model was evaluated using a balanced dataset comprising 40,000 social media posts, achieving an overall accuracy of 96% and an F1-score of 0.96. The proposed model outperforms existing state-of-the-art methods, including fine-tuned BERT and RoBERTa models, demonstrating superior performance in accurately classifying mental health disorders. The results highlight the effectiveness of leveraging domain-specific language models and CNNs for enhanced classification of mental health conditions in social media text. This study underscores the potential of advanced deep learning techniques in addressing mental health issues and facilitating early detection in real-world applications.

References

N. A. S. R. C. Kessler, “Anxious and non-anxious major depressive disorder in the World Health Organization World Mental Health Surveys,” Epidemiol. Psychiatr. Sci., vol. 24, no. 3, pp. 210–226, 2015, doi: 10.1017/S2045796015000189.

H. L. Robert E. Kraut, “Mental health during the COVID-19 pandemic: Impacts of disease, social isolation, and financial stressors,” PLoS One, vol. 17, no. 11, p. 11, 2022, doi: https://doi.org/10.1371/journal.pone.0277562.

J. M. Donohue and H. A. Pincus, “Reducing the Societal Burden of Depression,” PharmacoEconomics 2007 251, vol. 25, no. 1, pp. 7–24, Nov. 2012, doi: 10.2165/00019053-200725010-00003.

M. Garg, “Mental Health Analysis in Social Media Posts: A Survey,” Arch. Comput. Methods Eng., vol. 30, no. 3, pp. 1819–1842, Apr. 2023, doi: 10.1007/S11831-022-09863-Z/METRICS.

R. T. & P. Wolff, “Predicting future mental illness from social media: A big-data approach,” Behav. Res. Methods, vol. 51, pp. 1586–1600, 2019, doi: https://doi.org/10.3758/s13428-019-01235-z.

D. D. L. Luke Balcombe, “Digital Mental Health Challenges and the Horizon Ahead for Solutions,” JMIR Ment Heal., vol. 8, no. 3, 2021, [Online]. Available: https://mental.jmir.org/2021/3/e26811

K. H. A. Masab A. Mansoor, “Early Detection of Mental Health Crises through Artificial-Intelligence-Powered Social Media Analysis: A Prospective Observational Study,” J. Pers. Med., vol. 14, p. 958, 2024, doi: https://doi.org/10.3390/jpm14090958.

C. Y. C. and R. M. Lin Sze Khoo ,Mei Kuan Lim, “Machine Learning for Multimodal Mental Health Detection: A Systematic Review of Passive Sensing Approaches,” Sensors, vol. 24, no. 2, p. 348, 2024, doi: https://doi.org/10.3390/s24020348.

M. S. R. and A. B. M. S. A. M. M. Hossain, Sanjara, M. S. Hossain, S. Chaki, “Revolutionizing Mental Health Sentiment Analysis With BERT-Fuse: A Hybrid Deep Learning Model,” IEEE Access, vol. 13, pp. 85428–85446, 2025, doi: 10.1109/ACCESS.2025.3568340.

M. S. & S. A. Md. Mithun Hossain, Md. Shakil Hossain, M. F. Mridha, “Multi task opinion enhanced hybrid BERT model for mental health analysis,” Sci. Reports Vol., vol. 15, p. 3332, 2025, doi: https://doi.org/10.1038/s41598-025-86124-6.

Z. H. S. Abdullah Mazhar, “Figurative-cum-Commonsense Knowledge Infusion for Multimodal Mental Health Meme Classification,” WWW 2025 - Proc. ACM Web Conf., vol. 4, pp. 637–648, 2025, [Online]. Available: https://dl.acm.org/doi/10.1145/3696410.3714778

A. Das Rajashree Dash, Spandan Udgata, Rupesh K. Mohapatra, Vishanka Dash, “A Deep Learning Approach to Unveil Types of Mental Illness by Analyzing Social Media Posts,” Math. Comput. Appl, vol. 30, no. 3, p. 49, 2025, doi: https://doi.org/10.3390/mca30030049.

P. Gupta, A. Biswas, S. Gupta, and S. Jindal, “Reviewing depression analysis from social media platform data,” Adv. Electron. Comput. Phys. Chem. Sci., pp. 1–6, Jan. 2025, doi: 10.1201/9781003616252-1/REVIEWING-DEPRESSION-ANALYSIS-SOCIAL-MEDIA-PLATFORM-DATA-PREKSHA-GUPTA-ATIKA-BISWAS-SALONI-GUPTA-SHWETA-JINDAL.

F. S. Rebecca Macy, “Designing and developing a prescription digital therapeutic for at-home heart rate variability biofeedback to support and enhance patient outcomes in post-traumatic stress disorder treatment,” Front. Digit. Heal., vol. 7, 2025, [Online]. Available: https://www.frontiersin.org/journals/digital-health/articles/10.3389/fdgth.2025.1503361/full

A. M. Baqasah, “Deciphering Personality Disorders in the Digital Realm: A Deep Learning Approach Based on LSTM to Social Media Analysis,” 2024 Int. Symp. Syst. Adv. Technol. Knowledge, ISSATK 2024, 2024, doi: 10.1109/ISSATK62463.2024.10808851.

I. H. Bell et al., “Advances in the use of virtual reality to treat mental health conditions,” Nat. Rev. Psychol. 2024 38, vol. 3, no. 8, pp. 552–567, Jul. 2024, doi: 10.1038/s44159-024-00334-9.

Q. L. Bei Zhu, “The relationship between physical exercise and depressive symptoms in college students: the mediating role of rumination,” Front. Psychiatry, vol. 15, 2024, doi: https://doi.org/10.3389/fpsyt.2024.1501996.

M. H. N. Tayarani and S. I. Shahid, “Detecting Anxiety via Machine Learning Algorithms: A Literature Review,” IEEE Trans. Emerg. Top. Comput. Intell., 2025, doi: 10.1109/TETCI.2025.3543307.

F. Fkih, D. Rhouma, and T. Alharbi, “Mental disorder preventing by worry levels detection in social media using deep learning based on psycho-linguistic features: application on the COVID-19 lockdown period,” Comput. Biol. Med., vol. 191, p. 110162, 2025, doi: https://doi.org/10.1016/j.compbiomed.2025.110162.

H. M. Wai Lim Ku, “Evaluating Machine Learning Stability in Predicting Depression and Anxiety Amidst Subjective Response Errors,” Healthcare, vol. 12, no. 6, p. 625, 2024, doi: https://doi.org/10.3390/healthcare12060625.

P. Cho, “Leveraging Wearables Data to Understand Behavioral Patterns and Predict Influenza-like Illnesses,” 2025, Dissertation, Duke University. Accessed: Jul. 26, 2025. [Online]. Available: https://hdl.handle.net/10161/32839

O. Gerrish, “Exploring the Links Between Masculinities and Sexual Consent Through the Lens of Social Work,” Univ. Illinois Chicago, 2025, doi: https://doi.org/10.25417/uic.29337539.v1.

I. U. Zeeshan Ali Haider, Khan, F. M., Zafar, A., Nabila, & Khan, “Optimizing Machine Learning Classifiers for Credit Card Fraud Detection on Highly Imbalanced Datasets Using PCA and SMOTE Techniques,” VAWKUM Trans. Comput. Sci., vol. 12, no. 2, pp. 28–49, 2024, doi: https://doi.org/10.21015/vtcs.v12i2.1921.

H. Khan, I. U., Zeb, A., Rahman, T., Khan, F. M., Haider, Z. A., & Bilal, “ViTDroid and Hybrid Models for Effective Android and IoT Malware Detection,” Trans. Adv. Comput. Syst., vol. 1, no. 1, pp. 32–47, 2024.

J. C. Zhuyun Dai, “Deeper Text Understanding for IR with Contextual Neural Language Modeling,” SIGIR’19 Proc. 42nd Int. ACM SIGIR Conf. Res. Dev. Inf. Retr., pp. 985–988, 2019, doi: https://doi.org/10.1145/3331184.333130.

M. Lyons, N. D. Aksayli, and G. Brewer, “Mental distress and language use: Linguistic analysis of discussion forum posts,” Comput. Human Behav., vol. 87, pp. 207–211, 2018, doi: https://doi.org/10.1016/j.chb.2018.05.035.

E. A. Gibbs, R. W., Jr., Leggitt, J. S., & Turner, “What’s special about figurative language in emotional communication?,” S. R. Fussell (Ed.), verbal Commun. Emot. Interdiscip. Perspect., 2002, [Online]. Available: https://psycnet.apa.org/record/2002-17180-005

C. S. Falk Leichsenring, Peter Fonagy, Nikolas Heim, Otto F. Kernberg, Frank Leweke, Patrick Luyten, Simone Salzer, Carsten Spitzer, “Borderline personality disorder: a comprehensive review of diagnosis and clinical presentation, etiology, treatment, and current controversies,” World Psychiatry, vol. 23, no. 1, p. 2, 2024, doi: https://doi.org/10.1002/wps.21156.

J. F. V. Roger Alan Stein, Patricia A. Jaques, “An analysis of hierarchical text classification using word embeddings,” Inf. Sci. (Ny)., vol. 471, pp. 216–232, 2019, doi: https://doi.org/10.1016/j.ins.2018.09.001.

Q. Z.-T. Duy Duc An Bui, “Learning regular expressions for clinical text classification,” J. Am. Med. Informatics Assoc., vol. 21, no. 5, pp. 850–857, 2014, doi: https://doi.org/10.1136/amiajnl-2013-002411.

R. P. Balaram Puli, Pandian Sundaramoorthy, Rajesh Daruvuri N N Jose and S. Chidambaranathan, “Hybrid AI-Driven Framework for Mental Disorder Detection Using Facial Emotion Recognition and Deep Learning,” Int. Res. J. Eng. Technol., vol. 12, no. 2, 2025, [Online]. Available: https://www.irjet.net/archives/V12/i2/IRJET-V12I225.pdf

Downloads

Published

2025-07-31

How to Cite

Muhammad Alamzeb Khan, Muhammad Owais Khan, Haseena Noureen, Khan, M. S., & Muhammad Fawad. (2025). A Hybrid Transformer and CNN-Based Approach for Classifying Mental Health Disorders from Social Media Data. International Journal of Innovations in Science & Technology, 7(3), 1717–1738. Retrieved from https://journal.50sea.com/index.php/IJIST/article/view/1494

Issue

Section

Articles

Categories