zjunlp / EasyEdit

[ACL 2024] An Easy-to-use Knowledge Editing Framework for LLMs.
https://zjunlp.github.io/project/KnowEdit
MIT License
1.74k stars 210 forks source link

About the VQADataset #254

Closed yaohui120 closed 3 months ago

yaohui120 commented 3 months ago

I found something weird in VQADataset. When the tokenizer changes the answer to numbers, I found:

(Pdb) self.tok.encode([data[2]['target']], add_special_tokens=False, return_tensors="pt",)
tensor([[0]])
(Pdb) self.tok.encode(data[2]['target'], add_special_tokens=False, return_tensors="pt",)
tensor([[ 6454, 20452]])

Only the second one can be decoded as 'tomatoes' correctly. However, in function collate_fn, when batch_size=1, the format of trg is a list contained only one string, this will make edit_inner['labels'] wrong. I want to know if I understand it correctly.

tbozhong commented 3 months ago

Thank you for bringing this to our attention! You are indeed correct in your understanding, and I have addressed the issue.

However, this bug does not affect the outcome, as the forward pass of MiniGPT-4 and BLIP-2 returns a class containing logits and labels. We utilize these labels for evaluation, not edit_inner['labels'].

My apologies for any inconvenience caused! Please don't hesitate to get in touch if you need any assistance.

yaohui120 commented 3 months ago

Oh, I used the old version code, and it's

post_edit_outputs = edited_model(batch["edit_outer"])
post_batch_labels = batch["edit_outer"]["labels"]
if not isinstance(post_edit_outputs, torch.Tensor):
    post_edit_logits = post_edit_outputs.logits
else:
    post_edit_logits = post_edit_outputs

I am testing the current version code. Thank you.

yaohui120 commented 3 months ago

I test the newest code on VQA dataset and it doesn't have the problem I mention above. Thank you~