LM-Kit OneDocs2026.8.10lm-kit.com
AI Training

Fine-Tuning

Lists the caller's training jobs, newest first.#

GET/lmkit/v1/training/jobs

Responses

StatusTypeDescription
200[]

OK

curl -X GET "$LMKIT_ONE_URL/lmkit/v1/training/jobs" \
  -H "Authorization: Bearer $LMKIT_API_KEY"

Starts a LoRA fine-tuning job.#

POST/lmkit/v1/training/jobs

Fine-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 ·

PropertyTypeDescription
modelstring

Identifier of the base model to fine-tune. If omitted, the default chat model is used.

stagestring

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_textstring

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_idstring

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.

rankobject (int32)

LoRA rank (inner dimension of the adapter). Higher adds capacity and size. Default 8.

alphaobject (float)

LoRA alpha scaling factor. Effective scale is alpha/rank. Default 16.

target_modulesstring

Which modules receive adapters: 'attention' (default), 'attention_and_feedforward', or 'all'.

epochsobject (int32)

Number of passes over the training set. Default 3.

learning_rateobject (float)

Initial AdamW learning rate. Default 1e-4.

gradient_accumulationobject (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_rsloraboolean

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_schedulestring

Learning-rate schedule: 'cosine' (default), 'constant', 'linear', 'cosine_with_restarts', or 'polynomial'.

weight_decayobject (float)

AdamW weight decay.

max_grad_normobject (float)

Gradient clipping by global norm before each optimizer step. Default 1.0; 0 disables clipping.

min_learning_rateobject (float)

Floor the decaying schedules approach. Ignored by the constant schedule.

warmup_ratioobject (float)

Fraction of steps spent warming the learning rate up from zero. Default 0.

validation_splitobject (float)

Fraction of samples held out for per-epoch validation. Default 0.05.

assistant_loss_onlyboolean

Compute loss only on assistant tokens (standard for instruction tuning). Default true.

sequence_packingboolean

Pack consecutive short samples into shared training windows. Loss never crosses a sample boundary; image samples are never packed. Default false.

seedobject (uint32)

Seed for reproducible adapter initialization. 0 means non-deterministic.

cutoff_lengthobject (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_stepsobject (int32)

Save a training checkpoint (adapter weights + optimizer state) every N optimizer steps, enabling resume. 0 disables checkpointing.

early_stopping_patienceobject (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_bestboolean

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_batchobject (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_ratioobject (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_alphaobject (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_layerobject (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_layerobject (int32)

Last transformer block that receives adapters, inclusive. 0 (the default) extends to the last block.

full_precisionboolean

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_quantizationstring

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.

outputstring

Artifact to produce: 'adapter' (default, a small LoRA GGUF) or 'model' (base merged with the adapter).

Responses

StatusTypeDescription
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.#

GET/lmkit/v1/training/jobs/{jobId}

Parameters

NameInTypeDescription
jobIdrequiredpathstring

The training job identifier.

Responses

StatusTypeDescription
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.#

POST/lmkit/v1/training/jobs/{jobId}/cancel

Training halts after the current batch; the partially-trained adapter is still saved.

Parameters

NameInTypeDescription
jobIdrequiredpathstring

The training job identifier.

Responses

StatusTypeDescription
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).#

GET/lmkit/v1/training/jobs/{jobId}/artifact

Parameters

NameInTypeDescription
jobIdrequiredpathstring

The training job identifier.

Responses

StatusTypeDescription
200application/octet-stream

OK

404

Not Found

curl -X GET "$LMKIT_ONE_URL/lmkit/v1/training/jobs/$JOBID/artifact" \
  -H "Authorization: Bearer $LMKIT_API_KEY"