EUVIMEDDescoperă EUVIMED
Open access

Automated Risk Assessment of Opioid Use: Analysis Using Pre-Trained Transformers on Social Media Data

Muhammad Ahmad iD, Rita Orji iD, Maaz Amjad iD, Abubakar Siddique iD, Nailya Kubysheva iD, Ildar Batyrshin iD, Grigori Sidorov iD

JMIR Infodemiology · 2026

DOI: 10.2196/77783 ↗

At a glance

Journal article in JMIR Infodemiology, 2026. Written by Muhammad Ahmad and 6 co-authors. Institution: Instituto Politécnico Nacional, Centro de Investigación en Computación, Mexico City, Mexico. Major MEDLINE topics: Social Media, Opioid-Related Disorders. Cited 2 times so far (Crossref); 41 references. The full text is freely available in PubMed Central.

RezumatSubjectsDate bibliograficeCiteRelated studies

Abstract (original language)

Background

The illegal use of opioids has emerged as a major global public health concern, contributing to widespread addiction and a growing number of overdose-related deaths. In response, the US federal government has invested billions of dollars in combating the opioid epidemic through treatment, prevention, and law enforcement initiatives. Despite these efforts, there remains an urgent need for automated tools capable of detecting overdose cases and assessing the risk levels of substances—tools that can enable faster, more effective responses with less reliance on human intervention. Social media, particularly Reddit, has become a valuable source of self-reported data on opioid misuse, offering rich insights into user experiences and symptoms.

Objective

This research aimed to develop an advanced automated tool for detecting opioid overdose risks and classifying substances into high-risk and low-risk categories by analyzing social media posts.

Methods

A multistage methodology was used to achieve the objectives of this work. First, a new dataset was constructed from Reddit posts and manually annotated. Each post was labeled according to the risk level of the mentioned substance, using contextual indicators and user-reported experiences as the basis for classification. To ensure reliability and annotator consistency, detailed annotation guidelines were developed and applied throughout the labeling process. Second, a bidirectional encoder representation from transformers for biomedical text mining (BioBERT)–based classification framework was implemented and enhanced with a custom attention mechanism to capture relevant semantic information for more accurate predictions. Third, the model’s performance was evaluated using 5-fold cross-validation and compared against several baseline approaches, including traditional supervised learning, deep learning, and transfer learning methods. In total, 14 experiments were conducted to evaluate comparative effectiveness. To further assess the contribution of the attention layer, the best-performing model was also evaluated against a version incorporating the standard self-attention mechanism, using a train-test split. Finally, a paired t test was conducted to statistically assess the performance difference between the BioBERT-based model and the strongest baseline, extreme gradient boosting (XGBoost), providing validation of the observed improvements.

Results

The proposed BioBERT model with custom attention achieved an F1-score of 0.99 in cross-validation, outperforming the best baseline, XGBoost (F1-score=0.97), with a relative improvement of 2.06%. A paired t test conducted across the 5 folds (n=5) confirmed that the performance gain was statistically significant (P=.003), providing strong evidence that the improvement reflects genuine advances in overdose risk detection.

Conclusions

This paper demonstrates the potential of leveraging social media data and advanced natural language processing models to build reliable systems for opioid overdose risk detection. The BioBERT model with custom attention shows state-of-the-art performance and robustness, offering a powerful tool to support timely intervention and harm reduction strategies in the ongoing opioid crisis.

Subjects

MeSH terms (MEDLINE)

Social MediaOpioid-Related DisordersHumansRisk AssessmentData MiningData Analytics

Author keywords

AIBERTRedditartificial intelligencechronic paindata miningdeep learningdrug abuseopioid overdosesocial mediatransformer

Authors and institutions

  • Instituto Politécnico Nacional, Centro de Investigación en Computación, Mexico City, Mexico.
  • Faculty of Computer Science, Dalhousie University, Halifax, NS, Canada.
  • Department of Computer Science, Texas Tech University, Lubbock, TX, United States.
  • School of Engineering, Computer and Mathematical Sciences, Auckland University of Technology, Auckland, New Zealand.
  • Kazan Federal University, Kazan, Russian Federation.

ORCID profiles: Muhammad Ahmad, Rita Orji, Maaz Amjad, Abubakar Siddique, Nailya Kubysheva, Ildar Batyrshin, Grigori Sidorov

Cite

APA

Ahmad, M., Orji, R., Amjad, M., Siddique, A., Kubysheva, N., Batyrshin, I., & Sidorov, G. (2026). Automated Risk Assessment of Opioid Use: Analysis Using Pre-Trained Transformers on Social Media Data. JMIR Infodemiology. https://doi.org/10.2196/77783

Vancouver

Ahmad M, Orji R, Amjad M, Siddique A, Kubysheva N, Batyrshin I, et al. Automated Risk Assessment of Opioid Use: Analysis Using Pre-Trained Transformers on Social Media Data. JMIR Infodemiology. 2026. doi:10.2196/77783

BibTeX
@article{Ahmad2026,
  author = {Ahmad, Muhammad and Orji, Rita and Amjad, Maaz and Siddique, Abubakar and Kubysheva, Nailya and Batyrshin, Ildar and Sidorov, Grigori},
  title = {Automated Risk Assessment of Opioid Use: Analysis Using Pre-Trained Transformers on Social Media Data},
  journal = {JMIR Infodemiology},
  year = {2026},
  doi = {10.2196/77783}
}
Start for free →