Psychological Assessments with Large Language Models: A Privacy-Focused and Cost-Effective Approach (2024)

Abstract: This study explores the use of Large Language Models (LLMs) to analyze text comments from Reddit users, aiming to achieve two primary objectives: firstly, to pinpoint critical excerpts that support a predefined psychological assessment of suicidal risk; and secondly, to summarize the material to substantiate the preassigned suicidal risk level. The work is circumscribed to the use of “open-source” LLMs that can be run locally, thereby enhancing data privacy. Furthermore, it prioritizes models with low computational requirements, making it accessible to both individuals and institutions operating on limited computing budgets. The implemented strategy only relies on a carefully crafted prompt and a grammar to guide the LLM’s text completion. Despite its simplicity, the evaluation metrics show outstanding results, making it a valuable privacy-focused and cost-effective approach. This work is part of the Computational Linguistics and Clinical Psychology (CLPsych) 2024 shared task.

## introduction large language models (llms) like gpt (generative pre-trained transformer; @xcite , llama (large language model meta ai; @xcite , mistral/mixtral @xcite , and others (based on the transformer architecture and its attention mechanism, made popular thanks to bert and derivatives; @xcite @xcite represent a significant advancement in the field of artificial intelligence, specifically within natural language processing (nlp). these models have transformed how machines understand, generate, and interact with human language, enabling a wide range of applications. during the "pre-training" phase, llms learn a wide range of language patterns and they encode knowledge from a vast corpora of text data. in a posterior phase, they can be "fine-tuned" on smaller/alternate datasets to become specialized on specific tasks such as psychological assessments. the fine-tuning can also be restricted to a smaller number of parameters using techniques such as lora @xcite or qlora @xcite for quantized models @xcite . however, fine-tuning can still be costly in terms of computational resources and time investment, requiring a high level of expertise. models with a higher number of parameters are more sophisticated, encode more accurate knowledge and are capable of performing more advanced tasks with optimal results. this reduces the need for fine-tuning, but it increases the requirements for computational resources. there is also the option of not running the models locally, but relying on external services such as openai's api and their chat-gpt interface foot_0 . regrettably, this approach may not be viable due to the involvement of third parties, which might not ensure adequate data protection or adhere to the stringent privacy standards and ethical codes mandated by healthcare and medical institutions, along with other legal obligations. given this context, in this study i explore the use of "open-source" llms that can be run locally in current commodity hardware (thus, 4-bit quantized models with a maximum 7 billion parameters), and i do not fine-tune these models to specialize in any specific task or to incorporate new knowledge relevant to the domain of clinical psychology. this evaluation is focused on the shared task proposed by the computational linguistics and clinical psychology (clpsych) 2024 workshop @xcite at the 18th conference of the european chapter of the association for computational linguistics (acl). ## task and data the clpsych 2024 shared task consisted on finding evidence within reddit comments that support a preassigned suicide risk level. the organizers provided access the university of maryland reddit suicidality dataset (umd version 2; @xcite , which includes posts to the "r/suicidewatch" subreddit plus crowdsourced and expert risk level assessments. the risk levels to be considered are low, moderate and high. the evidence supporting the preassigned risk level can take two different forms: 1) highlights (i.e., snippets) from the user's comments; 2) a summary that aggregates the evidence that justifies the assigned risk level. in this study, both forms of evidence were generated for a selection of 162 posts (by 125 users) that the organizers used to evaluate each submitted result. ## methods this study considered six different llms, which were selected based on their ranking on the open llm leaderboard foot_1 , and the lmsys chatbot arena leaderboard foot_2 as of january 15th (2024). the models were obtained from tom jobbins's huggingface repository foot_3 in ggufv2 format ("q4_k_m" quant method). the inference code was run locally using the nasa scix brain software @xcite on a macbook air with the apple m1 chip (released on november 2020) and 16gb of ram. the concrete models were: 1. openhermes 2.5 foot_4 , based on mistral 7b and further trained on mainly gpt-4 generated data, and other open datasets. 2. orca 2 (mitra et al., 2023), based on llama 2, designed to excel in reasoning, trained on a censored synthetic dataset. human preference alignment techniques such as reinforcement learning from human feedback (rlhf; ziegler et al., 2019) or direct preference optimization (dpo; rafailov et al., 2023) were not used. each model is requested to either extract evidences from user's comments as text highlights or to generate a comprehensive summary, both with the goal of justifying a preassigned suicidal risk level. the request is done with a crafted prompt that sets the scene (e.g., act as a psychologist specializing in suicidal ideation), and includes a fake interaction where the user has shared the reddit comment and a preassigned risk level, and the model (i.e., the assistant) has already provided an answer. this is a one-shot prompt from where the model can infer what we expect it to generate after a user request. subsequently, the real comment to be analyzed is included, and the model's response is left empty for it to be completed. my evaluation of various prompts was not exhaustive, but rather a manual and subjective process based on a limited set of examples. the tests (inspired by a previous work; @xcite suggested that a prompt in which a user outlines the entire task and includes an example generally yields slightly inferior results compared to a prompt that simulates an initial round of interaction between the user and the assistant, as if the assistant had already responded to a previous request. all the tested prompts directed the model to adopt the role of an expert and incorporated a description of what constitutes evidence for supporting a suicidal risk assessment, based on the assumption that the llm will rely more heavily on this provided information than on the knowledge it has gained through its training. the structure of the final prompt used for extracting text highlights can be found in appendix a. for this particular subtask, i use a formal grammar (feature included in llama.cpp foot_5 ) to constraint the possible tokens that can be sampled (i.e., discarding tokens that would break the rules defined by the grammar). the grammar is in gbnf format, which is an extension of bnf (backus-naur/normal form, a metasyntax notation for context-free grammars) that primarily adds a few modern regex-like features. the grammar imposes the generation of a list (surrounded by square brackets) of strings (surrounded by double quotes), and the string can only contain words present in the user's comment in their original order (see a concrete example in appendix b). regarding the summarization subtask, the structure of the used prompt can be found in appendix c. in this case, there is no imposed grammar, the model is free to complete the response but it is primed by providing already the first sentence, which states what the preassigned suicidal risk level is. for both subtasks, a top-p sampling (aka nucleus sampling; @xcite approach is followed (after the grammar constrains have been applied in the case of the highlights subtask), where only the top tokens will be considered (up to a cumulative score of 0.95), and a temperature of 0.7 to favor precision over creativity (low values makes top tokens more likely) and a repeat penalty of 1.1 is used to prevent loops. thanks to the workshop organizers, the generated text highlights and summaries that support the preassigned suicidal risk level were automatically evaluated against a test set annotated by domain experts (who manually generated gold highlights and summaries). the computed metrics to evaluate highlights are: it measures how relevant the highlights are as supporting evidence. regarding the evaluation of summaries, the computed metrics are: ## results the clpsych 2024 shared task only accepted three submissions per team, but the organizers were kind enough to evaluate additional submissions that are not considered for the workshop ranking. for the competition, i submitted the output from openhermes, orca 2, and starling. orca 2 was selected as it is the sole model based on llama 2, while the other two were chosen for their standings in the llm leaderboards. in the final official ranking, openhermes produced the best results. for highlights, based on recall and harmonic mean metrics, it ended in the modest 10th position (out of 15). however, if the weighted recall were considered instead, it would have ended in the 3rd position. this shows that openhermes' length of its generated highlights are closer to human-highlighted ones compared to other systems. regarding summaries, based on the consistency metrics, openhermes ended in an outstanding 2nd position (out of 14). if the organizer would have considered the contradiction metrics, then it would have fallen to a (still honorable) 3rd position. beyond the workshop competition, and in the interest of better assessing all the considered llms, the performance metrics for all the evaluated models can be found in it is also worth exploring the evaluation metrics split by the preassigned suicidal risk level (see finally, in terms of computation, the average inference time was of 40 minutes to extract highlights from 162 posts (∼14.8 seconds per post), and 30 minutes to generate summaries for 125 users (∼14.4 seconds per user). these are extremely competitive numbers for llms running on a consumer-grade machine. ## discussion the openhermes' generated highlights and summaries, when compared to other submitted systems to the clpsych 2024 shared task competition, ended up with remarkable comparative metrics for an approach that has used cost-effective "opensource" llms without any specific fine-tuning for these specific tasks. the highlights subtask seems to be the one with more margin of improvement, especially if we only consider the unweighted recall (where matching highlight lengths are not taken into account). it would have been interesting to make a manual human-based evaluation, comparing the generated highlights with the golden ones (which has not been released publicly), to better understand the discrepancy between the unweighted and weighted recall metrics (10th vs 3rd position in the final ranking, respectively) and justify selecting one over the other. in any case, these extraordinary results seem to signal the potential that this approach may have at other relatively similar tasks such as named entity recognition. regarding the generation of summaries, both evaluation metrics placed this approach in the top 3 ranking, a stunning result for a model that has not been trained specifically for psychological assessments. openhermes seems to be the best well-balance model and one of the best for summarization, but if we consider all the evaluated llms, dolphin and zephyr perform better in the highlights subtask. however, these results would likely change if other prompt templates were used. for instance, the crafted prompt includes only one example with a high suicidal risk level, and we observed that almost all models perform better for comments from high risk users. expanding the prompt to include more examples of different risk levels could potentially improve the overall performance. ## conclusion six different "open-source" large language models were evaluated to accomplish the shared task proposed by the clpsych 2024 workshop. this work demonstrated that following a relatively simple approach, mainly consisting on a well structured prompt with one single example, can be used with cost-effective llms to extract highlights and generate comprehensive and consistent summaries