Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

line 307 in editor.py #255

Closed
SH9959 opened this issue May 14, 2024 · 4 comments
Closed

line 307 in editor.py #255

SH9959 opened this issue May 14, 2024 · 4 comments
Labels
question Further information is requested

Comments

@SH9959
Copy link

SH9959 commented May 14, 2024

Dear EasyEdit team,
I may have found a seeming contradiction line 307: EasyEdit/easyeditor/editors/editor.py
with torch.no_grad(): for k, v in weights_copy.items(): nethook.get_parameter(self.model, k)[...] = v.to(f "cuda:{self.hparams.device}")
This seems to be restoring the weights of the original model. But the final return value is named edited_model in line 361.
This has confused me, and I'm not sure if I'm missing other information that has led me to this confusion.

@pengzju
Copy link
Collaborator

pengzju commented May 15, 2024

Actually, the edited_model is a reference (address) to model, so they are essentially the same.

@SH9959
Copy link
Author

SH9959 commented May 15, 2024

😆Yes. But my question is that the weights of the specific layer in edited_model are recovered by weight_copy which records the origin value of origin model. So the edited_model gets the same weights as the origin model. I'm confused about whether the return value is what we expect. 🤔

@zxlzr zxlzr added the question Further information is requested label May 15, 2024
@pengzju
Copy link
Collaborator

pengzju commented May 15, 2024

👍Yes, your understanding is correct. In the past editing literature, the measurements were the results of a single edit, so it was necessary to roll back after each evaluation. However, in EasyEdit, you can enable continuous editing by setting keep_original_weights = False, more details in the issue #220

@SH9959
Copy link
Author

SH9959 commented May 15, 2024

Oh, I see. Thanks for your reply!😆

@SH9959 SH9959 closed this as completed May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants