The American Psychiatric Association (APA) has updated its Privacy Policy and Terms of Use, including with new information specifically addressed to individuals in the European Economic Area. As described in the Privacy Policy and Terms of Use, this website utilizes cookies, including for the purpose of offering an optimal online experience and services tailored to your preferences.

Please read the entire Privacy Policy and Terms of Use. By closing this message, browsing this website, continuing the navigation, or otherwise continuing to use the APA's websites, you confirm that you understand and accept the terms of the Privacy Policy and Terms of Use, including the utilization of cookies.

×
Published Online:https://doi.org/10.1176/appi.ps.202100692

Abstract

Objective:

The authors tested whether natural language processing (NLP) methods can detect and classify cognitive distortions in text messages between clinicians and people with serious mental illness as effectively as clinically trained human raters.

Methods:

Text messages (N=7,354) were collected from 39 clients in a randomized controlled trial of a 12-week texting intervention. Clinical annotators labeled messages for common cognitive distortions: mental filtering, jumping to conclusions, catastrophizing, “should” statements, and overgeneralizing. Multiple NLP classification methods were applied to the same messages, and performance was compared.

Results:

A tuned model that used bidirectional encoder representations from transformers (F1=0.62) achieved performance comparable to that of clinical raters in classifying texts with any distortion (F1=0.63) and superior to that of other models.

Conclusions:

NLP methods can be used to effectively detect and classify cognitive distortions in text exchanges, and they have the potential to inform scalable automated tools for clinical support during message-based care for people with serious mental illness.

HIGHLIGHTS

  • This is the first study to apply natural language processing to text messages between people with serious mental illness and their clinicians, with the goal of identifying cognitive distortions.

  • Findings indicate that a fine-tuned model that used bidirectional encoder representations from transformers achieved performance comparable to that of clinically trained human raters on the task of cognitive distortion identification.

  • Results from this study can inform automated tools for clinical support during message-based care for people with serious mental illness.

Mobile phone texting is gaining popularity as a promising method for delivering health care outside brick-and-mortar clinics (1). Texting may be particularly well suited for psychosocial interventions, in which language is the primary vehicle for administering treatment. Texting interventions have been deployed successfully among clients with a range of mental health conditions, including serious mental illness (2). People with serious mental illness in the United States have access to text-capable mobile phones at a level only slightly lower than that of the general population; in addition, surveys suggest that most people with serious mental illness actively use text messaging and are interested in text-based interventions (3). Recent research has demonstrated that augmentation of routine services with texting is feasible, acceptable, and clinically useful among people with serious mental illness (4).

Although technology-mediated services are feasible, a lack of training and clinician expertise presents a barrier to their adoption for treatment of serious mental illness in community settings (5). Opportunities for training in technology-based services are limited, and providers adopting these technologies commonly express a need for increased support (6). When available, training and supervision in the use of novel interventions are resource intensive and may preclude adoption of texting interventions (7). New methods to monitor and support clinicians who offer services via texting are needed to encourage consistent intervention delivery, reduce human resource requirements, and allow more patients to receive care via this modality.

Natural language processing (NLP) is the computational analysis of human language and may augment delivery of text-based care. NLP has shown promise for identifying cognitive distortions expressed by individuals receiving support for mood disorders (8, 9). Cognitive distortions are systematic errors in thinking that affect how individuals make sense of the world (10). Among people with serious mental illness, distortions exacerbate negative effects of psychiatric symptoms (11, 12). To identify and restructure these distortions is an important goal of cognitive-behavioral therapy (CBT). Access to and engagement in high-fidelity CBT interventions that ameliorate distortions are limited for individuals with serious mental illness (13). Training clinicians to provide high-quality CBT via text messaging can help alleviate this issue and successfully augment in-clinic services (2, 4). Automated methods for proactively flagging distortions in text-based interactions may assist clinicians who provide CBT in reducing distortion-related psychiatric symptoms.

