POST
/
fine-tunes
from together import Together
import os

client = Together(
api_key=os.environ.get("TOGETHER_API_KEY"),
)

response = client.fine_tuning.create(
model="meta-llama/Meta-Llama-3.1-8B-Instruct-Reference",
training_file="file-id"
)

print(response)
{
  "id": "ft-01234567890123456789",
  "status": "completed",
  "created_at": "2023-05-17T17:35:45.123Z",
  "updated_at": "2023-05-17T18:46:23.456Z",
  "user_id": "user_01234567890123456789",
  "owner_address": "[email protected]",
  "total_price": 1500,
  "token_count": 850000,
  "events": [],
  "model": "meta-llama/Llama-2-7b-hf",
  "model_output_name": "mynamespace/meta-llama/Llama-2-7b-hf-32162631",
  "n_epochs": 3,
  "training_file": "file-01234567890123456789",
  "wandb_project_name": "my-finetune-project"
}

Authorizations

Authorization
string
header
default:default
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
training_file
string
required

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

model
string
required

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

validation_file
string

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

n_epochs
integer
default:1

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

n_checkpoints
integer
default:1

Number of intermediate model versions saved during training for evaluation

n_evals
integer
default:0

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

batch_size
default:max

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.

learning_rate
number
default:0.00001

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

lr_scheduler
object

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

warmup_ratio
number
default:0

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

max_grad_norm
number
default:1

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

weight_decay
number
default:0

Weight decay. Regularization parameter for the optimizer.

suffix
string

Suffix that will be added to your fine-tuned model name

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, will use together as the project name.

wandb_name
string

The Weights & Biases name for your run.

train_on_inputs
boolean
default:auto
deprecated

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

training_method
object

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

training_type
object
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, the final checkpoint will be used.

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

200 - application/json

Fine-tuning job initiated successfully

A truncated version of the fine-tune response, used for POST /fine-tunes, GET /fine-tunes and POST /fine-tunes/{id}/cancel endpoints

id
string
required

Unique identifier for the fine-tune job

status
enum<string>
required
Available options:
pending,
queued,
running,
compressing,
uploading,
cancel_requested,
cancelled,
error,
completed
created_at
string<date-time>
required

Creation timestamp of the fine-tune job

updated_at
string<date-time>
required

Last update timestamp of the fine-tune job

user_id
string

Identifier for the user who created the job

owner_address
string

Owner address information

total_price
integer

Total price for the fine-tuning job

token_count
integer

Count of tokens processed

events
object[]

Events related to this fine-tune job

training_file
string

File-ID of the training file

validation_file
string

File-ID of the validation file

model
string

Base model used for fine-tuning

model_output_name
string
suffix
string

Suffix added to the fine-tuned model name

n_epochs
integer

Number of training epochs

n_evals
integer

Number of evaluations during training

n_checkpoints
integer

Number of checkpoints saved during training

batch_size
integer

Batch size used for training

training_type
object

Type of training used (full or LoRA)

training_method
object

Method of training used

learning_rate
number

Learning rate used for training

lr_scheduler
object

Learning rate scheduler configuration

warmup_ratio
number

Ratio of warmup steps

max_grad_norm
number

Maximum gradient norm for clipping

weight_decay
number

Weight decay value used

wandb_project_name
string

Weights & Biases project name

wandb_name
string

Weights & Biases run name

from_checkpoint
string

Checkpoint used to continue training

from_hf_model
string

Hugging Face Hub repo to start training from

hf_model_revision
string

The revision of the Hugging Face Hub model to continue training from