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

Skip token in push_to_hub #1945

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions trl/trainer/bco_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1432,12 +1432,12 @@ def push_to_hub(
self,
commit_message: Optional[str] = "End of training",
blocking: bool = True,
token: Optional[str] = None,
# token: Optional[str] = None, # Unlike the parent class, skip the token to mitigate security risks.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we delete altogether instead of having this commented out code?

Suggested change
# token: Optional[str] = None, # Unlike the parent class, skip the token to mitigate security risks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can.
I just want to find a way to tell my future self not to re-add it. I'll add to the comment below, let me know if that's ok.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better, thanks!

**kwargs,
) -> str:
"""
Overwrite the `push_to_hub` method in order to force-add the tag "bco" when pushing the
model on the Hub. Please refer to `~transformers.Trainer.push_to_hub` for more details.
"""
kwargs = trl_sanitze_kwargs_for_tagging(model=self.model, tag_names=self._tag_names, kwargs=kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, token=token, **kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, **kwargs)
4 changes: 2 additions & 2 deletions trl/trainer/cpo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,12 +970,12 @@ def push_to_hub(
self,
commit_message: Optional[str] = "End of training",
blocking: bool = True,
token: Optional[str] = None,
# token: Optional[str] = None, # Unlike the parent class, skip the token to mitigate security risks.
**kwargs,
) -> str:
"""
Overwrite the `push_to_hub` method in order to force-add the tag "cpo" when pushing the
model on the Hub. Please refer to `~transformers.Trainer.push_to_hub` for more details.
"""
kwargs = trl_sanitze_kwargs_for_tagging(model=self.model, tag_names=self._tag_names, kwargs=kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, token=token, **kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, **kwargs)
4 changes: 2 additions & 2 deletions trl/trainer/dpo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1615,12 +1615,12 @@ def push_to_hub(
self,
commit_message: Optional[str] = "End of training",
blocking: bool = True,
token: Optional[str] = None,
# token: Optional[str] = None, # Unlike the parent class, skip the token to mitigate security risks.
**kwargs,
) -> str:
"""
Overwrite the `push_to_hub` method in order to force-add the tag "dpo" when pushing the
model on the Hub. Please refer to `~transformers.Trainer.push_to_hub` for more details.
"""
kwargs = trl_sanitze_kwargs_for_tagging(model=self.model, tag_names=self._tag_names, kwargs=kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, token=token, **kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, **kwargs)
6 changes: 3 additions & 3 deletions trl/trainer/iterative_sft_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,12 @@ def push_to_hub(
self,
commit_message: Optional[str] = "End of training",
blocking: bool = True,
token: Optional[str] = None,
# token: Optional[str] = None, # Unlike the parent class, skip the token to mitigate security risks.
**kwargs,
) -> str:
"""
Overwrite the `push_to_hub` method in order to force-add the tag "dpo" when pushing the
Overwrite the `push_to_hub` method in order to force-add the tag "iterative-sft" when pushing the
model on the Hub. Please refer to `~transformers.Trainer.push_to_hub` for more details.
"""
kwargs = trl_sanitze_kwargs_for_tagging(model=self.model, tag_names=self._tag_names, kwargs=kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, token=token, **kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, **kwargs)
4 changes: 2 additions & 2 deletions trl/trainer/kto_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1385,12 +1385,12 @@ def push_to_hub(
self,
commit_message: Optional[str] = "End of training",
blocking: bool = True,
token: Optional[str] = None,
# token: Optional[str] = None, # Unlike the parent class, skip the token to mitigate security risks.
**kwargs,
) -> str:
"""
Overwrite the `push_to_hub` method in order to force-add the tag "kto" when pushing the
model on the Hub. Please refer to `~transformers.Trainer.push_to_hub` for more details.
"""
kwargs = trl_sanitze_kwargs_for_tagging(model=self.model, tag_names=self._tag_names, kwargs=kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, token=token, **kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, **kwargs)
4 changes: 2 additions & 2 deletions trl/trainer/online_dpo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,12 +580,12 @@ def push_to_hub(
self,
commit_message: Optional[str] = "End of training",
blocking: bool = True,
token: Optional[str] = None,
# token: Optional[str] = None, # Unlike the parent class, skip the token to mitigate security risks.
**kwargs,
) -> str:
"""
Overwrite the `push_to_hub` method in order to force-add the tag "online-dpo" when pushing the
model on the Hub. Please refer to `~transformers.Trainer.push_to_hub` for more details.
"""
kwargs = trl_sanitze_kwargs_for_tagging(model=self.model, tag_names=self._tag_names, kwargs=kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, token=token, **kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, **kwargs)
4 changes: 2 additions & 2 deletions trl/trainer/orpo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,12 +975,12 @@ def push_to_hub(
self,
commit_message: Optional[str] = "End of training",
blocking: bool = True,
token: Optional[str] = None,
# token: Optional[str] = None, # Unlike the parent class, skip the token to mitigate security risks.
**kwargs,
) -> str:
"""
Overwrite the `push_to_hub` method in order to force-add the tag "orpo" when pushing the
model on the Hub. Please refer to `~transformers.Trainer.push_to_hub` for more details.
"""
kwargs = trl_sanitze_kwargs_for_tagging(model=self.model, tag_names=self._tag_names, kwargs=kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, token=token, **kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, **kwargs)
4 changes: 2 additions & 2 deletions trl/trainer/ppov2_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,12 +617,12 @@ def push_to_hub(
self,
commit_message: Optional[str] = "End of training",
blocking: bool = True,
token: Optional[str] = None,
# token: Optional[str] = None, # Unlike the parent class, skip the token to mitigate security risks.
**kwargs,
) -> str:
"""
Overwrite the `push_to_hub` method in order to force-add the tag "ppo" when pushing the
model on the Hub. Please refer to `~transformers.Trainer.push_to_hub` for more details.
"""
kwargs = trl_sanitze_kwargs_for_tagging(model=self.model, tag_names=self._tag_names, kwargs=kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, token=token, **kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, **kwargs)
4 changes: 2 additions & 2 deletions trl/trainer/reward_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,12 @@ def push_to_hub(
self,
commit_message: Optional[str] = "End of training",
blocking: bool = True,
token: Optional[str] = None,
# token: Optional[str] = None, # Unlike the parent class, skip the token to mitigate security risks.
**kwargs,
) -> str:
"""
Overwrite the `push_to_hub` method in order to force-add the tag "reward-trainer" when pushing the
model on the Hub. Please refer to `~transformers.Trainer.push_to_hub` for more details.
"""
kwargs = trl_sanitze_kwargs_for_tagging(model=self.model, tag_names=self._tag_names, kwargs=kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, token=token, **kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, **kwargs)
4 changes: 2 additions & 2 deletions trl/trainer/rloo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,12 +515,12 @@ def push_to_hub(
self,
commit_message: Optional[str] = "End of training",
blocking: bool = True,
token: Optional[str] = None,
# token: Optional[str] = None, # Unlike the parent class, skip the token to mitigate security risks.
**kwargs,
) -> str:
"""
Overwrite the `push_to_hub` method in order to force-add the tag "rloo" when pushing the
model on the Hub. Please refer to `~transformers.Trainer.push_to_hub` for more details.
"""
kwargs = trl_sanitze_kwargs_for_tagging(model=self.model, tag_names=self._tag_names, kwargs=kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, token=token, **kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, **kwargs)
4 changes: 2 additions & 2 deletions trl/trainer/sft_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,15 +462,15 @@ def push_to_hub(
self,
commit_message: Optional[str] = "End of training",
blocking: bool = True,
token: Optional[str] = None,
# token: Optional[str] = None, # Unlike the parent class, skip the token to mitigate security risks.
**kwargs,
) -> str:
"""
Overwrite the `push_to_hub` method in order to force-add the tag "sft" when pushing the
model on the Hub. Please refer to `~transformers.Trainer.push_to_hub` for more details.
"""
kwargs = trl_sanitze_kwargs_for_tagging(model=self.model, tag_names=self._tag_names, kwargs=kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, token=token, **kwargs)
return super().push_to_hub(commit_message=commit_message, blocking=blocking, **kwargs)

def _prepare_dataset(
self,
Expand Down
Loading