We are not aware of previous work that has applied NLP methods to text-based interactions between clinicians and clients receiving treatment for serious mental illness. However, prior work that used machine learning methods to identify distortions in data from other populations informed our study. Shickel et al. (8) identified cognitive distortions in journal entries from college students with a self-guided online intervention and in crowdsourced samples from participants who were prompted to provide examples of distortions. Shreevastav and Foltz (9) explored identification of cognitive distortions in publicly available therapist question-and-answer transcripts. Whether NLP can be applied to text-based client-clinician interactions and successfully detect cognitive distortions is an open research question.

The purpose of this study was to test whether NLP techniques can automatically identify distortions in text-message exchanges between clients with serious mental illness and their therapists at a similar level to that of trained clinicians. We hypothesized that a fine-tuned NLP classifier would be able to identify distortions with a level of precision and recall, operationalized as an F1 score (range=0–1, where higher scores indicate better precision and recall), that is comparable to that of trained clinician annotators.

Methods

Data were collected from 39 clients enrolled in the active intervention arm of a randomized controlled trial between December 2017 and October 2019. Seven clinicians from mental health agencies in the Midwest and Pacific Northwest provided the texting intervention. Clients who contributed data to the current analysis had diagnoses of schizophrenia, schizoaffective disorder, major depressive disorder, or bipolar disorder. Most were male (N=22, 56%), with a mean±SD age of 45.4±11.1 years, a mean of 12.8±2.4 years of education, and a mean of 2.8±3.4 lifetime psychiatric hospitalizations. A full description of the trial, including intervention feasibility, acceptability, engagement, and clinical outcomes, was recently published in Psychiatric Services (4). The study was approved by the University of Washington’s Institutional Review Board, and clients provided informed consent. As part of the study, clients participating in standard care engaged with trained clinicians in back-and-forth text-message conversations for 12 weeks. In total, 14,312 messages were sent, with 7,354 coming from clients (mean±SD=188.6±226.4 messages per client). Clients had variable levels of engagement, with the average number of client messages ranging from 0.3 to 12.5 messages per day. All data were stored on a secure server, and client and clinician identifiers were removed before annotation and analysis.

We created a data set of text messages annotated for five common cognitive distortion types: mental filtering, jumping to conclusions, catastrophizing, should statements, and overgeneralizing (14). To do this, we selected distortion types noted to play a role in psychosis (e.g., jumping to conclusions) and those used in previous automated classification studies (8, 9, 11). Next, we developed an annotation guide that provides definitions and examples of these distortions to facilitate labeling of text messages by two clinically trained annotators (15). One annotator holds a psychology master’s degree (A.C.), and the other is a doctoral-level licensed clinical mental health counselor (J.S.T.). The annotators labeled client text messages as representing any of the five distortion types or as no distortion (see the online supplement to this report for definitions and examples). Multiple labels were assigned to messages when more than one distortion type was present. Annotators were trained to use the annotation guide and practiced coding transcripts that contained all messages from three randomly selected clients. Interrater discrepancies were discussed, code definitions were refined, and agreement was reached about how to apply codes. Annotators then coded messages from a sample of 23% (N=9) of clients (2,318 messages) and reached a moderate level of agreement (Cohen’s κ=0.51), a level comparable with previous work that used human annotation of cognitive distortion (8). All remaining transcripts were then equally divided between annotators for coding.

We created three NLP distortion classification models for comparison with human rater performance. he first model used bidirectional encoder representations from transformers (BERT) (16). BERT allows for pretraining on large quantities of unlabeled text and fine-tuning model parameters to specific classification tasks. BERT fine-tuning is an effective transfer learning strategy that has achieved state-of-the-art performance in many classification tasks and domains (17). Because BERT has not been previously used for identifying cognitive distortions, we also included the two best-performing models from prior cognitive distortion work with which to compare our BERT model: logistic regression with term frequency–inverse document frequency features (LR) and support vector machines with input features generated by sentence-BERT without fine-tuning (SVM) (8, 9). Using the NLP models, we classified the five cognitive distortions and an “any distortion” label, indicating whether one or more of the five cognitive distortions were present, as a multilabel binary classification task.

