PsychAdapter: Adapting LLM Transformers to Reflect Traits, Personality and Mental Health
Artificial intelligence-based language generators are now a part of most people’s lives. However, by default, they tend to generate “average” language without reflecting the ways in which people differ. Here, we propose a lightweight modification to the standard language model transformer architecture —“PsychAdapter” — es empirically derived trait-language patterns to generate natural language for specified personality, demographic, and mental health characteristics (with or without prompting). We applied PsychAdapters to modify OpenAI’s GPT-2, Google’s Gemma, and Meta’s Llama 3 and found generated text to reflect the desired traits. For example, expert raters evaluated PsychAdapter’s generated text output and found it matched intended trait levels with 87.3% average accuracy for Big Five personalities, and 96.7% for depression and life satisfaction. PsychAdapter is a novel method to introduce psychological behavior patterns into language models at the foundation level, independent of prompting, by influencing every transformer layer. This approach can create chatbots with specific personality profiles, clinical training tools that mirror language associated with psychological conditionals, and machine translations that match an authors reading or education level without taking up LLM context windows. PsychAdapter also allows for the exploration psychological constructs through natural language expression, extending the natural language processing toolkit to study human psychology
PsychAdapter was initially trained to cover the Big Five personality traits (openness, conscientiousness, extraversion, agreeableness, and neuroticism) as well as mental health-related variables (depression and life satisfaction), while simultaneously being conditioned on demographics (e.g., age or gender). It generates text that reflects authors high or low in any of these variables, and any combination thereof. For example, it can produce text characteristic of extraverts, or that of a young person who is depressed. Like all generative language models, PsychAdapter can continue sentences after a prompting phrase, for instance, exemplifying how one with depression would complete “I hate it when” or “I like to” for high extroversion.
Building PsychAdapter Unlike in prior work, PsychAdapter modifies the transformer architecture using patterns of empirical personality-language association without relying on prompting. Figure 1a summarizes the architecture of PsychAdapter, which extends the state-of-the-art transformer-based generative language model to incorporate personality factors as input. PsychAdapter builds on work in AI for conditional language modeling2–4. However, instead of conditioning only on text, it enables input of continuous dimensional psychological traits, such as personality or mental health variables, and outputs natural language that reflects these characteristics. The input vector (represented as dark yellow in Figure 1) can be a single psychological score or any combination of scores. Detailed in materials and methods, our modified transformer architecture can also condition on an input list of psychological scores through a learned dimension expansion per transformer layer, enabling the psychological scores to influence the generative model at every layer. Just like standard generative language models, PsychAdapter is trained with the objective of best predicting the next word, but instead of just learning weights for the transformer itself, it also learns how to weigh the psychological scores’ contribution to each layer.
We trained and validated language models with PsychAdapter using a dataset of open-source social media and blog posts. PsychAdapter also utilizes an empirically-trained language-based based assessment model. This assessment model is used to assign an “estimated” psychological scores for each text sample in the text corpus of social media and blog posts. For personality, we used a language-based assessment mirrors the approach established in prior work11, 16, that estimates the Big Five personality scores for a given text document. After training, the PsychAdpater was queried to produce text conditioned on vectors of Big Five (Openness, Conscientiousness, Extraversion, Agreeableness, and Neuroticism) personality scores. To instruct the model to generate text distinguishing a particular psychological attribute, we set its psychological score to a high value (+k×σi) and the other dimensions to their mean value (μj, with i ̸= j). For example, if we want generated text to reflect to extraversion, which is the third dimension of the input Big Five vector, we would feed the following vector into the model: (μO,μC,μE +k.σE,μA,μN), with k being any value from the range [−3,3] – akin to a 7-point Likert scale used in psychological surveys. We designed PsychAdapter to work with normalized trait scores (μi = 0,σi = 1), hence, we would use (0,0,+k,0,0) as input for the previous example. We have full simultaneous control over all dimensions; the model can be set to produce text corresponding to a combination of different scores by adjusting the input Big Five vector, such as placing a high value on one dimension and a low value on another. For example, the input (O,C,E,A,N) = (+3,0,−3,0,0) will generate text having both high openness and low extraversion while being average in the other three dimensions.
Once trained, thanks to the small size of PsychAdapters, with total added parameters less than 0.1% of original base language models across tested models (e.g. for Gemma 2B model, 55,296 parameters added compared to 2 billions parameters of base model), they can be easily distributed to be used with the base model. These lightweight “adapters” (each adapter corresponds to a different set of psychological or demographic variables) equip the base language models with the capability to generate text with fine-grained control of underlying psychological profiles. This benefit of PsychAdapters is similar to the benefits of Parameter-Efficient Fine-Tuning (PEFT)29 methods, which enable language models with fine-tuning capabilities by adding few parameters to the base model.
Equipping AI transformers with demographics and psychological traits offers a range of applications. For example, it could create chatbots with a diversity of personalities that is more human-like. Customer service staff could be trained with these systems mimicing customers with different personalities and emotional states. New crisis line workers and mental health responders could be trained, without risk to patients, using simulated conversation partners expressing different levels of depression and personality characteristics to better pick up on linguistic indications of distress without high-risk patient interactions.
Transformer-based text generation models are built into many modern applications, and thus our proposed modifications could also propagate to improving their standard applications such as machine translation or personalized assistants. For example, answers could be generated based on matching different education, dialectic, or age levels to be more accessible to different audiences. PsychAdapter presents a new degrees of freedom to enable more human-centered language generation. For researchers, PsychAdapter can be see as a new type of differential language analysis11–14 that empirically elicits the words, phrases, or topics that distinguish psychological constructs through language usage. Our work extends this direction by, front characteristic coherent sentences of traits rather than discrete words or phrases that are more ambiguous. Our new approach provides much more context for interpretation and higher-quality synthetic data for further use.
Our work builds upon prior research 11, 12, 15–18 employing natural language processing and big data analytics to investigate the connections between personality traits, mental health, and human language through regression frameworks to identify distinguishing phrases and topics. However, our approach advances this line of work by generating fully formed text that captures rich contextual information, rather than producing abstract, decontextualized data displays of words, phrases or topics associated with psychological dimensions. Our work also aligns with previous studies in the area of text generation