Fine-Tuning
Lists the caller's training jobs, newest first.#
/lmkit/v1/training/jobsResponses
| Status | Type | Description |
|---|---|---|
| 200 | [] | OK |
curl -X GET "$LMKIT_ONE_URL/lmkit/v1/training/jobs" \
-H "Authorization: Bearer $LMKIT_API_KEY"Starts a LoRA fine-tuning job.#
/lmkit/v1/training/jobsFine-tunes a base model on the supplied conversations using LoRA and produces a GGUF artifact (a small adapter, or the base merged with the adapter). Training runs in the background, one job at a time; poll GET /lmkit/v1/training/jobs/ for live loss and status, and download the result from /lmkit/v1/training/jobs//artifact when complete.
Request body
application/json ·
| Property | Type | Description |
|---|---|---|
model | string | Identifier of the base model to fine-tune. If omitted, the default chat model is used. |
stage | string | Training stage: 'sft' (default) fine-tunes on chat conversations with the chat template applied; 'pretrain' continues pre-training on raw text (assistant-only masking does not apply). |
raw_text | string | Raw training text for the 'pretrain' stage. Combined with any uploaded dataset file. |
dataset | [] | Inline training samples as conversations. Each item is a list of role/content messages; assistant turns are supervised. Provide this or dataset_file_id. |
dataset_file_id | string | File id (from /lmkit/v1/files/upload) of a dataset to train on: JSONL chat, ShareGPT, Alpaca, plain text, or a ZIP archive of these. Format is auto-detected. Provide this or dataset. |
rank | object (int32) | LoRA rank (inner dimension of the adapter). Higher adds capacity and size. Default 8. |
alpha | object (float) | LoRA alpha scaling factor. Effective scale is alpha/rank. Default 16. |
target_modules | string | Which modules receive adapters: 'attention' (default), 'attention_and_feedforward', or 'all'. |
epochs | object (int32) | Number of passes over the training set. Default 3. |
learning_rate | object (float) | Initial AdamW learning rate. Default 1e-4. |
gradient_accumulation | object (int32) | Samples accumulated per optimizer step: gradients combine across this many samples before the weights update, multiplying the effective batch size at flat memory. 1 steps on every sample. |
use_rslora | boolean | Rank-stabilized LoRA: scales the adapter by alpha/sqrt(rank) instead of alpha/rank, keeping higher ranks trainable. The scaling folds into the saved artifact. |
lr_schedule | string | Learning-rate schedule: 'cosine' (default), 'constant', 'linear', 'cosine_with_restarts', or 'polynomial'. |
weight_decay | object (float) | AdamW weight decay. |
max_grad_norm | object (float) | Gradient clipping by global norm before each optimizer step. Default 1.0; 0 disables clipping. |
min_learning_rate | object (float) | Floor the decaying schedules approach. Ignored by the constant schedule. |
warmup_ratio | object (float) | Fraction of steps spent warming the learning rate up from zero. Default 0. |
validation_split | object (float) | Fraction of samples held out for per-epoch validation. Default 0.05. |
assistant_loss_only | boolean | Compute loss only on assistant tokens (standard for instruction tuning). Default true. |
sequence_packing | boolean | Pack consecutive short samples into shared training windows. Loss never crosses a sample boundary; image samples are never packed. Default false. |
seed | object (uint32) | Seed for reproducible adapter initialization. 0 means non-deterministic. |
cutoff_length | object (int32) | Maximum tokens per training sequence (the training window). Samples longer than this are skipped, and every sample is padded to it during packing. 0 (the default) sizes the window to the longest sample. |
checkpoint_steps | object (int32) | Save a training checkpoint (adapter weights + optimizer state) every N optimizer steps, enabling resume. 0 disables checkpointing. |
early_stopping_patience | object (int32) | Stop the run after this many validation passes without improvement, keeping everything trained so far. Requires a validation split. 0 disables early stopping. |
artifact_from_best | boolean | Produce the artifact from the weights at the BEST validation loss instead of the last step: the run snapshots the adapter whenever validation improves. Requires a validation split. |
micro_batch | object (int32) | Tokens evaluated per training micro-batch. Smaller values cut activation memory linearly; larger values run faster when memory allows. 0 (the default) picks 512 or 256 to divide the window. |
lora_plus_ratio | object (float) | LoRA+ learning-rate ratio: the zero-initialized B matrices train at this multiple of the base learning rate, which speeds convergence at unchanged memory. 16 is the common value; 0 (the default) trains both sides at the base rate. |
neftune_alpha | object (float) | NEFTune noise alpha: training adds uniform noise scaled by alpha over sqrt(tokens x embedding width) onto the input embeddings, a regularizer that counters overfitting on small datasets. Validation always runs without noise. 5 is the paper's default; 0 (the default) disables it. |
first_layer | object (int32) | First transformer block that receives adapters, inclusive. 0 (the default) starts at the first block. Restricting the range cuts adapter memory and backward compute proportionally. |
last_layer | object (int32) | Last transformer block that receives adapters, inclusive. 0 (the default) extends to the last block. |
full_precision | boolean | Train from the model's full-precision (F16/BF16) variant when its repository publishes one, downloading it on first use. Ignored for custom paths and models with no published variant. |
merge_quantization | string | For merged-model output: quantize the merged GGUF to this precision (q4_k_m, q5_k_m, or q8_0). Empty keeps the merge at the base's precision. Ignored for adapter output. |
output | string | Artifact to produce: 'adapter' (default, a small LoRA GGUF) or 'model' (base merged with the adapter). |
Responses
| Status | Type | Description |
|---|---|---|
| 202 | Accepted | |
| 400 | Bad Request |
curl -X POST "$LMKIT_ONE_URL/lmkit/v1/training/jobs" \
-H "Authorization: Bearer $LMKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "",
"stage": "string",
"raw_text": "string",
"dataset": [
{
"messages": [
{
"role": "...",
"content": "..."
}
]
}
]
}'Gets the status and live metrics of a training job.#
/lmkit/v1/training/jobs/{jobId}Parameters
| Name | In | Type | Description |
|---|---|---|---|
jobIdrequired | path | string | The training job identifier. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | OK | |
| 404 | Not Found |
curl -X GET "$LMKIT_ONE_URL/lmkit/v1/training/jobs/$JOBID" \
-H "Authorization: Bearer $LMKIT_API_KEY"Requests cancellation of a training job.#
/lmkit/v1/training/jobs/{jobId}/cancelTraining halts after the current batch; the partially-trained adapter is still saved.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
jobIdrequired | path | string | The training job identifier. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | OK | |
| 404 | Not Found |
curl -X POST "$LMKIT_ONE_URL/lmkit/v1/training/jobs/$JOBID/cancel" \
-H "Authorization: Bearer $LMKIT_API_KEY"Downloads a completed job's GGUF artifact (adapter or merged model).#
/lmkit/v1/training/jobs/{jobId}/artifactParameters
| Name | In | Type | Description |
|---|---|---|---|
jobIdrequired | path | string | The training job identifier. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | application/octet-stream | OK |
| 404 | Not Found |
curl -X GET "$LMKIT_ONE_URL/lmkit/v1/training/jobs/$JOBID/artifact" \
-H "Authorization: Bearer $LMKIT_API_KEY"