Skip to content

FinetuningRun

FinetuningRun

FinetuningRun(
    id: Optional[str] = None,
    trained_model_name: Optional[str] = None,
)

Class to represent a single finetuning run.

Examples:

Instantiate a new fine-tuning run and stream logs

from baseten.training import FinetuningRun

my_run = FinetuningRun.create(
    trained_model_name="My Model",
    fine_tuning_config=config
)
my_run.stream_logs()

Access an existing fine-tuning run

from baseten.training import FinetuningRun

my_run = FinetuningRun("RUN_ID")

Initialize the object with the given id.

Parameters:

Name Type Description Default
id Optional[str]

The ID of the FinetuningRun on Blueprint

None
trained_model_name Optional[str]

Name of the FinetuningRun on Blueprint

None

status property

status: str

Get the status of your FinetuningRun. Statuses are:

  1. PENDING: The run has not yet started
  2. RUNNING: The run is actively fine-tuning the model
  3. SUCCEEDED: The run is finished and fine-tuned the model
  4. FAILED: The run hit an error and did not fine-tune the model
  5. CANCELLED: The run was cancelled by a user

Example

my_run = FinetuningRun("RUN_ID")
my_run.status

blueprint_url property

blueprint_url: str

Link to view this FinetuningRun in the Blueprint UI

Example:

from baseten.training import FinetuningRun

my_run = FinetuningRun("RUN_ID")
my_run.blueprint_url

is_pending property

is_pending: bool

Is the run pending (waiting to start)

is_running property

is_running: bool

Is the run running (actively fine-tuning the model)

is_succeeded property

is_succeeded: bool

Has the run succeeded (finished fine-tuning the model)

is_failed property

is_failed: bool

Has the run failed (errored and stopped running)

is_cancelled property

is_cancelled: bool

Was the run cancelled (terminated by the user)

create staticmethod

create(
    trained_model_name: str,
    fine_tuning_config: FinetuningConfig,
    auto_deploy: bool = True,
    verbose: bool = True,
) -> Optional[FinetuningRun]

Fine-tune a model by creating a FinetuningRun

Example:

from baseten.training import FinetuningRun

my_run = FinetuningRun.create(
    trained_model_name="My Model",
    fine_tuning_config=config
)

Parameters:

Name Type Description Default
trained_model_name str

The name you want your fine-tuned model to have

required
fine_tuning_config FinetuningConfig

The configuration for the fine-tuning process

required
auto_deploy bool

Flag for whether or not the model should be deployed after finetuning is complete.

True
verbose bool

Toggle this for verbose output

True

Returns:

Name Type Description
FinetuningRun Optional[FinetuningRun]

The newly created FinetuningRun on Blueprint

list staticmethod

list() -> List[FinetuningRun]

List all finetuning runs for user.

Example

from baseten.training import FinetuningRun

FinetuningRun.list()

stream_logs

stream_logs()

Stream logs from the FinetuningRun.

deploy

deploy(
    idle_time_minutes: int = 30, verbose: bool = True
) -> FoundationalModel

Deploy the fine-tuned model created during the FinetuningRun

Example

from baseten.training import FinetuningRun

my_run = FinetuningRun("RUN_ID")
# After the run is finished
my_run.deploy()

Parameters:

Name Type Description Default
idle_time_minutes int

How long the deployed model should wait between invocations before scaling resources to zero

30
verbose bool

Toggle this for verbose output

True

Returns:

Name Type Description
StableDiffusionPipeline FoundationalModel

A model object using the finetuning run results

cancel

cancel() -> bool

Cancels this FinetuningRun.

Example

from baseten.training import FinetuningRun

my_run = FinetuningRun("RUN_ID")
# While the run is still going
my_run.cancel()

Returns:

Name Type Description
bool bool

True if the run was successfully canceled