Fine tuning

Create job

POST
/fine-tunes

Create a fine-tuning job with the provided model and training data.

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Request Body

application/json

training_file*string

File-ID of a training file uploaded to the Together API

validation_file?string

File-ID of a validation file uploaded to the Together API

packing?boolean

Whether to use sequence packing for training. This flag has no effect if the training data is in Parquet format.

Defaulttrue
max_seq_length?integer

Maximum sequence length to use for training. If not specified, the maximum allowed for the model and training method will be used.

model*string

Name of the base model to run fine-tune job on

n_epochs?integer

Number of complete passes through the training dataset (higher values may improve results but increase cost and risk of overfitting)

Default1
n_checkpoints?integer

Number of intermediate model versions saved during training for evaluation

Rangevalue <= 10
Default1
n_evals?integer

Number of evaluations to be run on a given validation set during training

Default0
batch_size?|

Number of training examples processed together (larger batches use more memory but may train faster). Defaults to "max". We use training optimizations like packing, so the effective batch size may be different than the value you set.

Default"max"
gradient_accumulation_steps?integer

Number of steps to accumulate gradients before performing a weight update. If omitted or set to 0, the model default is used.

Range0 <= value
learning_rate?number

Controls how quickly the model adapts to new information (too high may cause instability, too low may slow convergence)

Default0.00001
lr_scheduler?

The learning rate scheduler to use. It specifies how the learning rate is adjusted during training.

Default"none"
warmup_ratio?number

The percent of steps at the start of training to linearly increase the learning rate.

Default0
max_grad_norm?number

Max gradient norm to be used for gradient clipping. Set to 0 to disable.

Default1
weight_decay?number

Weight decay. Regularization parameter for the optimizer.

Default0
random_seed?integer

Random seed for reproducible training. When set, the same seed produces the same run (e.g. data shuffle, init). If omitted or null, the server applies its default seed (e.g. 42).

early_stopping_enabled?boolean

Whether to stop training early when validation loss stops improving. Requires a validation_file, and n_evals must be at least early_stopping_patience + early_stopping_warmup_evals + 1 so a plateau can be detected.

Defaultfalse
early_stopping_patience?integer

Number of consecutive evaluations with no improvement in validation loss to allow before stopping. Only applies when early_stopping_enabled is true.

Range1 <= value
Default2
early_stopping_min_delta?number

Minimum decrease in validation loss for an evaluation to count as an improvement. Larger values treat small gains as non-improvements, causing training to stop sooner. Only applies when early_stopping_enabled is true.

Range0 <= value
Default0
early_stopping_warmup_evals?integer

Number of initial evaluations excluded from the early-stopping decision. These still establish the baseline validation loss but do not count toward patience. Set to 0 to disable warmup; if omitted, defaults to 1. Only applies when early_stopping_enabled is true.

Range0 <= value
Default1
suffix?string

Suffix to add to your fine-tuned model name. Must be at most 64 characters long.

Lengthlength <= 64
wandb_api_key?string

Integration key for tracking experiments and model metrics on W&B platform

wandb_base_url?string

The base URL of a dedicated Weights & Biases instance.

wandb_project_name?string

The Weights & Biases project for your run. If not specified, uses together as the project name.

wandb_name?string

The Weights & Biases name for your run.

wandb_entity?string

The Weights & Biases entity for your run.

train_on_inputs?|
Deprecated

Whether to mask user messages in conversational data or prompts in instruction data.

Default"auto"
training_method?|

The training method to use. 'sft' for Supervised Fine-Tuning or 'dpo' for Direct Preference Optimization.

training_type?|

The training type to use. Defaults to LoRA if not provided.

Defaultnull
multimodal_params?
from_checkpoint?string

The checkpoint identifier to continue training from a previous fine-tuning job. Format is {$JOB_ID} or {$OUTPUT_MODEL_NAME} or {$JOB_ID}:{$STEP} or {$OUTPUT_MODEL_NAME}:{$STEP}. The step value is optional; without it, uses the final checkpoint.

from_hf_model?string

The Hugging Face Hub repo to start training from. Should be as close as possible to the base model (specified by the model argument) in terms of architecture and size.

hf_model_revision?string

The revision of the Hugging Face Hub model to continue training from. E.g., hf_model_revision=main (default, used if the argument is not provided) or hf_model_revision='607a30d783dfa663caf39e06633721c8d4cfcd7e' (specific commit).

hf_api_token?string

The API token for the Hugging Face Hub.

hf_output_repo_name?string

The name of the Hugging Face repository to upload the fine-tuned model to.

Response Body

application/json

application/json

curl -X POST "https://example.com/fine-tunes" \  -H "Content-Type: application/json" \  -d '{    "training_file": "string",    "model": "string"  }'
{  "id": "string",  "status": "pending",  "created_at": "2019-08-24T14:15:22Z",  "updated_at": "2019-08-24T14:15:22Z",  "started_at": "2019-08-24T14:15:22Z",  "user_id": "string",  "owner_address": "string",  "total_price": 0,  "token_count": 0,  "events": [    {      "object": "fine-tune-event",      "created_at": "string",      "level": null,      "message": "string",      "type": "job_pending",      "param_count": 0,      "token_count": 0,      "total_steps": 0,      "wandb_url": "string",      "step": 0,      "checkpoint_path": "string",      "model_path": "string",      "tokenized_dataset_path": "string",      "early_stopping_best_step": 0,      "early_stopping_best_metric_value": 0    }  ],  "training_file": "string",  "validation_file": "string",  "packing": true,  "max_seq_length": 0,  "model": "string",  "model_output_name": "string",  "suffix": "string",  "n_epochs": 0,  "n_evals": 0,  "n_checkpoints": 0,  "batch_size": 0,  "training_type": {    "type": "Full"  },  "training_method": {    "method": "sft",    "train_on_inputs": "auto"  },  "learning_rate": 0,  "lr_scheduler": {    "lr_scheduler_type": "linear",    "lr_scheduler_args": {      "min_lr_ratio": 0    }  },  "warmup_ratio": 0,  "max_grad_norm": 0,  "weight_decay": 0,  "random_seed": 0,  "wandb_project_name": "string",  "wandb_name": "string",  "from_checkpoint": "string",  "from_hf_model": "string",  "hf_model_revision": "string",  "progress": {    "estimate_available": true,    "seconds_remaining": 0  },  "early_stopped": true,  "early_stopping_best_step": 0,  "early_stopping_best_metric": 0}