LLM fine-tuning
Fine-tune a chat LLM that is on the server with your own prompt and answer data. After reading this page you can start training in Build › LLM fine-tuning, compare answers before and after training, and start the merged model in Playground as a test serving. The end of the page shows how to run the same training from code.
What gets trained
Section titled “What gets trained”The only method is SFT-LoRA. The base model's weights stay frozen, and only a small add-on (the adapter) learns from your prompt and answer examples. When training ends, the adapter is saved as an output model. An adapter cannot be served on its own, so you create a merged model that combines it with the base model and serve that.
The whole flow is: prepare a base model → prepare data → settings → training → compare before and after → merge → test serving. Training is an ordinary run sent to the GPU queue, so it also shows up in the experiments page, run comparison, lineage and notifications.
Prepare
Section titled “Prepare”Base model
Section titled “Base model”The base model must be a chat (Instruct) LLM. It needs safetensors weights, config files, a tokenizer and a chat template. Models that need their own code (.py files or auto_map in config.json) cannot be picked.
Bring base models onto the server with Start › Imports. Download a Hugging Face model pinned to a commit, or, on a server without internet access, upload a model folder or zip from the browser. Administrators can also import from the server console with install.sh import-model. Imported models are registered as published models and appear in the fine-tuning base model list right away. Datasets covers the import steps. A merged model from an earlier fine-tune can be picked as a base model again.
Base models have a size cap. The default is 15B (billion parameters), and larger models cannot be picked. Administrators change it in Base model size limit under Settings › LLM fine-tuning. Raising the cap above 15B can leave the server short of memory when the model loads.
Training environment
Section titled “Training environment”Fine-tuning runs in an LLM training environment that an administrator has registered on the server. If the training environment or a base model is not ready, Build › LLM fine-tuning shows 'Fine-tuning is not ready on this device' and the reasons at the top. An administrator registers it as described in 'Register the LLM training environment' in Install, update and back up.
Training data is one .jsonl file inside a dataset version. A .json array file also works. That version must be mounted on the server. Datasets covers uploading and mounting.
There are three formats, detected automatically. Write one example per line.
{"messages": [{"role": "system", "content": "Answer briefly."}, {"role": "user", "content": "What is LoRA?"}, {"role": "assistant", "content": "A method that keeps the base weights and trains only small extra weights."}]}system may appear once, at the start. user and assistant alternate, and the last message is assistant.
{"instruction": "Summarize the following sentence in one line.", "input": "…", "output": "…"}input is optional.
{"prompt": "What is 3 times 7?", "completion": "21"}Train in the UI
Section titled “Train in the UI”Press New fine-tune in Build › LLM fine-tuning. A five-step wizard opens.
-
Base model. Pick one from the list. Each model shows its size in billions of parameters. Models that got warnings in the import check are marked separately.
-
Data. Pick a dataset version and a file, and the Data check runs at once. It shows format errors with line numbers, a preview, the token length distribution and the share of rows longer than the maximum length. If there are errors, fix the file or turn on Skip invalid rows before you can start. Validation ratio sets aside a share for validation (0~0.2, at most 500 rows). With fewer than 20 rows, nothing is set aside.
-
Settings. Pick a Preset to set how much to train. Quick try is 200 steps with a maximum length of 512, Default is 1 epoch and Thorough is 3 epochs. Batch and maximum length are filled in to suit the base model size. In the advanced settings you change LoRA r, alpha, dropout and target, the scheduler and the checkpoint interval. Answer-only loss (on by default) uses the prompt only as context and trains on the last answer's tokens.
-
Eval prompts. The same prompts produce answers before training starts and after it ends, for comparison. Five default prompts are filled in, and you can have up to twenty.
-
Review. Check the memory estimate, estimated time, training environment and queue, then press Start training.
The memory estimate is the value automatic dispatch uses to pick an agent. If the server does not have enough free memory, the training waits in the queue before it starts. The estimated time is an estimate. After one training run with the same base model, it is recalculated from that measurement.
If this is your first time, start from the 'LLM fine-tuning quick try' template in Start › Starter templates. It fills the wizard with a small base model, sample data and the Quick try settings. If that base model is not on the server, an import button appears too.
License check
Section titled “License check”If the base model has a license with a usage policy (a label that starts with llama, gemma, qwen and the like), a research, non-commercial or other license, or no license label, the check box 'I checked this model's usage policy (recorded in the action log)' shows right above Start training. Training starts only after you tick it, and the action log records who confirmed it. This is decided by the license label recorded on the base model, not by the model family.
When an administrator turns on Block restricted licenses in Settings › LLM fine-tuning, only administrators can fine-tune research, non-commercial, other and unlabeled models. This classification exists to show warnings. It is not a legal judgment. Adapters and merged models can carry the base model's license terms.
Watch the training
Section titled “Watch the training”When training starts, the run details open. Progress, the current phase and the loss curve are at the top, and the tabs below are Curves, Answers, Settings, Info and Log. train/loss is the loss on the training data and eval/loss is the loss on the held-out validation data. If the validation loss starts to rise again, suspect overfitting.
Checkpoints pile up during training. If you stopped the training, or it stopped because memory ran short, Resume continues from the last checkpoint. Only the run owner can resume. If you turn on Auto-requeue on low memory in the Review step, a run stopped for low memory goes back on the queue under your name using a proxy key. You can revoke proxy keys at any time in Settings › API credentials. See Checkpoints and resume and Share GPUs and the queue for details.
Compare before and after
Section titled “Compare before and after”The Answers tab shows, for each eval prompt, the prompt, the answer before training and the answer after training side by side. Answers are made with greedy generation. The before answers are saved before training begins. So if training stops halfway, the before answers remain, and a cell with no after answer is left empty with the reason.
Merge and test serving
Section titled “Merge and test serving”When training ends, the adapter is saved as an output model named <run name> 어댑터 (the suffix means adapter). On the models page it has an 'Adapter' chip and a note that it cannot be served as is.
- Press Create merged model in the run details. The model name is optional. A small GPU run merges the adapter into the base model. The merged model is the same size as the base model, so check that the server has enough storage first.
- When the merge ends, press Start in Playground to start it as a test serving. Test serving and the test API covers chat and the test API.
- To let others use it, publish the merged model in Models. Published models appear in every user's list. A draft model can be started only by its creator (or the creator of the run that made it) and administrators.
Fine-tune from code
Section titled “Fine-tune from code”You can call the same runner the studio uses from code. Use it when you process the data yourself or tie training to other code. The training packages the runner needs are only in the LLM training environment, and imported base model folders are visible only inside training jobs on the GPU queue, at /qgon-models/imported/<model name> (read-only). So even from code, send the training to the GPU queue.
-
Bring the shared environment
llm(the LLM training environment) into your workspace. Workspaces and environments shows how. -
Write the training code.
ft_train.py import osimport qgonfrom qgon.finetune import train_hererun = qgon.init(project="llm-finetune", name="ko-qa-sft", auto_log=False)data_dir = qgon.dataset("ko-qa", version="1.0") # returns the mounted folder if the version is mountedspec = {"name": "ko-qa SFT","base_model_id": "<base model id>", # id from the models page"dataset": {"vid": "<dataset version id>", "file": "train.jsonl", "format": "chat"},"lora": {"r": 16},"train": {"epochs": 1, "lr": 2e-4, "max_len": 1024, "batch": 2},"eval": {"prompts": ["Introduce yourself in two sentences."], "max_new_tokens": 128},}res = train_here(spec,"/qgon-models/imported/<model name>", # base model folder as seen inside the jobos.path.join(data_dir, "train.jsonl"))print(res["adapter_dir"]) -
Send it to the GPU queue with the imported environment version. You can also pick that environment in New run in the UI. Run training on the GPU queue explains how.
qgon run --queue gpu --env <environment version> -- python ft_train.py
When called inside a run started with qgon.init(), train_here records checkpoints, the before and after answers, and the adapter output model on that run. The spec keys are the same as the studio settings, and unknown keys are refused. base_model_id and dataset are values kept in the run record, so the folder and file actually read are the second and third arguments. Their format is still checked, and a wrong value stops train_here before training. Put the 32-character model id from the models page in base_model_id and the 32-character dataset version id in dataset.vid, and give dataset.file as a relative .jsonl or .json path. See the qgon.finetune reference for the functions.
To run from folders without a run record, use the runner commands. The base model folder must be readable where you run them.
python -m qgon.finetune local-train --spec spec.json --base <base model folder> --data train.jsonl --out ./ft-outpython -m qgon.finetune local-merge --base <base model folder> --adapter ./ft-out/adapter --out ./mergedThe Create merged model button exists only for runs started in the studio. Merge an adapter trained from code with local-merge.