Models were evaluated with a nested cross-validation procedure (18). We randomly split the annotated data set into five folds (1, 2, . . . 5). These folds were used to split data into train (Dtrain), validation (Dval), and test (Dtest) sets. There was no overlap between the messages in the train and test sets; however, a given client could appear in both the training and test sets. We tuned hyperparameters by using Dtrain, and we evaluated Dval by using splits of the data. After hyperparameters were tuned, final model performance was assessed by combining Dtrain and Dval splits to train a final model to evaluate performance on the previously unused Dtest split. As a form of repeated holdout testing, we iterated over folds assigned to Dtrain, Dval, and Dtest, retuning the hyperparameters for each iteration. For example, fold assignments for iteration 1 were Dtrain={1, 2, 3}, Dval={4}, Dtest={5}; fold assignments for iteration 2 were Dtrain={2, 3, 4}, Dval={5}, Dtest={1}; and fold assignments for iteration 5 were Dtrain={5, 1, 2}, Dval={3}, Dtest={4}. We assessed performance of aggregated Dtest predictions with F1 scores and receiver operating characteristic (ROC) area under the curve (AUC) values. Hyperparameters were optimized to maximize average F1 (macro F1) score across the six binary targets. The F1 score is a standard performance metric in NLP evaluation, and it is calculated by combining precision and recall into a mean score. The selected model configurations are summarized in the online supplement.

We used the Shapley additive explanations (SHAP) package to identify portions of client messages that most influenced classification decisions and to demonstrate the interpretability of the BERT model (19). The online supplement provides examples of SHAP plots for each cognitive distortion type, in which each word is evaluated for its impact on the model output.

Results

Frequencies of distortions identified by human annotators and by the NLP models are presented in Table 1. The mean distortion frequency (any distortion type) per client was 48.5±106.1. Table 1 presents clinical rater and NLP model performances for identifying cognitive distortions. BERT outperformed LR and SVM for all distortion labels. The performance of BERT was comparable to that of clinical raters for any distortion, mental filtering, jumping to conclusions, and catastrophizing, indicating that the BERT framework (with pretraining) is a good fit for this task. BERT performed less well, relative to clinical raters, when identifying should statements and overgeneralizing. Our fine-tuned BERT model achieved an AUC of 0.83 (see online supplement for ROC curve) for the any distortion label.

TABLE 1. Frequencies of distortions identified by human annotators and by the NLP models, with interannotator agreement and model prediction performancea

Human performanceNLP performanceb
DistortionNF1 agreementNLRSVMcBERTd
Any614.631,793.56.45.62
Catastrophizing268.521,092.44.38.49
Mental filtering259.39632.34.30.38
Jumping to conclusions184.56594.37.38.50
Overgeneralizing113.48263.24.29.37
Should statements71.41192.16.08.20

aNLP, natural language processing; LR, logistic regression with term frequency–inverse document frequency features; SVM, support vector machines with input features generated by sentence-BERT without fine-tuning; BERT, bidirectional encoder representations from transformers.

bNLP performance for LR, SVM, and BERT represents the average F1 score, a weighted average of precision and recall. The F1 score has a range of 0 to 1, where higher scores represent better precision and recall.

cBERT was not fine-tuned to the cognitive distortion task.

dBERT was fine-tuned to the cognitive distortion task.

TABLE 1. Frequencies of distortions identified by human annotators and by the NLP models, with interannotator agreement and model prediction performancea

Enlarge table

Discussion

