Anwar, Md. TawhidAhmed, Md. SabbirAlam, Md. AshrafulSakib, SadmanHossain, NahmarChowdhury, Kumar Prothom Pranto SarmaHakim, ShehzadIslam, A Q M Mujahidul2026-08-102026-08-1020262026-01ID 21201605ID 21201639ID 22201736ID 22341022ID 22101014https://hdl.handle.net/10361/28896This thesis is submitted in partial fulfillment of the requirements for the degree of Bachelor of Science in Computer Science and Engineering, 2026.Cataloged from PDF version of thesis.Includes bibliographical references (pages 38-40).Insomnia affects a significant portion of the global population, yet distinguishing between primary and secondary insomnia—where sleep disturbances stem from underlying medical, psychiatric, or environmental factors—remains critically underexplored in computational health research. This study presents a multi-stage computational framework for identifying and phenotyping secondary insomnia from naturalistic Reddit discussions. A clinically validated dataset of 600 posts was developed, with linguistic validation confirming that secondary insomnia posts contain significantly more biomedical terminology than primary insomnia posts. Mental- RoBERTa, a domain-adapted transformer, was employed (after the initial integration of RoBERTa-Base) for identifying cases, which outperformed both traditional baselines and large language models. The trained model identified over 3,400 high confidence secondary insomnia cases from 5,000 unlabeled posts. A hybrid pipeline combining Llama-3 clinical summarization with BERTopic unsupervised clustering discovered 10 distinct etiological categories, revealing gastroesophageal reflux disease, menopausal factors, and benzodiazepine withdrawal as predominant drivers. Zero-shot emotion profiling revealed distinct psychological phenotypes across different triggers, with benzodiazepine withdrawal exhibiting the highest perplexity and environmental factors showing the greatest frustration. This framework enables the first large-scale computational characterization of secondary insomnia drivers and their psychological burdens, providing actionable insights for precision intervention design and population health surveillance in digital mental health systems.47 pagesen-USAttribution-NonCommercial-NoDerivatives 4.0 InternationalBRAC University theses are protected by copyright. They may be viewed from this source for any purpose, but reproduction or distribution in any format is prohibited without written permission.http://creativecommons.org/licenses/by-nc-nd/4.0/InsomniaMachine learningSupervised learningText classificationSleep disordersMental healthZero-shot emotion profilingNatural language processing (Computer science).Insomnia--Diagnosis.Sleep disorders--Classification.Insomnia--Etiology.Mental health--Data processing.Integrating mental-RoBERTa and generative LLMs for phenotyping secondary insomnia: A multi-dimensional framework for etiology discoveryThesis