Bug about using ROME to edit
Hello, when I tried to use ROME to edit gpt2-xl according to the example of ROME from the Docs and Colab, I met some bugs. The code is: from easyeditor import ROMEHyperParams from easyeditor import BaseEditor
hparams = ROMEHyperParams.from_hparams('./hparams/ROME/gpt2-xl')
prompts = ['Ray Charles, the', 'Grant Hill is a professional', 'The law in Ikaalinen declares the language' ] ground_truth = ['piano', 'basketball', 'Finnish' ] target_new = ['violin', 'soccer', 'Swedish' ] subject = ['Ray Charles', 'Grant Hill', 'Ikaalinen' ]
editor = BaseEditor.from_hparams(hparams)
metrics, edited_model, _ = editor.edit( prompts=prompts, ground_truth=ground_truth, target_new=target_new, subject=subject, # locality_inputs=locality_inputs, keep_original_weight=False )
I met a bug:
Traceback (most recent call last):
File "/home/yangwanli/EasyEdit/test_rome.py", line 25, in
I found the bug come from "File "/home/yangwanli/EasyEdit/easyeditor/util/runningstats.py", line 1485, in load_cached_state": if a not in dat or dat[a] != v: if not quiet: print("%s %s changed from %s to %s" % (cachefile, a, dat[a], v)) return None
a was not in dat, but you used dat[a], so it raise the KeyError. But I don't know how to fix the bug. I tried to comment the print codes, but it raise other errors.
Here are my two suggestions:
-
- Set
mom2_adjustmentto false, which avoids calculating second-order momentum, but does not affect overall performance.
- Set
-
- When
mom2_adjustmentis set to True, the wikipedia dataset must be downloaded and the representation calculated, which is time-consuming. You can break points here (or import pdb) to see if the load dataset is correct
- When
Now that I've set all mom2_adjustment to False by default, please update the easyedit code and try again.
If your problem has been resolved, please help close this issue.
Thanks for your help! It's correct. Now I can use ROME to edit gpt2-xl successfully. Thanks for your great contributions again!