This repository contains modified versions of EasyEdit and mergekit for experiments on model merging after knowledge editing.
git clone https://github.com/Applied-Machine-Learning-Lab/MM4KE.git
cd MM4KE
conda create -n MM4KE python=3.9.7
conda activate MM4KE
# Install EasyEdit dependencies
cd EasyEdit
pip install -r requirements.txt
# Install mergekit dependencies
cd ../mergekit
pip install -e .
cd EasyEdit/examples
python run_knowedit_llama2.py \
--editing_method=FT \
--hparams_dir=../hparams/FT/qwen2.5-7b \
--data_dir=./data \
--datatype='counterfact'
cd ../../mergekit
mergekit-pytorch examples/task_arithmetic.yml ./output_pytorch_model_directory
-
Sequential Editing Support (
EasyEdit/examples/run_knowedit_llama2.py#L265
)- Added
sequential_edit=True
parameter to enable sequential knowledge editing
- Added
-
Extended Training Epochs (
EasyEdit/easyeditor/editors/editor.py#L375-376
)- Added epoch loop with
epoch = 5
for improved editing performance - Allows multiple training iterations over the edit data
- Added epoch loop with
-
Qwen2.5 Model Support (
EasyEdit/hparams/FT/qwen2.5-7b.yaml
)- Added configuration file for Qwen2.5-7B model
- Enables knowledge editing on the latest Qwen model series
- Sparsification for Task Arithmetic (
mergekit/mergekit/merge_methods/registry.py#L31
)- Added
sparsification_method=SparsificationMethod.magnitude
to task arithmetic merging - Enables sparsification similar to TIES method but without TIES regularization
- Allows for more controlled model merging with magnitude-based pruning
- Added