GitHub - XiaojieGu/UltraEdit: UltraEdit: Training-, Subject-, and Memory-Free Lifelong Editing in Large Language Models

๐Ÿ”ฅ News

๐Ÿ“ฆ Data & Model Preparation

1๏ธโƒฃ Download the files from Google Drive and place them under UltraEdit/data/raw.

2๏ธโƒฃ Download the UltraEditBench and save it under UltraEdit/data/raw/ultraeditbench.

3๏ธโƒฃ Specify the path to model weights by setting the name_or_path field in UltraEdit/config/model/model.yaml.

If you need to use locate-then-edit methods, we provide precomputed covariance matrices on Hugging Face for several models: GPT-J 6B, Qwen2.5-7B-Instruct, Mistral-7B-v0.3, LLaMA-3-8B-Instruct, and LLaMA-2-7B-hf.

๐Ÿš€ Setup

Create the environment and install dependencies:

conda create -n ultraedit python=3.10
conda activate ultraedit
pip install torch==2.3.0+cu121 --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt

๐Ÿ’ก If you want to try editing a Mistral-7B model, even a 24GB consumer GPU is enough โ€” model editing for everyone!

๐Ÿงช Run

Run the main experiment with:

The run.sh script includes a sample command like:

python main.py dataset=zsre model=mistral-7b editor=ultraedit num_seq=200 \ # Number of turns
    editor.cache_dir=cache \
    dataset.batch_size=10 \
    dataset.n_edits=100 \ # Number of edits per turn
    model.edit_modules="[model.layers.29.mlp.down_proj, model.layers.30.mlp.down_proj]"

๐Ÿ’ก Just try editing 20K samples on Mistral-7B in under 5 minutes โ€” ultra-efficient!

๐Ÿ™ Acknowledgements

Our work builds upon several excellent model editing frameworks. We sincerely thank the authors of RLEdit for their valuable contributions to the field.

๐Ÿ“ซ Contact

For any inquiries or possible collaboration, feel free to reach out at peettherapynoys@gmail.com

๐Ÿ“‘ Citation

If you find UltraEdit useful for your research and applications, please cite using this BibTeX:

@misc{gu2025ultraedittrainingsubjectmemoryfree,
      title={UltraEdit: Training-, Subject-, and Memory-Free Lifelong Editing in Language Models}, 
      author={Xiaojie Gu and Ziying Huang and Jia-Chen Gu and Kai Zhang},
      year={2025},
      eprint={2505.14679},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2505.14679}, 
}