generated from fastai/nbdev_template
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[online-dpo] allow parse-args as list of floats #2108
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
kashif
changed the title
use a seperate argument for list of floats
[online-dpo] use a seperate argument for list of floats
Sep 24, 2024
What about this instead? from transformers import HfArgumentParser, TrainingArguments
from dataclasses import dataclass, field
from typing import List
@dataclass
class MyArgs(TrainingArguments):
beta: List[float] = field(default_factory=lambda: [0.1])
def __post_init__(self):
super().__post_init__()
if len(self.beta) == 1:
self.beta = self.beta[0]
parser = HfArgumentParser(MyArgs)
args = parser.parse_args_into_dataclasses()[0]
print(args.beta)
|
ah yes good idea! fixing |
To allow using args without the parser, we should check if the object has is sizeable as well: from transformers import TrainingArguments
from dataclasses import dataclass, field
from typing import List
@dataclass
class MyArgs(TrainingArguments):
beta: List[float] = field(default_factory=lambda: [0.1])
def __post_init__(self):
super().__post_init__()
if hasattr(self.beta, "__len__") and len(self.beta) == 1:
self.beta = self.beta[0]
args = MyArgs(output_dir="tmp", beta=0.2)
print(args.beta) # 0.2
args = MyArgs(output_dir="tmp", beta=[0.1, 0.2])
print(args.beta) # [0.1, 0.2] |
qgallouedec
reviewed
Sep 24, 2024
qgallouedec
reviewed
Sep 24, 2024
qgallouedec
reviewed
Sep 24, 2024
qgallouedec
reviewed
Sep 24, 2024
qgallouedec
reviewed
Sep 24, 2024
qgallouedec
reviewed
Sep 24, 2024
qgallouedec
reviewed
Sep 24, 2024
qgallouedec
reviewed
Sep 24, 2024
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
qgallouedec
reviewed
Sep 24, 2024
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
qgallouedec
reviewed
Sep 24, 2024
I'll just add a few tests |
qgallouedec
approved these changes
Sep 24, 2024
LGTM thanks, just make sure to update the title |
kashif
changed the title
[online-dpo] use a seperate argument for list of floats
[online-dpo] allow parse-args as list of floats
Sep 24, 2024
qgallouedec
added a commit
that referenced
this pull request
Sep 24, 2024
* use a seperate argument for list of floats * do super first * fix docstrings * typos * use list of floats only * check if it has len * fix docstring * fix suggestion * fix default * Update trl/trainer/online_dpo_config.py Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com> * Update trl/trainer/xpo_config.py Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com> * Update trl/trainer/nash_md_config.py Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com> * Update trl/trainer/nash_md_config.py * additional tests --------- Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com> Co-authored-by: Quentin Gallouédec <quentin.gallouedec@huggingface.co>
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
fixes #2106