Skip to main content

Fine-Tuning

Fine-Tuning manages training jobs that adapt a base model to your data. Use this resource to create and monitor jobs, stream events, and deploy the resulting model.

Access it as client.fine_tuning on a Strongly client, or the same path on AsyncStrongly with await. All methods exist on both with identical signatures.

Methods​

All methods​

base_models​

base_models() -> list[FineTuningBaseModel]

List the fine-tuning catalog: every base model a job can use.

A job on any other model is refused. Each model has its provider, family, size, context_length, description, recommended, capabilities, supported_methods, lora_requirements (the least GPU memory, CPU, RAM and storage a LoRA fine-tune needs) and serving (what a model fine-tuned from it is deployed with).

create_job​

create_job(*, name: str, base_model: str, training_dataset: str, volume_id: str | None = None, data_version: int | None = None, url_volume_id: str | None = None, output_volume_id: str | None = None, output_volume_name: str | None = None, description: str | None = None, validation_file: str | None = None, dataset_format: str | None = None, epochs: int | None = None, batch_size: int | None = None, training_method: str | None = None, learning_rate: float | None = None, gpu_count: int | None = None, gpu_type: str | None = None, use_spot: bool | None = None, spot_fallback: bool | None = None, hyperparameters: Mapping[str, Any] | None = None, suffix: str | None = None) -> FineTuningJob

Create a new fine-tuning job.

The trained model is written to a shared volume: an existing one (output_volume_id) or a new one the platform creates (output_volume_name). Give exactly one.

Every training row must fit the job's max length (2048 of the base model's tokens unless set). Rows are never cut: the job's first step measures every row before any GPU starts, and a longer row stops the job with status validation_failed; its status message and its validation logs (job_logs(job_id, log_type="validation")) name each such row, its length and the max.

A size is the whole workload: Strongly's helper services beside it (sign-in proxy, outbound proxy, data volume mounts, model cache upload, metrics) are taken out of it, never added on top (set 4 GB and the workload uses 4 GB in total). A size too small to hold them is refused naming them. A CPU, memory, GPU count or disk above the largest allowed machine's room for one workload raises APIError with status_code 400 naming the resource and both figures, and nothing is created or changed. Check client.compute.list_pools() allowed_sizes (max_cpu, max_memory_gib, max_disk_gib, max_gpus) before a large size.

