1. Introduction
Suicide is one of the most critical and preventable causes of premature mortality worldwide. Suicide is also the 4th leading cause of death in the age range of 15–29 years (the most at-risk group for mental illness and social isolation) worldwide. Approximately 700,000 people die by suicide every year according to the World Health Organization [
1]. Millions more suffer from chronic suicidal thoughts, create plans for committing suicide, or attempt non-fatal suicide, the vast majority of whom are unknown to mental health professionals, do not receive support from family and friends, and have no community resources to help them. The hidden nature of most of the burden associated with suicide is particularly worrisome because non-fatal suicide attempts are strong predictors of later completion of suicide. The absence of identification and support for a large number of non-fatal suicide attempters represents not only a missed opportunity for clinical intervention but also a serious threat to the overall public health system.
This gap in detection has an extensive impact because untreated suicidal crises usually worsen over time, and the absence of appropriate responses increases the physiological impact of the untreated individual, which corresponds to the probability of completion of suicide. The significant progress made by mental health advocates, public health organizations, and governments to increase general awareness of mental illness and provide access to evidence-based treatment options has left early and accurate identification of people at real and imminent risk of suicide as one of the most challenging, complex, and consequential issues facing researchers, clinicians, and policymakers worldwide.
One reason is that it is difficult to identify suicidal thoughts and feelings because people often attempt to hide them. Instead, they show signs of suicidal thoughts and feelings through many different types of behavior and language, which do not appear when people are evaluated using traditional clinical assessment methods. Thus, there is an urgent need for scalable, automated, and intelligent detection systems that can proactively identify individuals at risk of suicide. These detection systems must function effectively in different linguistic and cultural contexts and complement existing clinical assessment systems that are ethical and based on valid scientific research.
The growing number of social networking sites has changed how people share their emotions. Platforms such as Reddit, Twitter, and Facebook represent new ways for people to tell others about their emotional distress due to being alone, depressed, or having thoughts of self-harm before receiving treatment or talking to a friend or family member about these feelings [
2]. This body of information on the Internet provides an opportunity to develop automated, large-scale systems to identify issues with suicidal behavior by analyzing text for early warning signs.
Natural language processing (NLP) and machine learning have shown great potential for analyzing text related to mental health on social media [
3]. In the past, computational approaches to analyzing this type of content used lexicon-based models, handcrafted features, and classical classifiers (e.g., logistic regression and support vector machines) to produce benchmark results. However, they were not able to effectively capture complex linguistic patterns, context dependencies, and the subtle semantic nuances associated with suicidal communication [
4].
The introduction of deep learning architectures, especially recurrent neural networks such as Long Short-Term Memory (LSTM) [
5] and Convolutional Neural Networks (CNN), has resulted in significantly improved performance in text classification. Furthermore, deep learning models can learn hierarchical representations of language/text without extensive feature engineering. However, they are still limited by their use of fixed context windows and their inability to capture long-range dependencies in text, both of which are vital for understanding subtle expressions of psychological distress [
6].
The introduction of transformer-based models has completely overhauled the field of natural language processing. The introduction features work from Vaswani et al. [
7], which provided the foundation for BERT [
8] and RoBERTa [
9], two sets of models that were trained using large amounts of data to achieve state-of-the-art performance on many different benchmarks for language understanding after fine-tuning them for specific tasks. These models have shown themselves to be capable of identifying contextual semantics, which makes these types of models extremely well-suited for conducting more sensitive types of classification work, such as predicting the likelihood of suicide [
10].
The major shortcoming of transformer-based models is their lack of interpretability. A model that only predicts the risk without describing how it arrived at that conclusion is insufficient and could cause harm in clinical applications with high stakes. To provide a sufficient level of transparency to mental health professionals, the models must provide explainable predictions that indicate the specific external traits/patterns present in the input data that led to a specific overall risk classification [
11]. The mandate to provide an explanation is more than an academic requirement [
12]; it is a requirement to enable clinicians to fully trust the prediction, to provide for the ethical use of, and to allow for meaningful collaboration between mental health clinicians and artificial intelligence when working together.
The issue that has been identified here is the absence of an explainable model that combines the strengths of existing deep learning models, such as DistilBERT [
13], and some form of interpretability module. To address this gap, we developed a new method called CrisisFormer, which includes an explanation layer built on top of DistilBERT (which retains 97% of the original BERT’s language understanding capabilities) to provide real-time predictions of suicide risk using social media data.
In this study, we present an explainable hybrid predictive model called “CrisisFormer,” which utilizes three current interpretability techniques (SHAP, LIME, and Attention Visualization) for predicting suicide risk based on social media text. In addition, we tested its effectiveness with the Suicide Watch dataset from Reddit, showed that it performed better than multiple baseline models, and provided a detailed exploration of how CrisisFormer’s predictions correlate with the clinical evidence of suicidal behavior (using various linguistic features linked to suicide risk). The full implementation of the model can be requested from the corresponding author, in adherence to open science principles.
The remainder of this paper is organized as follows:
Section 2 provides an overview of related research;
Section 3 describes the dataset, including how we preprocessed it;
Section 4 discusses the proposed CrisisFormer approach;
Section 5 provides experimental results;
Section 6 provides analyses of the results and limitations; Finally,
Section 7 concludes our findings.
2. Related Works
Lexicon-based and classical statistical approaches defined the early evolution of computational methods for suicide risk detection, prior to the widespread adoption of machine learning and deep learning techniques. The use of lexicon-based approaches prior to machine learning was characterized by “manual” feature engineering and the creation of features for the training of a model through the creation of a feature set. Most early studies relied on manual definitions of both linguistic markers and how features were defined, thereby requiring a level of human interpretation to turn raw data (text) into structured data. For instance, the models developed by Coppersmith et al. [
2] used predefined linguistic markers including word counts, parts of speech, and psychological content categories to classify suicidal posts on Twitter, involved using a predefined set of linguistic markers such as a number of words, parts of speech, and/or type of psychological content to create features necessary for classification of electronically detected suicidal individuals’ posts on Twitter (demonstrating the feasibility of conducting mental health and suicide-based surveillance through social media).
Using an approach similar to Coppersmith et al.’s [
2], Burnap et al. used machine learning algorithms to classify electronically detected suicidal individuals’ posts [
14] and achieved significant performance using both n-grams (i.e., consecutive sequences of n words) and sentiment scores. While both studies provide significant baseline data and proof of feasibility, they share one limitation: both studies relied on manual feature engineering and, as such, cannot be generalized across different samples and/or contexts. (Collectively) both studies lacked the ability to express the multitude of complex, nuanced, linguistic elements present in all human communications regarding mental health and/or suicidality.
Deep learning has subsequently created a major shift toward resolving the limitations of traditional methods; however, it has also introduced new obstacles. Tadesse et al. [
4] demonstrated much better results using LSTM networks and CNNs to identify suicidal thoughts on Reddit than previous approaches, in that LSTMs automatically learn features from the text (instead of relying on previous feature sets) and do so from the context of the entire post. Yates et al. [
15] showed that these neural network approaches lead to better classification of mental health than previous approaches; however, they also established that the systems were not able to provide clinicians with reliable/meaningful and interpretable data. The LSTM complex model was developed by Hochreiter and Schmidhuber [
5] when they were trying to develop a model for sequential data. LSTMs were developed for the specific purpose of being able to model the sequential flow of language. Despite the performance gains achieved with deep learning, there are two major weaknesses. First, deep learning models generally lack the ability to deal with longer continuous contexts throughout the entire document (i.e., long-term dependencies). Second, the reason deep learning systems are unable to provide reliable information/data to clinicians is because of their non-LTSM structures and opaque computations, which are very difficult to interpret, leading to a major “black” box problem.
The introduction of the transformer model by Vaswani et al. [
7] introduced a paradigm shift in the field, and subsequent developments, such as pretrained models BERT [
8], resulted in marked differences between recurrent neural networks and transformer-based models through the utilization of self-attention mechanisms within transformer architectures. Self-attention mechanisms promote a model’s ability to consider all aspects of an input sentence at once, allowing it to determine which individual token/word in the input sentence is relevant for producing the model’s output, regardless of the proximity of the tokens to each other. Consequently, models built on transformer architecture can incorporate much richer representations of the contextual dependencies contained within the input data.
The efficacy of the self-attention mechanism within transformer architectures for predictive modeling was demonstrated by Matero et al. [
10], who observed that BERT-type models produced superior predictions of suicide risk based on both clinical and social media text compared to traditional deep learning and conventional predictive model techniques. The field has also evolved rapidly owing to the development of advanced versions of the pre-training process, such as RoBERTa [
9] and DistilBERT [
13], which produced state-of-the-art performance on many benchmarking datasets while making the pre-trained models smaller and sufficiently efficient to be used on resource-limited production deployments with minimal performance degradation.
While these performance improvements were substantial, the interpretability of these exceptionally well-performing transformer models remains a critical barrier to clinical use. This has resulted in the rise of Explainable AI (XAI) in mental health natural language processing. The introduction of foundational techniques such as SHAP [
11] and LIME [
16] addressed the need to understand model behavior through a shared framework of interpretability. SHAP uses game-theoretic Shapley values to produce a theoretically grounded and unified representation of the importance of features, whereas LIME, which employs local explanations, approximates how predictions made by a complex model behave in proximity to a particular prediction.
Individuals in this area of study have begun utilizing these approaches in mental health; for example, Aladağ et al. [
6] applied neural networks with limited interpretability methods to detect suicide ideation. In addition to these methodological advancements, datasets such as the Dreaddit dataset [
17] have served to strengthen the empirical base of our knowledge while also providing resources unique to the analysis of stress. Consequently, as evidence accumulating in the area of clinical practice supports the growing demand for interpretable models, authors such as Ji et al. [
3] have recognized this need as urgent and specifically noted that transparency in models must be present before they are used in the real world as presented in
Table 1.
According to several recent studies, deep learning and transformer-based methods for detecting suicidal risk have improved rapidly in the last few years. In addition, De Oliveira et al. [
18] utilized explainable machine learning to identify mental health in communication platforms (e.g., social media), demonstrating how interpretability methods can clarify language features used by machine-learning models to predict outcomes. Heckler et al. [
19] undertook a systematic review to provide an overview of machine-learning methodologies for identifying suicidal thoughts, summarizing the literature through nearly 4000 studies and highlighting the increasingly important role of deep learning in this area in particular. These studies by De Oliveira et al. [
12], Levkovich and Omar [
20], and De Oliveira et al. [
21], together emphasize the growing agreement about the importance of interpretability, clinical relevance, for the responsible use of AI-based systems for suicide risk detection with a specific emphasis on the need for clearly interpretable, clinical-trusted models that will enable effective in-use clinical application in a real world mental health monitoring context.
6. Discussion
CrisisFormer has shown great success as a framework for identifying social media users at risk of suicide and will provide significant contributions to the research literature, with all evaluation metrics showing high accuracy and AUC scores. A review of the academic literature on suicide risk assessment using Reddit data has confirmed that natural language processing methods can reliably identify users exhibiting linguistic characteristics of crisis-level emotional states [
22], while CrisisFormer extends this line of investigation by combining computational efficiency with a multi-layered explainability architecture. Furthermore, unlike transformer models such as RoBERTa, which are much larger, CrisisFormer was created using a significantly lower number of model parameters without sacrificing prediction quality. Recent research into generalized autoregressive pretraining has similarly shown that optimized architectures can provide robust language understanding capabilities and improved accuracy on language understanding tasks with no deterioration in model performance as the model size increases or the architectures become more complicated [
23].
The AUC of 0.9944 is exceptionally high; however, due to the explicit crisis labelling inherent in the content of the Suicide Watch subreddit, caution is required when interpreting this figure. The more clearly defined class boundary present in the Suicide Watch subreddit, compared to the potentially less rigorously defined class boundaries that would likely exist in a more typical social media setting, may account for a higher AUC than is typically observed within the broader scope of social media data. Additionally, an analysis of baseline performance metrics based on static pre-trained word representations, such as GloVe [
24] and Word2Vec [
25], demonstrated that CrisisFormer’s contextual transformer-based encodings provide more richly semantically and syntactically informed embeddings than do static embedding approaches overall. Thus, these analyses further established confidence in the robustness of CrisisFormer’s design and provided a transparent evidence base for evaluating CrisisFormer’s relative contributions to the literature.
BERT-base has been found to have accuracy scores nearly matching those of CrisisFormer on the present dataset; however, the key differentiator of CrisisFormer is its explanation module, which is part of the development of the multilayer architecture of CrisisFormer and is not standard for BERT-base. In clinical and applied settings, the ability to produce interpretable, token-level explanations has much greater practical utility than marginal improvements in predictive accuracy alone. This was evidenced by the results of RISK FORMER [
26], which showed that for ethically responsible clinical deployment, the inclusion of explanation mechanisms in transformer-based suicide risk detection models is necessary. This supports the argument that the explanation of a model should be the basis of its selection in clinical situations, as opposed to solely the accuracy of the model, making CrisisFormer a more clinically viable solution than other models with no explanation provisions.
The most clinically significant finding of this study was the false-negative rate of 2.07% (62 out of 3000 instances) in relation to suicide risk assessment. The importance of minimizing false negatives cannot be understated, especially as an undetected case is an opportunity for intervention that may have saved someone’s life. Therefore, it is encouraging that the false-negative rate achieved by CrisisFormer was so low, further suggesting that the model may be an effective first-line screening tool for this purpose. CrisisFormer was built and trained using PyTorch version 1.9.0 [
27], which provided a strong, efficient, deep learning framework to fine-tune DistilBERT using large amounts of text data, supporting the reproducibility and scalability of the proposed model framework.
The integration of SHAP, LIME and Attention Visualization in CrisisFormer addresses a long-standing limitation regarding providing clinically relevant (i.e., meaningful within a clinical setting) explanations for the use of deep learning NLP models in mental health. Specifically, through systematic explanatory analysis, it was demonstrated that the predictions made by CrisisFormer were based on clinically relevant (i.e., important in a clinical context) linguistic attributes, as opposed to spurious statistical patterns. The repeated identification of specific linguistic terms that corresponded to emotional distress, hopelessness, and suicide risk for each of the high-risk classification categories was highly consistent (i.e., located in concordance) with the existing clinical knowledge of the linguistic indicators associated with suicide risk. The close proximity of computational outcomes to clinical understanding can be viewed as a major success of the proposed framework and signifies a broader shift in the computational linguistics community towards developing auditable and interpretable classification systems [
28], which is critically important in high-consequence domains such as mental health.
Clinicians’ ability to interrogate model explanations increases the transparency of models and supports institutional trust, while also providing an additional basis for making more informed clinical decisions. Recent empirical research has verified the effectiveness of incorporating interpretability mechanisms into transformer-based classification frameworks in multilingual text summarization [
29] and computational detection of extremism [
30], where interpretability has been identified as an essential facilitator for the responsible deployment of models in the real world. In addition, the ability to access auditable model predictions allows mental health professionals to conduct systematic assessments of model behavior across various demographic subgroups and different types of linguistic registers, providing a structured, principled, and transparent method of ongoing ethical oversight and accountability for the models deployed in the field.
The inferences drawn from the current investigation have limitations defined by its boundaries, which also provide a clear direction for subsequent investigations, since the training corpus generated from Reddit’s communication style may not accurately depict how varied forms of suicide are communicated among various social media and cultural/language differences. The literature [
31] has found that language processing using transformer networks can be produced more generally across different platforms; hence, extending the application of the CrisisFormer framework to larger populations may require the parallel extension of the models produced in this study to accommodate greater numbers of populations. The binary classification methodology used in this study, while appropriate for the goals of this project, fails to replicate degrees of severity as assessed by clinically validated scales, thus providing an opportunity for the development of multi-class or severity-stratified variants of the framework as future research opportunities.
The method used in this study, a 50/50 balanced sampling approach, is traditionally used for binary classification tasks. Because of this imbalance, it would be beneficial for future evaluations to assess CrisisFormer on datasets that experience natural imbalances in crisis-related content and then report calibration measurements and traditional classification performance measurements. Recent applied research has shown the importance of robust validation frameworks for transformer-based models [
32] that need to be followed in future studies for their results to be generalizable and applicable in the real world.
The present investigation used only one stratified train/validation/test partition (70%/15%/15%), which is the accepted method for performing large-scale transformer fine-tuning, allowing k-fold cross-validations to be included as part of the study’s future work. Implementing k-fold cross-validations would provide statistically meaningful performance estimates and lower the variance across performance metrics in reporting, thus further enhancing the support that the CrisisFormer tool can be deployed in a clinical setting. The Suicide Watch Dataset [
33], which was the primary source of training and testing data in this study, provided a structured and domain-specific corpus for binary classification, while also providing a reproducible experimental baseline on which additional, more diverse dataset evaluations can be built in the future.
There is an exciting opportunity for the next wave of CrisisFormer to support a broader array of multicultural and multilingual citizens. Additional multimodal signals, such as temporal behavioral patterns and longitudinal user activity history, could increase the understanding of suicidal ideation detection through additional accuracy and contextual sensitivity. Collaborating with mental health care providers and conducting rigorous prospective clinical validation studies will serve as essential building blocks for the responsible and ethical use of CrisisFormer in clinical and public health settings, ultimately leading to better outcomes for people in crisis.