Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2025 Jun 19:5:e70525.
doi: 10.2196/70525.

Sentiment Analysis Using a Large Language Model-Based Approach to Detect Opioids Mixed With Other Substances Via Social Media: Method Development and Validation

Affiliations

Sentiment Analysis Using a Large Language Model-Based Approach to Detect Opioids Mixed With Other Substances Via Social Media: Method Development and Validation

Muhammad Ahmad et al. JMIR Infodemiology. .

Abstract

Background: The opioid crisis poses a significant health challenge in the United States, with increasing overdoses and death rates due to opioids mixed with other illicit substances. Various strategies have been developed by federal and local governments and health organizations to address this crisis. One of the most significant objectives is to understand the epidemic through better health surveillance, and machine learning techniques can support this by identifying opioid users at risk of overdose through the analysis of social media data, as many individuals may avoid direct testing but still share their experiences online.

Objective: In this study, we take advantage of recent developments in machine learning that allow for insights into patterns of opioid use and potential risk factors in a less invasive manner using self-reported information available on social platforms.

Methods: This study used YouTube comments posted between December 2020 and March 2024, in which individuals shared their self-reported experiences of opioid drugs mixed with other substances. We manually annotated our dataset into multiclass categories, capturing both the positive effects of opioid use, such as pain relief, euphoria, and relaxation, and negative experiences, including nausea, sadness, and respiratory depression, to provide a comprehensive understanding of the multifaceted impact of opioids. By analyzing this sentiment, we used 4 state-of-the-art machine learning models, 2 deep learning models, 3 transformer models, and 1 large language model (GPT-3.5 Turbo) to predict overdose risks to improve health care response and intervention strategies.

Results: Our proposed methodology (GPT-3.5 Turbo) was highly precise and accurate, helping to automatically identify sentiment based on the adverse effects of opioid drug combinations and high-risk drug use in YouTube comments. Our proposed methodology demonstrated the highest achievable F1-score of 0.95 and a 3.26% performance improvement over traditional machine learning models such as extreme gradient boosting, which demonstrated an F1-score of 0.92.

Conclusions: This study demonstrates the potential of leveraging machine learning and large language models, such as GPT-3.5 Turbo, to analyze public sentiment surrounding opioid use and its associated risks. By using YouTube comments as a rich source of self-reported data, the study provides valuable insights into both the positive and negative effects of opioids, particularly when mixed with other substances. The proposed methodology significantly outperformed traditional models, contributing to more accurate predictions of overdose risks and enhancing health care responses to the opioid crisis.

Keywords: BERT; ChatGPT; NLP; Reddit; bidirectional encoder representations from transformers; chronic pain; data mining; deep learning; high dose; large language models; natural language processing; opioid overdose; social media; suicide.

PubMed Disclaimer

Conflict of interest statement

Conflicts of Interest: None declared.

Figures

Figure 1.
Figure 1.. Architecture of proposed solution. DL: deep learning; LLM: large language model; ML: machine learning; TL: transfer learning.
Figure 2.
Figure 2.. ML-, DL-, and LLM-based model training pipeline for multiclass text classification. DL: deep learning; LLM: large language model; ML: machine learning; TL: transfer learning.
Figure 3.
Figure 3.. Confusion matrix of the proposed GPT-3.5 Turbo model.

Similar articles

References

    1. Jackson TP, Stabile VS, McQueen KAK. The global burden of chronic pain. ASA Monitor. 2014;78(6):24–27. doi: 10.1097/01.ASM.0001071728.63045.b4. doi. - DOI
    1. GBD 2017 Disease and Injury Incidence and Prevalence Collaborators Global, regional, and national incidence, prevalence, and years lived with disability for 354 diseases and injuries for 195 countries and territories, 1990-2017: a systematic analysis for the Global Burden of Disease Study 2017. Lancet. 2018 Nov 10;392(10159):1789–1858. doi: 10.1016/S0140-6736(18)32279-7. doi. Medline. - DOI - PMC - PubMed
    1. Zimmer Z, Fraser K, Grol-Prokopczyk H, Zajacova A. A global study of pain prevalence across 52 countries: examining the role of country-level contextual factors. Pain. 2022 Sep 1;163(9):1740–1750. doi: 10.1097/j.pain.0000000000002557. doi. Medline. - DOI - PMC - PubMed
    1. Mills SEE, Nicolson KP, Smith BH. Chronic pain: a review of its epidemiology and associated factors in population-based studies. Br J Anaesth. 2019 Aug;123(2):e273–e283. doi: 10.1016/j.bja.2019.03.023. doi. Medline. - DOI - PMC - PubMed
    1. Dahlhamer J, Lucas J, Zelaya C, et al. Prevalence of chronic pain and high-impact chronic pain among adults - United States, 2016. MMWR Morb Mortal Wkly Rep. 2018 Sep 14;67(36):1001–1006. doi: 10.15585/mmwr.mm6736a2. doi. Medline. - DOI - PMC - PubMed

MeSH terms

Substances

LinkOut - more resources