-
Notifications
You must be signed in to change notification settings - Fork 16
Migrate train_on_inputs to sft-specific params #297
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
Open
connermanuel
wants to merge
3
commits into
main
Choose a base branch
from
cmanuel/eng-24978-move-train_on_inputs-to-the-parameters-of-sft-training
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -77,7 +77,7 @@ def create_finetune_request( | |||||
wandb_base_url: str | None = None, | ||||||
wandb_project_name: str | None = None, | ||||||
wandb_name: str | None = None, | ||||||
train_on_inputs: bool | Literal["auto"] = "auto", | ||||||
train_on_inputs: bool | Literal["auto"] | None = None, | ||||||
training_method: str = "sft", | ||||||
dpo_beta: float | None = None, | ||||||
from_checkpoint: str | None = None, | ||||||
|
@@ -174,6 +174,18 @@ def create_finetune_request( | |||||
f"training_method must be one of {', '.join(AVAILABLE_TRAINING_METHODS)}" | ||||||
) | ||||||
|
||||||
if train_on_inputs is not None and training_method != "sft": | ||||||
raise ValueError("train_on_inputs is only supported for SFT training") | ||||||
|
||||||
if train_on_inputs is None and training_method == "sft": | ||||||
log_warn_once( | ||||||
"train_on_inputs is not set for SFT training, it will be set to 'auto' automatically" | ||||||
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.
Suggested change
|
||||||
) | ||||||
train_on_inputs = "auto" | ||||||
|
||||||
if dpo_beta is not None and training_method != "dpo": | ||||||
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. Other option might be just a warning. What do you think? |
||||||
raise ValueError("dpo_beta is only supported for DPO training") | ||||||
|
||||||
lr_scheduler: FinetuneLRScheduler | ||||||
if lr_scheduler_type == "cosine": | ||||||
if scheduler_num_cycles <= 0.0: | ||||||
|
@@ -191,8 +203,10 @@ def create_finetune_request( | |||||
lr_scheduler_args=LinearLRSchedulerArgs(min_lr_ratio=min_lr_ratio), | ||||||
) | ||||||
|
||||||
training_method_cls: TrainingMethodSFT | TrainingMethodDPO = TrainingMethodSFT() | ||||||
if training_method == "dpo": | ||||||
training_method_cls: TrainingMethodSFT | TrainingMethodDPO | ||||||
if training_method == "sft": | ||||||
training_method_cls = TrainingMethodSFT(train_on_inputs=train_on_inputs) | ||||||
elif training_method == "dpo": | ||||||
training_method_cls = TrainingMethodDPO(dpo_beta=dpo_beta) | ||||||
|
||||||
finetune_request = FinetuneRequest( | ||||||
|
@@ -214,7 +228,6 @@ def create_finetune_request( | |||||
wandb_base_url=wandb_base_url, | ||||||
wandb_project_name=wandb_project_name, | ||||||
wandb_name=wandb_name, | ||||||
train_on_inputs=train_on_inputs, | ||||||
training_method=training_method_cls, | ||||||
from_checkpoint=from_checkpoint, | ||||||
) | ||||||
|
@@ -319,7 +332,7 @@ def create( | |||||
wandb_name: str | None = None, | ||||||
verbose: bool = False, | ||||||
model_limits: FinetuneTrainingLimits | None = None, | ||||||
train_on_inputs: bool | Literal["auto"] = "auto", | ||||||
train_on_inputs: bool | Literal["auto"] | None = None, | ||||||
training_method: str = "sft", | ||||||
dpo_beta: float | None = None, | ||||||
from_checkpoint: str | None = None, | ||||||
|
@@ -364,12 +377,12 @@ def create( | |||||
Defaults to False. | ||||||
model_limits (FinetuneTrainingLimits, optional): Limits for the hyperparameters the model in Fine-tuning. | ||||||
Defaults to None. | ||||||
train_on_inputs (bool or "auto"): Whether to mask the user messages in conversational data or prompts in instruction data. | ||||||
train_on_inputs (bool or "auto", optional): Whether to mask the user messages in conversational data or prompts in instruction data. | ||||||
"auto" will automatically determine whether to mask the inputs based on the data format. | ||||||
For datasets with the "text" field (general format), inputs will not be masked. | ||||||
For datasets with the "messages" field (conversational format) or "prompt" and "completion" fields | ||||||
(Instruction format), inputs will be masked. | ||||||
Defaults to "auto". | ||||||
Defaults to None, or "auto" if training_method is "sft" (set in create_finetune_request). | ||||||
training_method (str, optional): Training method. Defaults to "sft". | ||||||
Supported methods: "sft", "dpo". | ||||||
dpo_beta (float, optional): DPO beta parameter. Defaults to None. | ||||||
|
@@ -707,7 +720,7 @@ async def create( | |||||
wandb_name: str | None = None, | ||||||
verbose: bool = False, | ||||||
model_limits: FinetuneTrainingLimits | None = None, | ||||||
train_on_inputs: bool | Literal["auto"] = "auto", | ||||||
train_on_inputs: bool | Literal["auto"] | None = None, | ||||||
training_method: str = "sft", | ||||||
dpo_beta: float | None = None, | ||||||
from_checkpoint: str | None = None, | ||||||
|
@@ -757,7 +770,7 @@ async def create( | |||||
For datasets with the "text" field (general format), inputs will not be masked. | ||||||
For datasets with the "messages" field (conversational format) or "prompt" and "completion" fields | ||||||
(Instruction format), inputs will be masked. | ||||||
Defaults to "auto". | ||||||
Defaults to None, or "auto" if training_method is "sft" (set in create_finetune_request). | ||||||
training_method (str, optional): Training method. Defaults to "sft". | ||||||
Supported methods: "sft", "dpo". | ||||||
dpo_beta (float, optional): DPO beta parameter. Defaults to None. | ||||||
|
This file contains hidden or 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
This file contains hidden or 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
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.
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.
formatting only