Finetune¶
Use client.finetune() to adapt an existing LLM or vision-language model. Fine-tuning
produces a LoRA adapter, which is loaded on top of the base model.
import pandas as pd
data = pd.DataFrame({"text": ["Below is an instruction...\n\n### Response:\n..."]})
job = client.finetune(
model="qwen2.5-0.5b",
training_mode="low", # low | medium | high | custom
data=data,
gpus=1,
time_limit="01:00:00",
)
result = job.run(wait=True)
if result["status"] == "completed":
job.download("./my-model")
Training modes¶
| Mode | Strategy | Precision |
|---|---|---|
low |
QLoRA (rank 8) | 4-bit |
medium |
LoRA (rank 16) | 8-bit on 1 GPU, bf16 on more |
high |
LoRA (rank 64) | bf16 |
custom |
Your settings via config= |
bf16, fp16, 4bit, or 8bit |
Custom configuration¶
For full control, use training_mode="custom" with a config:
job = client.finetune(
model="qwen2.5-0.5b",
training_mode="custom",
data=data,
config={
"batch_size": 2,
"learning_rate": 2e-4,
"scheduler": "cosine",
"n_epoch": 3,
"precision": "bf16",
"lora": {"r": 16, "alpha": 32, "dropout": 0.05},
"max_seq_length": 2048,
"optimizer": "adamw_torch",
"n_checkpoint": 100,
"n_evals": 0,
"seed": 42,
},
)
gpus, gpu_type, and time_limit are passed as arguments, not inside config. Reported accuracy is
token-level accuracy. Setting n_evals above 0 requires an evaluation split.
Vision-language models¶
For vision-language models, pass task="captioning" or task="vqa" with image-text data.
See dataspires.docs("finetune").
Dataset format¶
See Models and data sources for the columns
that are converted to text automatically.