GitHub - humanlab/psychadapter: PsychAdapter is a modular framework for steering LLMs to reflect specific Big Five personality traits and mental health states using parameter-efficient adapters. · GitHub
/" data-turbo-transient="true" />
Skip to content
Search or jump to...
Search code, repositories, users, issues, pull requests...
-->
Search
Clear
Search syntax tips
Provide feedback
--><br>We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
Saved searches
Use saved searches to filter your results more quickly
-->
Name
Query
To see all available qualifiers, see our documentation.
Cancel
Create saved search
Sign in
/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
humanlab
psychadapter
Public
Notifications<br>You must be signed in to change notification settings
Fork
Star<br>21
main
BranchesTags
Go to file
CodeOpen more actions menu
Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit
History<br>17 Commits<br>17 Commits
src
src
README.md
README.md
inference_command.sh
inference_command.sh
train_command.sh
train_command.sh
View all files
Repository files navigation
PsychAdapter: Adapting LLM Transformers to Reflect Traits, Personality and Mental Health
This is the source code repository for the paper "PsychAdapter: Adapting LLM Transformers to Reflect Traits, Personality and Mental Health".
This work proposes the architecture PsychAdapter - an transformer-based AI language model that is able to reflect individual characteristics in its text output. PsychAdapter is trained to be able to reflect any of the Big Five personality traits (openness, conscientiousness, extraversion, agreeableness, and neuroticism) as well as mental health variables (depression and life satisfaction), while optionally being conditioned on demographics (e.g., age).
This project was done in collaboration between PhD students, postdocs, and professors from Stony Brook University (Huy Vu, Swanie Juhng, Adithya Ganesan, Oscar N.E. Kjell, H. Andrew Schwartz), University of Texas at Dallas (Ryan L. Boyd), Stanford University (Johannes C. Eichstaedt), New York University (Joao Sedoc), University of Melbourne (Margaret L. Kern), University of Pennsylvania (Lyle Ungar). Corresponding authors: Huy Vu (hvu@cs.stonybrook.edu), Johannes C. Eichstaedt (johannes.stanford@gmail.com), H. Andrew Schwartz (has@cs.stonybrook.edu).
HuggingFace Resources
The model checkpoints and the full dataset are available on HuggingFace:
Model Checkpoints: https://huggingface.co/huvucode/PsychAdapter
Dataset: https://huggingface.co/datasets/huvucode/PsychAdapter
Installations requirements
Python: 3.10.0+.
pip install transformers=="4.18.0"
pip install peft=="0.10.0"
Instructions for training and generating text with PsychAdapter
Training
We train PsychAdapter using the following command format. The LLM base models can be set through argument --model_name_or_path. Run python3 ./train_psychadapter.py -h for more information. The code reads the data from ./processed_data directory then begins the training process. A directory ./trained_models will be created containing the trained model.
To obtain training and validating dataset (containing messages' text and their corresponding "estimated" construct scores, e.g. Big Five scores, depression, life-satisfaction scores) for research purpose, please contact Huy Vu at [hvu@cs.stonybrook.edu].
# Training Big Five personalities PsychAdapter<br>python ./codes/train_psychadapter.py \<br>--train_data_file ./data/big5_training_data.csv \<br>--eval_data_file ./data/big5_validating_data.csv \<br>--output_dir ./checkpoints/big5_model \<br>--model_name_or_path google/gemma-2b \<br>--latent_size 5 \<br>--do_lower_case \<br>--per_gpu_train_batch_size 32 \<br>--per_gpu_eval_batch_size 32 \<br>--gradient_accumulation_steps 2 \<br>--do_train \<br>--evaluate_during_training \<br>--learning_rate 5e-5 \<br>--num_train_epochs 5<br>--save_steps 1000 \<br>--logging_steps 100
Inferencing
After training, PsychAdapter can be used to generate text corresponding to all interested dimensions, using the following command. The code loops through all variables and generates text from the high and low value of each variable, controled by the std_range and generate_interval arguments. There are many configurations for the generating process that can be modifed (e.g., number of generated sentences, nucleous sampling parameters). Run python3 ./inference_psychadapter.py -h for more information.
# Inferencing Big Five personalities PsychAdapter<br>python ./codes/inference_psychadapter.py \<br>--train_data_file ./data/big5_training_data.csv \<br>--output_dir...