zjunlp / EasyEdit

[知识编辑] [ACL 2024] An Easy-to-use Knowledge Editing Framework for LLMs.
https://zjunlp.github.io/project/KnowEdit
MIT License
1.63k stars 200 forks source link

Qwen1.5 AttributeError: 'BaseModelOutputWithPast' object has no attribute 'logits' #288

Closed CaiJichang212 closed 1 month ago

CaiJichang212 commented 1 month ago

when i run run_knowedit_llama2.py with Qwen1.5 & ROME:

Traceback (most recent call last): File "EasyEdit/examples/run_knowedit_llama2.py", line 208, in metrics, editedmodel, = editor.edit( File "EasyEdit/easyeditor/editors/editor.py", line 171, in edit return self.edit_requests(requests, sequential_edit, verbose, kwargs) File "EasyEdit/easyeditor/editors/editor.py", line 280, in edit_requests metrics = {"pre": compute_edit_quality(self.model, self.model_name, self.hparams, self.tok, request, self.hparams.device, eval_metric=eval_metric, test_generation=test_generation)} File "EasyEdit/easyeditor/evaluate/evaluate.py", line 64, in compute_edit_quality ret = compute_rewrite_or_rephrase_quality(model, model_name, hparams, tok, File "EasyEdit/easyeditor/evaluate/evaluate.py", line 133, in compute_rewrite_or_rephrase_quality acc = test_prediction_acc(model, tok, hparams, prompt, target_new, device) File "EasyEdit/easyeditor/evaluate/evaluate_utils.py", line 134, in test_prediction_acc logits = outputs.logits AttributeError: 'BaseModelOutputWithPast' object has no attribute 'logits'**

CaiJichang212 commented 1 month ago

how can you so fast?

CaiJichang212 commented 1 month ago

image bug code position

CaiJichang212 commented 1 month ago

when i run run_knowedit_llama2.py with llama2 & ROME,there is no bug. is the qwen1.5 a reason?

XeeKee commented 1 month ago

Hello, run_knowedit_llama2.py is prepared to run llama2 for the knowedit dataset. If you want to run qwen, I recommend you use the functions inside edit.py and load the dataset using KnowEditDataset

CaiJichang212 commented 1 month ago

thank for you response, however I don't think this bug has anything to do with the dataset.

elif 'qwen' in self.model_name.lower():
    # self.model = AutoModelForCausalLM.from_pretrained(self.model_name,fp32=False,trust_remote_code=True, device_map=device_map)
    # fix cjc@0603 TypeError: __init__() got an unexpected keyword argument 'fp32' qwen1.5
    self.model = AutoModel.from_pretrained(self.model_name,trust_remote_code=True, torch_dtype=torch_dtype, device_map=device_map)
    self.tok = AutoTokenizer.from_pretrained(self.model_name, eos_token='<|endoftext|>', pad_token='<|endoftext|>',unk_token='<|endoftext|>', trust_remote_code=True)

whether running run_knowedit_llama2.py or something else xxx.py script,executes this load model&tok code.

CaiJichang212 commented 1 month ago

Hello, run_knowedit_llama2.py is prepared to run llama2 for the knowedit dataset. If you want to run qwen, I recommend you use the functions inside edit.py and load the dataset using KnowEditDataset

Looking forward to your reply