Abstract
Substance use disorders (SUD) are a leading cause of psychiatric hospitalization among adolescents, yet the underlying diagnostic profiles and comorbidities remain poorly characterized. Here, we applied a transformer-based language model to 4,849 hospital discharge records from adolescents (aged 11–18) admitted with mental health and SUD in Spain between 2016 and 2020. We generated dense clinical embeddings and identified sex-specific diagnostic clusters using unsupervised learning. Male subgroups were primarily defined by externalizing disorders such as conduct disorder, ADHD, and psychosis, often associated with cannabis and alcohol use. Female subgroups exhibited higher rates of borderline personality traits, mood instability, suicidal ideation, and stress-related conditions. A unified embedding space revealed a clear sex-based separation in diagnostic patterns. These findings highlight the potential of transformer-based embeddings to uncover latent clinical phenotypes and inform precision approaches to adolescent mental health care. These sex-specific subtypes could enhance early intervention strategies and support the development of tailored treatment programmes for youths with SUD.
Competing Interest Statement
MC is currently associated with Cambridge Precision Medicine Limited.
Funding Statement
Yes
Author Declarations
I confirm all relevant ethical guidelines have been followed, and any necessary IRB and/or ethics committee approvals have been obtained.
Not Applicable
The details of the IRB/oversight body that provided approval or exemption for the research described are given below:
The study was approved by the Clinical Research Ethics Committee of the Universidad Internacional de La Rioja (UNIR) (ref. PI-022/2023 4/27/2023).
I confirm that all necessary patient/participant consent has been obtained and the appropriate institutional forms have been archived, and that any patient/participant/sample identifiers included were not known to anyone (e.g., hospital staff, patients or participants themselves) outside the research group so cannot be used to identify individuals.
Not Applicable
I understand that all clinical trials and any other prospective interventional studies must be registered with an ICMJE-approved registry, such as ClinicalTrials.gov. I confirm that any such study reported in the manuscript has been registered and the trial registration ID is provided (note: if posting a prospective study registered retrospectively, please provide a statement in the trial ID field explaining why the study was not registered in advance).
Not Applicable
I have followed all appropriate research reporting guidelines, such as any relevant EQUATOR Network research reporting checklist(s) and other pertinent material, if applicable.
Not Applicable
Data Availability
All the data and code developed for this research are publicly available in the GitHub repository https://github.com/manuelcorpas/LLM-Mental-Health-Clustering. The repository provides Python scripts for data preprocessing, fine-tuning DeBERTa-v3, contrastive embedding, unsupervised clustering, and PCA/UMAP visualization, along with instructions for replicating each step. The data for males and females are available as CSV files with the corresponding predicted cluster pipeline result. Licensed under the MIT License, the code may be freely used and adapted for academic or other purposes, thereby promoting reproducible research and collaborative improvement of the pipeline.
https://github.com/manuelcorpas/LLM-Mental-Health-Clustering





