Skip to content

Add rpo alpha #307

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
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build-backend = "poetry.masonry.api"

[tool.poetry]
name = "together"
version = "1.5.7"
version = "1.5.8"
authors = ["Together AI <support@together.ai>"]
description = "Python client for Together's Cloud Platform!"
readme = "README.md"
Expand Down
9 changes: 9 additions & 0 deletions src/together/cli/api/finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ def fine_tuning(ctx: click.Context) -> None:
default=0.1,
help="Beta parameter for DPO training (only used when '--training-method' is 'dpo')",
)
@click.option(
"--rpo-alpha",
type=float,
default=None,
help="RPO alpha to control the weight of NLL loss component for chosen responses "
"(only used when '--training-method' is 'dpo')",
)
@click.option(
"--suffix",
"-s",
Expand Down Expand Up @@ -206,6 +213,7 @@ def create(
train_on_inputs: bool | Literal["auto"],
training_method: str,
dpo_beta: float,
rpo_alpha: float,
from_checkpoint: str,
) -> None:
"""Start fine-tuning"""
Expand Down Expand Up @@ -239,6 +247,7 @@ def create(
train_on_inputs=train_on_inputs,
training_method=training_method,
dpo_beta=dpo_beta,
rpo_alpha=rpo_alpha,
from_checkpoint=from_checkpoint,
)

Expand Down
9 changes: 8 additions & 1 deletion src/together/resources/finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def create_finetune_request(
train_on_inputs: bool | Literal["auto"] = "auto",
training_method: str = "sft",
dpo_beta: float | None = None,
rpo_alpha: float | None = None,
from_checkpoint: str | None = None,
) -> FinetuneRequest:
if model is not None and from_checkpoint is not None:
Expand Down Expand Up @@ -193,7 +194,7 @@ def create_finetune_request(

training_method_cls: TrainingMethodSFT | TrainingMethodDPO = TrainingMethodSFT()
if training_method == "dpo":
training_method_cls = TrainingMethodDPO(dpo_beta=dpo_beta)
training_method_cls = TrainingMethodDPO(dpo_beta=dpo_beta, rpo_alpha=rpo_alpha)

finetune_request = FinetuneRequest(
model=model,
Expand Down Expand Up @@ -322,6 +323,7 @@ def create(
train_on_inputs: bool | Literal["auto"] = "auto",
training_method: str = "sft",
dpo_beta: float | None = None,
rpo_alpha: float | None = None,
from_checkpoint: str | None = None,
) -> FinetuneResponse:
"""
Expand Down Expand Up @@ -373,6 +375,7 @@ def create(
training_method (str, optional): Training method. Defaults to "sft".
Supported methods: "sft", "dpo".
dpo_beta (float, optional): DPO beta parameter. Defaults to None.
rpo_alpha (float, optional): RPO alpha to control the weight of NLL loss component for chosen responses. Defaults to None.
from_checkpoint (str, optional): The checkpoint identifier to continue training from a previous fine-tuning job.
The format: {$JOB_ID/$OUTPUT_MODEL_NAME}:{$STEP}.
The step value is optional, without it the final checkpoint will be used.
Expand Down Expand Up @@ -425,6 +428,7 @@ def create(
train_on_inputs=train_on_inputs,
training_method=training_method,
dpo_beta=dpo_beta,
rpo_alpha=rpo_alpha,
from_checkpoint=from_checkpoint,
)

Expand Down Expand Up @@ -710,6 +714,7 @@ async def create(
train_on_inputs: bool | Literal["auto"] = "auto",
training_method: str = "sft",
dpo_beta: float | None = None,
rpo_alpha: float | None = None,
from_checkpoint: str | None = None,
) -> FinetuneResponse:
"""
Expand Down Expand Up @@ -761,6 +766,7 @@ async def create(
training_method (str, optional): Training method. Defaults to "sft".
Supported methods: "sft", "dpo".
dpo_beta (float, optional): DPO beta parameter. Defaults to None.
rpo_alpha (float, optional): RPO alpha to control the weight of NLL loss component for chosen responses. Defaults to None.
from_checkpoint (str, optional): The checkpoint identifier to continue training from a previous fine-tuning job.
The format: {$JOB_ID/$OUTPUT_MODEL_NAME}:{$STEP}.
The step value is optional, without it the final checkpoint will be used.
Expand Down Expand Up @@ -813,6 +819,7 @@ async def create(
train_on_inputs=train_on_inputs,
training_method=training_method,
dpo_beta=dpo_beta,
rpo_alpha=rpo_alpha,
from_checkpoint=from_checkpoint,
)

Expand Down
1 change: 1 addition & 0 deletions src/together/types/finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class TrainingMethodDPO(TrainingMethod):

method: Literal["dpo"] = "dpo"
dpo_beta: float | None = None
rpo_alpha: float | None = None


class FinetuneRequest(BaseModel):
Expand Down