Official repo for our paper Reinforced Lifelong Editing for Language Models
.
Create a virtual environment and install the dependencies.
conda create -n rledit python==3.11
conda activate rledit
pip install -r requirements.txt
Download LLMs, and put their paths into config/model/xxx.yaml
You can modify the GPU device number you want to use in the model.py
file.
run.sh
is a simple example that performs a 400x20 editing task on the ZSRE dataset using Llama-3-8B.
sh run.sh
The run.sh
script is as follows:
python main.py dataset=fever model=llama-3-instruct editor=rledit num_seq=20
Below are the explanations for each argument:
dataset
: Dataset used for editing and testing.model
: LLM used for editing and testing.editor
: Method for editing and testing. Available methods includerledit
,mend
, andmalmen
. All of these methods are evaluated using lifelong editing tasks.num_seq
: Number of editing batches. For example, in a 400x20 editing task, this value is 400.
Other configurable settings can be found in config
folder., such as:
n_edits
inconfig/dataset/zsre.yaml
: Number of knowledge samples edited per batch. For example, in a 400x20 editing task, this value is 20.reg_coef
inconfig/editor/rledit.yaml
: The regularization coefficient.time_decay
inconfig/editor/rledit.yaml
: Memory backtracking decay factor.edit_modules
inconfig/model/llama-3-instruct.yaml
: Layer indices of the LLM to be edited.
Our code is based on malmen. Thanks to their clear and understandable code!