This repository is the official implementation of the paper "Precise Localization of Memories: A Fine-grained Neuron-level Knowledge Editing Technique for LLMs" (ICLR 2025).
To get started, please clone this repository and install packages as:
git clone https://github.com/opanhw/FiNE.git
conda create -n FiNE python=3.11
...
pip install -r requirements.txt- KnowEdit Benchmark
See details of the benchmark in this page.
Please setting parameters before editing. Parameters of FiNE can be found in ./hparams/FINE/, which contain:
model_name: path to the model you chooseepochs: maximum iterationslr: learning ratealpha: coefficient of KL divergencebeta: coefficient of repetition penalty lossgamma: coefficient of norm lossneuron_num: number of edited neuronsearly_stop_prob: minimum probability of early stoppinglast_layer: number of last frozen layersfp16: true for single precision, false for double precision
A sample editing command for gpt-j-6b is:
bash run_gptj_fine.shA sample editing command for llama-2-7b is:
bash run_llama2_fine.shA sample editing command for llama-3-8b is:
bash run_llama3_fine.shOur code is based on EasyEdit and MM_Neurons.
Thanks @wonderful9462 for the assistance in this work.
If you find this code useful, please kindly cite our work as:
@inproceedings{pan2025precise,
title={Precise Localization of Memories: A Fine-grained Neuron-level Knowledge Editing Technique for LLMs},
author={Haowen Pan and Xiaozhi Wang and Yixin Cao and Zenglin Shi and Xun Yang and Juanzi Li and Meng Wang},
booktitle={The Thirteenth International Conference on Learning Representations},
year={2025},
url={https://openreview.net/forum?id=5xP1HDvpXI}
}