Official implementation of ICML 2024 paper, "PICLe: Eliciting Diverse Behaviors from Large Language Models with Persona In-Context Learning" by Hyeong Kyu Choi and Yixuan Li.
git clone https://github.com/imhgchoi/PICLe.git
cd PICLe
conda env create -f environment.yml
Download the needed LLM parameters from huggingface repos and place them in an accessible directory.
Run the following command to fine-tune the Llama-2 model. Specify the directory where you saved the downloaded LLM parameters, [YOUR_MODEL_DIR], and the directory you would want to save your learned SFT model parameters, [YOUR_OUTPUT_DIR]. Insert the persona type you would want to adapt to in [PERSONA] (e.g. --target_persona narcissism
). All persona types can be found here.
python src/main.py --mode persona_sft --target_persona [PERSONA] --model llama --exp_name persona_sft --output_dir [YOUR_OUTPUT_DIR] --model_dir [YOUR_MODEL_DIR] --num_epochs 4
To run this for all persona types, run
sh scripts/llama2/persona_sft.sh
Note, you need to modify the model and output directory arguments. This can be done similarly with other LLMs: llama2-large, vicuna, gptj.
To apply PICLe to a target [PERSONA], run
python src/main.py --mode picle --target_persona [PERSONA] --model llama --exp_name PICLe --likelihood_func diff --output_dir [YOUR_OUTPUT_DIR] --model_dir [YOUR_MODEL_DIR] --likelihood_use_epoch 4 --verbose
To run across all persona types, run
sh scripts/llama2/picle.sh
Again, the same applies to other LLMs: llama2-large, vicuna, gptj.
Run the shell files in the same manner. For instance, to run the similarity baseline on llama2,
sh scripts/llama2/similarity.sh
For the sampling pool refinement experiments, simply add --pos_label_sample_only
to the commands. Refer to scripts/llama2/picle_plus.sh
for an example.
If you find our code useful, please consider citing our paper:
@inproceedings{choi2024beyond,
title={PICLe: Eliciting Diverse Behaviors from Large Language Models with Persona In-Context Learning},
author={Hyeong Kyu Choi and Yixuan Li},
booktitle={International Conference on Machine Learning},
year={2024}
}