Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 17 additions & 0 deletions src/together/cli/api/finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,19 @@ def fine_tuning(ctx: click.Context) -> None:
"The format: {$JOB_ID/$OUTPUT_MODEL_NAME}:{$STEP}. "
"The step value is optional, without it the final checkpoint will be used.",
)
@click.option(
"--from-hf-model",
type=str,
default=None,
help="The Hugging Face repo to start training from. "
"Should be paired with the base model, specified in `model` argument.",
)
@click.option(
"--hf-model-revision",
type=str,
default=None,
help="The revision of the Hugging Face model to continue training from.",
)
@click.option(
"--hf-api-token",
type=str,
Expand Down Expand Up @@ -246,6 +259,8 @@ def create(
rpo_alpha: float | None,
simpo_gamma: float | None,
from_checkpoint: str,
from_hf_model: str,
hf_model_revision: str,
hf_api_token: str | None,
hf_output_repo_name: str | None,
) -> None:
Expand Down Expand Up @@ -284,6 +299,8 @@ def create(
rpo_alpha=rpo_alpha,
simpo_gamma=simpo_gamma,
from_checkpoint=from_checkpoint,
from_hf_model=from_hf_model,
hf_model_revision=hf_model_revision,
hf_api_token=hf_api_token,
hf_output_repo_name=hf_output_repo_name,
)
Expand Down
28 changes: 28 additions & 0 deletions src/together/resources/finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def create_finetune_request(
rpo_alpha: float | None = None,
simpo_gamma: float | None = None,
from_checkpoint: str | None = None,
from_hf_model: str | None = None,
hf_model_revision: str | None = None,
hf_api_token: str | None = None,
hf_output_repo_name: str | None = None,
) -> FinetuneRequest:
Expand All @@ -87,6 +89,16 @@ def create_finetune_request(
if model is None and from_checkpoint is None:
raise ValueError("You must specify either a model or a checkpoint")

if from_checkpoint is not None and from_hf_model is not None:
raise ValueError(
"You must specify either a Hugging Face model or a checkpoint to start a job from, not both"
)

if from_hf_model is not None and model is None:
raise ValueError(
"You must specify base model to run a fine-tuning job with a Hugging Face model"
)

model_or_checkpoint = model or from_checkpoint

if warmup_ratio is None:
Expand Down Expand Up @@ -251,6 +263,8 @@ def create_finetune_request(
wandb_name=wandb_name,
training_method=training_method_cls,
from_checkpoint=from_checkpoint,
from_hf_model=from_hf_model,
hf_model_revision=hf_model_revision,
hf_api_token=hf_api_token,
hf_output_repo_name=hf_output_repo_name,
)
Expand Down Expand Up @@ -332,6 +346,8 @@ def create(
rpo_alpha: float | None = None,
simpo_gamma: float | None = None,
from_checkpoint: str | None = None,
from_hf_model: str | None = None,
hf_model_revision: str | None = None,
hf_api_token: str | None = None,
hf_output_repo_name: str | None = None,
) -> FinetuneResponse:
Expand Down Expand Up @@ -390,6 +406,9 @@ def create(
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.
from_hf_model (str, optional): The Hugging Face repo to start training from.
Should be paired with the base model, specified in `model` argument.
hf_model_revision (str, optional): The revision of the Hugging Face model to continue training from. Defaults to None.
hf_api_token (str, optional): API key for the Hugging Face Hub. Defaults to None.
hf_output_repo_name (str, optional): HF repo to upload the fine-tuned model to. Defaults to None.

Expand Down Expand Up @@ -445,6 +464,8 @@ def create(
rpo_alpha=rpo_alpha,
simpo_gamma=simpo_gamma,
from_checkpoint=from_checkpoint,
from_hf_model=from_hf_model,
hf_model_revision=hf_model_revision,
hf_api_token=hf_api_token,
hf_output_repo_name=hf_output_repo_name,
)
Expand Down Expand Up @@ -759,6 +780,8 @@ async def create(
rpo_alpha: float | None = None,
simpo_gamma: float | None = None,
from_checkpoint: str | None = None,
from_hf_model: str | None = None,
hf_model_revision: str | None = None,
hf_api_token: str | None = None,
hf_output_repo_name: str | None = None,
) -> FinetuneResponse:
Expand Down Expand Up @@ -817,6 +840,9 @@ async def create(
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.
from_hf_model (str, optional): The Hugging Face repo to start training from.
Should be paired with the base model, specified in `model` argument.
hf_model_revision (str, optional): The revision of the Hugging Face model to continue training from. Defaults to None.
hf_api_token (str, optional): API key for the Huggging Face Hub. Defaults to None.
hf_output_repo_name (str, optional): HF repo to upload the fine-tuned model to. Defaults to None.

Expand Down Expand Up @@ -872,6 +898,8 @@ async def create(
rpo_alpha=rpo_alpha,
simpo_gamma=simpo_gamma,
from_checkpoint=from_checkpoint,
from_hf_model=from_hf_model,
hf_model_revision=hf_model_revision,
hf_api_token=hf_api_token,
hf_output_repo_name=hf_output_repo_name,
)
Expand Down