Parameters

  • name (str): Job name.
  • base_model (str): Base HuggingFace model to fine-tune (self-hosted only).
  • training_dataset (str): The training dataset: an hf://org/dataset id or an https URL (both with url_volume_id), or, with volume_id, a file's path in that shared volume's data half (a file uploaded there, or a Data Forge export). An hf:// dataset of any size is saved to url_volume_id as the job starts, under datasets/huggingface/<org>/<dataset>/, with the job owner's HuggingFace token (Profile > Integrations > HuggingFace Token), and the job trains from it there; a gated or private dataset needs that token with access granted on huggingface.co.
  • volume_id (str | None, optional): The shared volume whose data half holds training_dataset: your own shared volume or one shared with you (an unshared project volume stays in its project).
  • data_version (int | None, optional): The volume data version to read the file at (default: latest).
  • url_volume_id (str | None, optional): For an hf:// or https training_dataset (required): the shared volume (one you may write) the dataset is saved to before the job reads it.
  • output_volume_id (str | None, optional): The shared volume the trained model is written to, one you may write. Give this or output_volume_name.
  • output_volume_name (str | None, optional): The name of a new shared volume to create for the trained model.
  • description (str | None, optional): Optional description.
  • validation_file (str | None, optional): Validation dataset id or path.
  • dataset_format (str | None, optional): Dataset format, e.g. "chatml" (Data Forge exports), "alpaca", "sharegpt", or "jsonl". If omitted the trainer expects instruction/output JSONL.
  • epochs (int | None, optional): Number of training epochs.
  • batch_size (int | None, optional): Per-device training batch size.
  • training_method (str | None, optional): "lora" (default) or "qlora".
  • learning_rate (float | None, optional): Learning rate (e.g. 2e-4).
  • gpu_count (int | None, optional): GPUs to train on, 1 to 8 (1 when omitted). Fine-tuning trains on NVIDIA GPUs only: 0 is refused.
  • gpu_type (str | None, optional): The GPU type (required by the server). One of the types list_gpu_options lists (the admin Compute selection); any other is refused with a 400 ValidationError.
  • use_spot (bool | None, optional): True trains on spot capacity (cheaper; when it is reclaimed, training resumes from its last checkpoint).
  • spot_fallback (bool | None, optional): With use_spot: True (the API's default) falls back to on-demand capacity when no spot is available; False waits for spot.
  • hyperparameters (Mapping[str, Any] | None, optional): Free-form extra trainer overrides, merged into the training config (e.g. {"weight_decay": 0.01}).
  • suffix (str | None, optional): Suffix for the resulting model name.

delete_job​

delete_job(job_id: str) -> None

Delete a fine-tuning job.

deploy_model​

deploy_model(job_id: str, **kwargs) -> AIModel

Deploy the fine-tuned model from a completed job as a self-hosted model.

Returns the model it made (the request is accepted, 202); poll client.ai.models.status until it is running.

Parameters

  • job_id (str): The fine-tuning job ID.
  • **kwargs (Any): Deployment parameters, written Pythonically: deployment_name (required), gpu_type, tensor_parallel_size, scheduling, max_tokens (the context length to serve it with: at most the base model's context window, which it defaults to; required when the base model's Hugging Face config records none), and use_spot (run on spot capacity) with spot_fallback (True, the API's default, falls back to on-demand when spot is unavailable; False waits for spot).

hardware​

hardware() -> list[FineTuningHardware]

Get available hardware options for fine-tuning.

job_logs​

job_logs(job_id: str, *, log_type: str | None = None) -> list[FineTuningLogLine]

Get a fine-tuning job's logs from one source, oldest first.

Parameters

  • job_id (str): The fine-tuning job ID.
  • log_type (str | None, optional): The logs' source: build, validation (the dataset checks before training), training, deploy, or all. The platform reads training when none is given.

job_metrics​

job_metrics(job_id: str) -> list[FineTuningMetric]

Get fine-tuning job metrics (loss, accuracy, etc.).

job_status​

job_status(job_id: str) -> FineTuningJobStatus

Get a fine-tuning job's lifecycle status, synced live from the gateway.

Parameters

  • job_id (str): The fine-tuning job ID.

Returns

  • FineTuningJobStatus: job_id, status, phase (its status message), progress, error, started_at, completed_at and updated_at.

list_jobs​

list_jobs(*, status: str | None = None, base_model: str | None = None, search: str | None = None, limit: int | None = None) -> SyncPaginator[FineTuningJobSummary]

List fine-tuning jobs with pagination and filtering.

Parameters

  • status (str | None, optional): Filter by job status.
  • base_model (str | None, optional): Filter by base model name.
  • search (str | None, optional): Search by name, description, or base model.
  • limit (int | None, optional): Maximum number of items to return (default: all matching items).

model_requirements​

model_requirements(base_model: str, *, method: str | None = None) -> ModelRequirements

Get the hardware and VRAM a base model needs to be fine-tuned.

Parameters

  • base_model (str): The base model id (from base_models).
  • method (str | None, optional): A training method (lora, qlora, full) for its own requirements.

recommend​

recommend(base_model: str, *, use_case: str | None = None, dataset_size: int | None = None) -> FineTuningRecommendation

Get a recommended configuration (method, hyperparameters, hardware) for a base model.

Parameters

  • base_model (str): The base model id (from base_models).
  • use_case (str | None, optional): The intended use: chat (the platform's default), instruction, classification and so on.
  • dataset_size (int | None, optional): The number of training examples.

restart_job​

restart_job(job_id: str) -> FineTuningJob

Restart a fine-tuning job; returns the job.

retrieve_job​

retrieve_job(job_id: str) -> FineTuningJob

Get a single fine-tuning job by ID.

stats​

stats() -> FineTuningStats

Count the fine-tuning jobs you may use: total, active, completed and failed.

stop_job​

stop_job(job_id: str) -> FineTuningJob

Stop a running fine-tuning job; returns the job.

validate_config​

validate_config(base_model: str, *, method: str, hardware: Mapping[str, Any] | None = None, method_config: Mapping[str, Any] | None = None) -> FineTuningValidation

Check a fine-tuning configuration before create_job.

Parameters

  • base_model (str): The base model id.
  • method (str): The training method: lora, qlora or full.
  • hardware (Mapping[str, Any] | None, optional): The target hardware, e.g. {"gpu_type": "A100", "gpu_count": 1}.
  • method_config (Mapping[str, Any] | None, optional): Method settings, e.g. {"bits": 4} for qlora.

Returns

  • FineTuningValidation: valid, errors and warnings.