Skip to content
qgonDEV DOCSSDK 0.3.31
ENKR

qgon.finetune

In the appBuild › LLM fine-tuning

The LLM fine-tuning runner.

The training packages (transformers, peft, trl, datasets, accelerate) exist only in the shared training environment image. Importing this module does not load them.

To try it directly in a workspace that uses the shared training environment (the same path as exporting to code and the fine-tuning starter template):

python -m qgon.finetune local-train --spec spec.json --base /qgon-models/imported/qwen2.5-0.5b-instruct \
--data train.jsonl --out ./ft-out [--resume ./ft-out/ckpt/ckpt-000050.tar]
python -m qgon.finetune local-merge --base <base folder> --adapter ./ft-out/adapter --out ./merged
from qgon.finetune import train_here

train_here

functionchanged in 0.3.29

Trains from code (the starter template or exported code): inside a run started with qgon.init() it records checkpoints, before/after samples and the adapter output model on that run and resumes when the run was started with Resume training, otherwise it works like train_local.

train_here(spec, base_dir, data_path, out_dir='outputs')

In the app · Build › LLM fine-tuning

train_local

functionchanged in 0.3.29

Trains in a local folder without recording a run and returns the result as a dict.

train_local(spec, base_dir, data_path, out_dir, resume_tar=None)

In the app · Build › LLM fine-tuning

merge_local

functionchanged in 0.3.29

Merges a LoRA adapter into its base model without recording a run, saves only the safetensors, JSON and tokenizer files in out_dir, and returns an info dict.

merge_local(base_dir, adapter_dir, out_dir)

In the app · Build › LLM fine-tuning

normalize

function

Validates a fine-tuning spec and fills in defaults, returning a new dict; failures raise SpecError naming the field, and params_b (base model size, assumed 7B when unknown) sets the batch and length defaults.

normalize(spec, params_b=None)

In the app · Build › LLM fine-tuning

SpecError

exceptionchanged in 0.3.29

Raised when a fine-tuning spec is invalid (a ValueError); msg holds the message (in Korean) and field the name of the offending field.

SpecError(msg, field=None)

In the app · Build › LLM fine-tuning

SPEC_VERSION

constantchanged in 0.3.29

The fine-tuning spec format version this SDK accepts (the spec's v field).

SPEC_VERSION = 1

In the app · Build › LLM fine-tuning