-
Notifications
You must be signed in to change notification settings - Fork 157
Upgrading transformers version to 4.51.3 to support recent models #175
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
Changes from all commits
56b662e
31546d3
9987ee3
4b43848
e180d7f
1a3b7c8
367fee9
d6f1f1a
f1d2572
d3dfad6
faf942f
2ff5029
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,12 +18,12 @@ | |
| install_requires=requirements, # Uses requirements.txt | ||
| extras_require={ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| "lm-eval": [ | ||
| "lm-eval==0.4.8", | ||
| ], # Install using `pip install .[lm-eval]` | ||
| "lm-eval==0.4.11", | ||
| ], # Install using `pip install ".[lm-eval]"` | ||
| "dev": [ | ||
| "pre-commit==4.0.1", | ||
| "ruff==0.6.9", | ||
| ], # Install using `pip install .[dev]` | ||
| ], # Install using `pip install ".[dev]"` | ||
| }, | ||
| python_requires=">=3.11", | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| from typing import Any, Dict, List, Optional, Tuple, Union | ||
| from typing import Any, Optional, Union | ||
|
|
||
| import torch | ||
| from torch import nn | ||
|
|
@@ -78,10 +78,10 @@ def _prepare_deepspeed(self, model): | |
| def prediction_step( | ||
| self, | ||
| model: nn.Module, | ||
| inputs: Dict[str, Union[torch.Tensor, Any]], | ||
| inputs: dict[str, Union[torch.Tensor, Any]], | ||
| prediction_loss_only: bool, | ||
| ignore_keys: Optional[List[str]] = None, | ||
| ) -> Tuple[Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor]]: | ||
| ignore_keys: Optional[list[str]] = None, | ||
| ) -> tuple[Optional[torch.Tensor], Optional[torch.Tensor], Optional[torch.Tensor]]: | ||
| """ | ||
| The only change to this function is calling the Trainer's compute_loss, as it's often overridden by unlearning methods, and we want to maintain the Trainer's evaluation setup. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also include these docstrings in the updated code including |
||
| """ | ||
|
|
@@ -104,7 +104,9 @@ def prediction_step( | |
| if ignore_keys is None: | ||
| if hasattr(self.model, "config"): | ||
| ignore_keys = getattr( | ||
| self.model.config, "keys_to_ignore_at_inference", [] | ||
| self.model.config, | ||
| "keys_to_ignore_at_inference", | ||
| ["past_key_values"], | ||
| ) | ||
| else: | ||
| ignore_keys = [] | ||
|
|
@@ -146,11 +148,11 @@ def prediction_step( | |
| else: | ||
| if has_labels or loss_without_labels: | ||
| with self.compute_loss_context_manager(): | ||
| ### Call compute_loss of super class since overridden compute_loss is not be applicable to eval_dataset. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the line I am referring here: https://github.com/locuslab/open-unlearning/pull/175/changes#r2837139317 |
||
| ### Call compute_loss of super class since overridden compute_loss is not applicable to eval_dataset. | ||
| loss, outputs = super().compute_loss( | ||
| model, inputs, return_outputs=True | ||
| ) | ||
| loss = loss.mean().detach() | ||
| loss = loss.detach().mean() | ||
|
|
||
| if isinstance(outputs, dict): | ||
| logits = tuple( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like these additions in gitignore are specific to your usecases.
can you revert this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, done