This study demonstrated that NLP models can identify cognitive distortions in text messages between people with serious mental illness and clinicians at a level comparable to that of clinically trained raters. Our BERT implementation outperformed previously published NLP methods for detecting cognitive distortions in text. BERT’s performance in this task is attributable to the transfer learning paradigm, in which a rich representation of language is learned from unlabeled text (pretraining) and then adapted to the target task (fine-tuning). Our work extends previous research on detection of cognitive distortions by confirming that detecting distortions in text messages during text-based care for people with serious mental illness is possible.

A key strength of this study is that data came from real-world communications between clients and clinicians that focused on management of symptoms of serious mental illness. There were no prompts to elicit distortions in these interactions, which allowed our classification model to be trained on the natural language used by clients as they typically communicate. This study is limited by size (number of clients, therapists, and messages). Although the study’s BERT model was able to demonstrate strong binary classification of the any distortion label and the most commonly occurring distortions, all NLP models were not as successful in identifying distortion types with fewer instances in the data set. Similar to prior cognitive distortion work, classification performance was limited by the challenge of manually annotating distortions (8).

Additional work with an expanded data set is needed to assess generalizability to a diverse client population, including clients not represented in the training data and clients engaged in other text-based messaging interventions. Incorporating previously sent messages may also prove beneficial to model performance by ensuring that predictions are grounded in the context of entire conversations.

Conclusions

Recent advancements in mobile phone–based mental health interventions, combined with advancements in computational methods of language analysis, have created new possibilities for developing technology-assisted interventions. NLP-based methods from this study show promise for supporting clinicians in future delivery of text-message interventions for people with serious mental illness. By applying NLP classification methodologies to clinical text-message interactions, it may be possible to proactively prompt clinicians’ actions, enhancing their ability to deliver effective, timely interventions.

Behavioral Research in Technology and Engineering Center, Department of Psychiatry and Behavioral Sciences (Tauscher, Chander, Cohen, Ben-Zeev), and Department of Biomedical Informatics and Medical Education (Lybarger, Ding, Cohen), University of Washington, Seattle; Department of Psychological and Brain Sciences, Dartmouth College, Hanover, New Hampshire (Hudenko).
Send correspondence to Dr. Ben-Zeev ().

This work was supported by an innovation grant from the Garvey Institute for Brain Health Solutions at the University of Washington Medicine, by NIMH grant R56-MH-109554, and in part by the NIH’s National Library of Medicine Biomedical and Health Informatics training program at the University of Washington (grant T15-LM-007442). These views represent the opinions of the authors and not necessarily those of the NIH.

Dr. Hudenko is an employee and shareholder of K Health Inc. He is also a shareholder of BrainBox Inc., Mentorworks Inc., and Voi Inc. Dr. Ben-Zeev has an intervention content licensing agreement with Pear Therapeutics and has financial interests in CORE technology, FOCUS technology, and Merlin LLC. He has also consulted for Boehringer-Ingelheim, Deep Valley Labs, eQuility, K Health Inc., Otsuka Pharmaceuticals Ltd., and Trusst Health Inc. The other authors report no financial relationships with commercial interests.

References

1. Herzog K: Mental Health Apps Draw Wave of New Users as Experts Call for More Oversight. Englewood Cliffs, NJ, CNBC, 2020. https://www.cnbc.com/2020/05/24/mental-health-apps-draw-wave-of-users-as-experts-call-for-oversight.html. Accessed Oct 15, 2021Google Scholar

2. D’Arcey J, Collaton J, Kozloff N, et al.: The use of text messaging to improve clinical engagement for individuals with psychosis: systematic review. JMIR Ment Health 2020; 7:e16993Crossref, MedlineGoogle Scholar

3. Young AS, Cohen AN, Niv N, et al.: Mobile phone and smartphone use by people with serious mental illness. Psychiatr Serv 2020; 71:280–283LinkGoogle Scholar

4. Ben-Zeev D, Buck B, Meller S, et al.: Augmenting evidence-based care with a texting mobile interventionist: a pilot randomized controlled trial. Psychiatr Serv 2020; 71:1218–1224LinkGoogle Scholar

5. Perry K, Gold S, Shearer EM: Identifying and addressing mental health providers’ perceived barriers to clinical video telehealth utilization. J Clin Psychol 2020; 76:1125–1134Crossref, MedlineGoogle Scholar

6. Lattie EG, Nicholas J, Knapp AA, et al.: Opportunities for and tensions surrounding the use of technology-enabled mental health services in community mental health care. Adm Policy Ment Health 2020; 47:138–149Crossref, MedlineGoogle Scholar

7. Moyers TB, Martin T, Manuel JK, et al.: Assessing competence in the use of motivational interviewing. J Subst Abuse Treat 2005; 28:19–26Crossref, MedlineGoogle Scholar

8. Shickel B, Siegel S, Heesacker M, et al.: Automatic detection and classification of cognitive distortions in mental health text; in 2020 IEEE 20th International Conference on Bioinformatics and Bioengineering, Cincinnati, Oct 26–28, 2020. IEEE, 2020, pp 275–280Google Scholar

9. Shreevastava S, Foltz P: Detecting cognitive distortions from patient-therapist interactions; in Proceedings of the Seventh Workshop on Computational Linguistics and Clinical Psychology: Improving Access. Association for Computational Linguistics, 2021, pp 151–158Google Scholar

10. Beck AT: Thinking and depression: idiosyncratic content and cognitive distortions. Arch Gen Psychiatry 1963; 9:324–333Crossref, MedlineGoogle Scholar

11. Dudley R, Taylor P, Wickham S, et al.: Psychosis, delusions and the “jumping to conclusions” reasoning bias: a systematic review and meta-analysis. Schizophr Bull 2016; 42:652–665Crossref, MedlineGoogle Scholar

12. Sauvé G, Lavigne KM, Pochiet G, et al.: Efficacy of psychological interventions targeting cognitive biases in schizophrenia: a systematic review and meta-analysis. Clin Psychol Rev 2020; 78:101854Crossref, MedlineGoogle Scholar

13. Mojtabai R, Fochtmann L, Chang SW, et al.: Unmet need for mental health care in schizophrenia: an overview of literature and new data from a first-admission study. Schizophr Bull 2009; 35:679–695Crossref, MedlineGoogle Scholar

14. Burns DB: Feeling Good: The New Mood Therapy, rev. ed. New York, Harper, 1999Google Scholar

15. Xia F, Yetisgen-Yildiz M: Clinical Corpus Annotation: Challenges and Strategies; in Proceedings of the Third Workshop on Building and Evaluating Resources for Biomedical Text Mining, Istanbul, May 26, 2012, European Language Resources Association, 2012, pp 32–39. http://faculty.washington.edu/fxia/mpapers/2012/lrec2012_biomed_workshop.pdf. Accessed Oct 15, 2021Google Scholar

16. Devlin J, Chang MW, Lee K, et al.: BERT: pre-training of deep bidirectional transformers for language understanding; in Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers). Minneapolis, June 2–7, 2019. Association for Computational Linguistics, 2019, pp 4171–4186Google Scholar

17. Minaee S, Kalchbrenner N, Cambria E, et al.: Deep Learning Based Text Classification: A Comprehensive Review [preprint]. Ithaca, NY, arXiv, 2020. https://arxiv.org/abs/2004.03705v3. Accessed Oct 15, 2021 Google Scholar

18. Varma S, Simon R: Bias in error estimation when using cross-validation for model selection. BMC Bioinformatics 2006; 7:91Crossref, MedlineGoogle Scholar

19. Lundberg SM, Lee SI: A unified approach to interpreting model predictions; in Proceedings of the 31st International Conference on Neural Information Processing Systems, Long Beach, CA, Dec 4–9, 2017. Curran Associates, 2017, pp 4768–4777Google Scholar