EasyEdit icon indicating copy to clipboard operation
EasyEdit copied to clipboard

综述论文当中sequential editing的复现问题

Open WanliYoung opened this issue 3 years ago • 10 comments

作者您好!非常感谢你们的杰出贡献。 最近我在尝试利用EasyEdit复现你们的这篇论文("Editing Large Language Models: Problems, Methods, and Opportunities")中关于sequential editing的结果。 我采用的模型是gpt-j-6b,编辑方法是ROME,数据集是zsre_mend_eval.json的前一千条数据 执行程序全部代码如下:

from easyeditor import ROMEHyperParams, BaseEditor
import json

test_data = json.load(open("DATA_PATH", 'r', encoding='utf-8'))

prompts = [test_data_['src'] for test_data_ in test_data]  
target_new = [test_data_['alt'] for test_data_ in test_data]  
subject = [test_data_['subject'] for test_data_ in test_data]
rephrase_prompts = [edit_data_['rephrase'] for edit_data_ in test_data]
locality_prompts = [edit_data_['loc'] for edit_data_ in test_data]
locality_ans = [edit_data_['loc_ans'] for edit_data_ in test_data]

locality_inputs = {
    'neighborhood':{
        'prompt': locality_prompts,
        'ground_truth': locality_ans
    },
}

hparams = ROMEHyperParams.from_hparams('./hparams/ROME/gpt-j-6b')  
editor = BaseEditor.from_hparams(hparams)

metrics, edited_model, _ = editor.edit(
    prompts=prompts,
    target_new=target_new,
    rephrase_prompts=rephrase_prompts,
    locality_inputs=locality_inputs,
    subject=subject,
    keep_original_weight=False
)

# json.dump...

其余代码除在hparams指定模型路径和显卡外都没有改动。

在1000次sequential editing的统计数据中,locality指标中的neighborhood_acc达到1.0的仅有7项。但是原论文中该设置下,正确率至少应该有25%。

请问可能是什么地方出现了问题呢?非常期待您的答复!谢谢!

WanliYoung avatar Nov 14 '23 13:11 WanliYoung

In the paper, we use second-order momentum to adjust the model weights, mom2_adjustment is set to True. Perhaps the performance fluctuation comes from the setting of this hyperparameter

  • https://github.com/zjunlp/EasyEdit/blob/main/hparams/ROME/llama-7b.yaml#L13

pengzju avatar Nov 15 '23 02:11 pengzju

If you still can't reproduce the results, please leave me a message

pengzju avatar Nov 15 '23 02:11 pengzju

Ok, thank you! I will try the solution and reply.

WanliYoung avatar Nov 15 '23 08:11 WanliYoung

In the paper, we use second-order momentum to adjust the model weights, mom2_adjustment is set to True. Perhaps the performance fluctuation comes from the setting of this hyperparameter

  • https://github.com/zjunlp/EasyEdit/blob/main/hparams/ROME/llama-7b.yaml#L13

The setting works. Thank you so much!

WanliYoung avatar Nov 16 '23 03:11 WanliYoung

Sorry for bothering you that though the result for zsre is consistent with the paper (even higher) the result for counterfact is a bit different from the paper. Under the setting above, I sequentially edited gptj with ROME one hundred times on counterfact, the final acc is about 23% which is about 50% in paper. Is this acceptable?

WanliYoung avatar Nov 16 '23 04:11 WanliYoung

Could you perhaps share the hyperparameter settings used in your paper's experiments? I'd like to compare and see if there are any differences in certain hyperparameters. Thank you so much!

WanliYoung avatar Nov 16 '23 14:11 WanliYoung

我们采用的是应该是counterfact_portability_gpt4.json这个文件,或许可以尝试这个? 如果性能在个位数浮动,可能是正常的。

pengzju avatar Nov 18 '23 02:11 pengzju

参数应该都是默认即可

pengzju avatar Nov 18 '23 03:11 pengzju

Hi, have you solved your issue?

zxlzr avatar Nov 19 '23 02:11 zxlzr

Yes. I have reproduced the results in your paper. Thank you for your kind help!

WanliYoung avatar Nov 19 '23 11:11 WanliYoung