This repo is a fork of Function Vectors (Offical Repo) that was used for parts of the results in Reversed Attention (Offical Repo)
NOTE: the version of code that was used for Reversed Attention might be different from the most updated version of Function Vectors' repo
Follow Function Vectors instructions to run the experiments
This repository contains data and code for the paper: Function Vectors in Large Language Models.
We recommend using conda as a package manager.
The environment used for this project can be found in the fv_environment.yml file.
To install, you can run:
conda env create -f fv_environment.yml
conda activate fv
Checkout notebooks/fv_demo.ipynb for a jupyter notebook with a demo of how to create a function vector and use it in different contexts.
The datasets used in our project can be found in the dataset_files folder.
Our main evaluation scripts are contained in the src directory with sample script wrappers in src/eval_scripts.
Other main code is split into various util files:
eval_utils.pycontains code for evaluating function vectors in a variety of contextsextract_utils.pycontains functions for extracting function vectors and other relevant model activations.intervention_utils.pycontains main functionality for intervening with function vectors during inferencemodel_utils.pycontains helpful functions for loading models & tokenizers from huggingfaceprompt_utils.pycontains data loading and prompt creation functionality
We thank the authors of the Function Vectors paper. Please cite them:
This work appeared at ICLR 2024. The paper can be cited as follows:
@inproceedings{todd2024function,
title={Function Vectors in Large Language Models},
author={Eric Todd and Millicent L. Li and Arnab Sen Sharma and Aaron Mueller and Byron C. Wallace and David Bau},
booktitle={Proceedings of the 2024 International Conference on Learning Representations},
year={2024},
}