collabedit
[ICLR 2025] CollabEdit: Towards Non-destructive Collaborative Knowledge Editing
Science Score: 54.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.9%) to scientific vocabulary
Repository
[ICLR 2025] CollabEdit: Towards Non-destructive Collaborative Knowledge Editing
Basic Info
Statistics
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
CollabEdit: Towards Non-destructive Collaborative Knowledge Editing
If our project helps you, please give us a star ⭐ and cite our paper!
Overview
Overview
Collaborative learning of LLMs has emerged as a new paradigm for utilizing private data from different parties. Meanwhile, Knowledge Editing (KE) for LLMs has also garnered increased attention due to its ability to manipulate the behaviors of LLMs explicitly, yet leaves the collaborative KE case unexamined (in which knowledge edits of multiple parties are aggregated in a privacy-preserving and continual manner):
- Destructive collaborative KE ( a naive combination of single-model KE methods and model fusion techniques) suffer from significant performance degradation.
- Currently, there is no existing method to address the three important challenges (knowledge overlap, knowledge conflict, and knowledge forgetting) that we have identified in collaborative scenarios.
Therefore, we designed CollabEdit to nondestructively integrate edits from multiple LLMs simultaneously and, based on this framework, propose a solution to address the three challenges.
Installation
We recommend conda for managing Python, CUDA, and PyTorch; pip is for everything else. To get started, simply install conda and run:
```bash CONDAHOME=$CONDAHOME ./scripts/setup_conda.sh
example 1
CONDAHOME=~/miniconda3 ./scripts/setupconda.sh
example 2
CONDAHOME=/opt/anaconda3 ./scripts/setupconda.sh ```
$CONDA_HOME should be the path to your conda installation, e.g., ~/miniconda3.
How to use our codebase for collaborative KE?
1. Collaborative KE in a single round (i.e., each client submits edit requests once):
1) Comparing standard KE (Global-Editing), destructive collaborative KE (SA, TA, Ties) and our nondestructive collaborative KE (CollabEdit) in a single round:
```BASH
GPT-J
python3 -m experiments.mergingsingleRound --algname=MEMIT --modelname=EleutherAI/gpt-j-6B --hparamsfname=EleutherAIgpt-j-6B.json --numeditsperclientperround=500 --numclients=10 --usecache --merging_method=CollabEdit
GPT2-XL
python3 -m experiments.mergingsingleRound --algname=MEMIT --modelname=gpt2-xl --hparamsfname=gpt2-xl.json --numeditsperclientperround=500 --numclients=10 --usecache --mergingmethod=CollabEdit ```
merging_methodincludes["GLOBAL", "SA", "TA", "TIES", "CollabEdit"]."GLOBAL"means Global-Editing (Upper bound)"SA"means Simple-Average."TA"means Task-Arithmetic."TIES"means Ties-Merging."CollabEdit"means our CollabEdit.
By default, we assume there are
10clients and each client has500edit requests. You can easily modify our code to handle different numbers of edit requests from different clients.Results of each run are stored at
results/<method_name>/run_<run_id>:
bash
results/
|__ MEMIT/
|__ run_<run_id>/
|__ params.json
|__ case_0.json
|__ case_1.json
|__ ...
|__ case_10000.json
2) To summarize the results, you can use experiments/CollabEdit_summarize.py.
bash
python3 -m experiments.CollabEdit_summarize --dir_name=MEMIT --edit_category global_edit --runs=run_<run_id>
edit_category: ["global_edit", "collabrative_edit"]- Set
edit_categorytoglobal_editwhen you use GLOBAL. - Set
edit_categorytocollaborative_editwhen you use SA/TA/TIES/CollabEdit.
- Set
2. Collaborative KE in multiple rounds (i.e., each client submits edit requests multiple times):
1) Comparing Global-Editing, SA, TA, Ties and our CollabEdit in multiple rounds: ```BASH
GPT-J
python3 -m experiments.mergingmultiRound --algname=MEMIT --modelname=EleutherAI/gpt-j-6B --hparamsfname=EleutherAIgpt-j-6B.json --numeditsperclientperround=100 --numclients=10 --numrounds=5 --usecache --mergingmethod=CollabEdit
GPT2-XL
python3 -m experiments.mergingmultiRound --algname=MEMIT --modelname=gpt2-xl --hparamsfname=gpt2-xl.json --numeditsperclientperround=100 --numclients=10 --numrounds=5 --usecache --merging_method=CollabEdit ```
- You can modify the following variables to adjust the total number of edit requests (
num_edits = num_clients x num_edits_per_client_per_round x num_rounds):num_clients: The number of clients.num_edits_per_client_per_round: The number of edit requests made by a client in a round.num_rounds: The number of rounds.
- We introduce Dynamic Covariance in our CollabEdit algorithm to enhance multi-round editing, which can significantly improve the editing performance and mitigate Knowledge Forgetting.
2) To summarize the results, you can use experiments/CollabEdit_summarize.py.
Additional experiments
(1) Evaluate knowledge forgetting and the performance of Dynamic Covariance $\mathbf{C}$:
```BASH
Knowledge Forgetting on GPT-J
python3 -m experiments.multiround --algname=MEMIT --modelname=EleutherAI/gpt-j-6B --hparamsfname=EleutherAIgpt-j-6B.json --numedits=1000 --usecache
Knowledge Forgetting on GPT2-XL
python3 -m experiments.multiround --algname=MEMIT --modelname=gpt2-xl --hparamsfname=gpt2-xl.json --numedits=1000 --use_cache ```
We test how Knowledge Forgetting affects the final editing outcome in the multiround.py script. (Immutable $\mathbf{C}$)
```BASH
Mitigating Knowledge Forgetting on GPT2-XL with Dynamic Covariance
python3 -m experiments.C1 --algname=MEMIT --modelname=gpt2-xl --hparamsfname=gpt2-xl.json --numedits=1000 --usecache
Mitigating Knowledge Forgetting on GPT-J with Dynamic Covariance
python3 -m experiments.C1 --algname=MEMIT --modelname=gpt2-xl --hparamsfname=gpt2-xl.json --numedits=1000 --usecache ```
We tested in the C_1.py whether our proposed Dynamic Covariance can mitigate the problem of Knowledge Forgetting. (Dynamic $\mathbf{C}$)
To summarize the results, you can use experiments/CollabEdit_summarize.py.
(2) Test Knowledge overlap and the $\ell_2$-norm of Residual $\mathbf{R}$:
The experiment is relatively straightforward, so we decide not write an additional script. If you want to experiment and observe Residual $\mathbf{R}$, you only need to make some minor modifications to merging_singleRound.py. The steps are as follows:
- Firstly, change the
record_chunkson line133of merging_singleRound.py to1000repeated first elements.
python
...
for record_chunks in Rec_chunks:
#generate repeat examples
repeat_item = record_chunks[0]
front_list = []
for i in range(1000):
front_list.append(repeat_item)
front_list.extend(record_chunks)
record_chunks = front_list
...
- Secondly, locate the intermediate variable
R_L2on line258under memit_main.py, and print it within every editing round to observe the change in the $\ell_2$-norm of the Residual $\mathbf{R}$ as the number of repeated editing rounds increases.
python
...
adj_k = torch.linalg.solve(
hparams.mom2_update_weight * cov.double() + layer_ks @ layer_ks.T,
layer_ks,
)
resid = targets / (len(hparams.layers) - i) # Distribute residual across layers
R_L2 = torch.linalg.norm(resid)
#print("R_L2: ",R_L2)
upd_matrix = resid @ adj_k.T
...
To summarize the results, you can use experiments/CollabEdit_summarize.py.
(3) Test Knowledge conflict and the effects of data augmentation.:
```BASH
TEST Conflict(full)on GPT2-XL
python3 -m experiments.Conflict --algname=MEMIT --modelname=gpt2-xl --hparamsfname=gpt2-xl.json --usecache --dsname=mcfconflict --conflictexptype=whetherConflict --numedits=2500 --datasetsize_limit 2500
TEST Conflict(full)on GPT-J
python3 -m experiments.Conflict --algname=MEMIT --modelname=EleutherAI/gpt-j-6B --hparamsfname=EleutherAIgpt-j-6B.json --usecache --dsname=mcfconflict --conflictexptype=whetherConflict --numedits=2500 --datasetsizelimit 2500 ```
conflict_exp_typeincludes["whetherConflict","Performance_A","Performance_B","Performance_[A+B]","single_B"].Adenotes the original edits andBdenotes the conflict edits.whetherConflict: We editedAbut evaluated model‘s performance based onB's answers to verify whetherA's answer conflict with that ofB.Performance_A: We only tested the performance onA, which is equivalent to runningmerging.py. ( Edit $\mathcal{E}$ )Performance_B: We edited bothAandB, but we ultimately evaluated the model's performance based onA's answers. ( Edit $\mathcal{E}^{\prime}$ )Performance_[A+B]: We edited bothAandB, but we ultimately evaluated the model's performance based onB's answers.
```BASH
TEST data augmentation for knowledge conflict on GPT2-XL
python3 -m experiments.evaluateaugmentation --algname=MEMIT --modelname=gpt2-xl --hparamsfname=gpt2-xl.json --datasetsizelimit 1000 --num_edits 1000 --mode=easy
TEST data augmentation for knowledge conflict on GPT-J
python3 -m experiments.evaluateaugmentation --algname=MEMIT --modelname=EleutherAI/gpt-j-6B --hparamsfname=EleutherAIgpt-j-6B.json --datasetsizelimit 1000 --numedits 1000 --mode=easy ```
To summarize the results, you can use experiments/CollabEdit_summarize.py.
Acknowledgement
We are grateful for the following awesome projects:
How to Cite
bibtex
@article{zheng2024collabedit,
title={CollabEdit: Towards Non-destructive Collaborative Knowledge Editing},
author={Zheng, Jiamu and Zhang, Jinghuai and Du, Tianyu and Zhang, Xuhong and Yin, Jianwei and Lin, Tao},
journal={International Conference on Learning Representations (ICLR)},
year={2025}
}
Owner
- Name: LINs Lab @ Westlake University
- Login: LINs-lab
- Kind: organization
- Location: China
- Website: https://lins-lab.github.io/
- Repositories: 2
- Profile: https://github.com/LINs-lab
Learning and INference Systems (LINs) Laboratory
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
preferred-citation:
type: article
authors:
- family-names: "Zheng"
given-names: "Jiamu"
- family-names: "Zhang"
given-names: "Jinghuai"
- family-names: "Du"
given-names: "Tianyu"
- family-names: "Zhang"
given-names: "Xuhong"
- family-names: "Yin"
given-names: "Jianwei"
- family-names: "Lin"
given-names: "Tao"
journal: "International Conference on Learning Representations (ICLR)"
title: "CollabEdit: Towards Non-destructive Collaborative Knowledge Editing"
year: 2025
GitHub Events
Total
- Watch event: 9
- Push event: 2
- Public event: 1
Last Year
- Watch event: 9
- Push event: 2
- Public event: 1