RepBelief
1.0.0
Ce référentiel fournit le code pour l'article "Les modèles de langage représentent les croyances de soi et des autres". Il montre que les LLM représentent en interne les croyances d'eux-mêmes et d'autres agents, et la manipulation de ces représentations peut avoir un impact significatif sur leurs capacités de raisonnement théorie de la théorie de l'esprit.
conda create -n lm python=3.8 anaconda
conda activate lm
# Please install PyTorch (<2.4) according to your CUDA version.
conda install pytorch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 pytorch-cuda=12.1 -c pytorch -c nvidia
pip install -r requirements.txt
Téléchargez ensuite les modèles linguistiques (par exemple Mistral-7B-Istruct-V0.2, Deepseek-llm-7b-chat) sur models/ . Vous pouvez également spécifier les chemins de fichier dans lm_paths.json .
sh scripts/save_reps.sh 0_forward belief
sh scripts/save_reps.sh 0_forward action
sh scripts/save_reps.sh 0_backward beliefBinaire:
python probe.py --belief=protagonist --dynamic=0_forward --variable belief
python probe.py --belief=oracle --dynamic=0_forward --variable belief
python probe.py --belief=protagonist --dynamic=0_forward --variable action
python probe.py --belief=oracle --dynamic=0_forward --variable action
python probe.py --belief=protagonist --dynamic=0_backward --variable belief
python probe.py --belief=oracle --dynamic=0_backward --variable beliefMultinomial:
python probe_multinomial.py --dynamic=0_forward --variable belief
python probe_multinomial.py --dynamic=0_forward --variable action
python probe_multinomial.py --dynamic=0_backward --variable beliefsh scripts/0_forward_belief.sh
sh scripts/0_forward_action.sh
sh scripts/0_backward_belief.shIntervention pour la tâche de croyance avancée :
sh scripts/0_forward_belief_interv_oracle.sh
sh scripts/0_forward_belief_interv_protagonist.sh
sh scripts/0_forward_belief_interv_o0p1.shIntervention de la tâche croisée:
sh scripts/cross_0_forward_belief_to_forward_action_interv_o0p1.sh
sh scripts/cross_0_forward_belief_to_backward_belief_interv_o0p1.sh @inproceedings { zhu2024language ,
title = { Language Models Represent Beliefs of Self and Others } ,
author = { Zhu, Wentao and Zhang, Zhining and Wang, Yizhou } ,
booktitle = { Forty-first International Conference on Machine Learning } ,
year = { 2024 }
}