Fine-tuning
Fine-tuning is the process of teaching an AI model to understand and respond to user queries. ToothFairyAI allows organisations to build, own and host their own AI models, with support for five training methods — SFT, DPO, GRPO, KTO and continued pre-training — plus a sixth RLVR mode (reinforcement learning with verifiable rewards) for agentic tasks. This document provides an overview of the fine-tuning process.
Menu location
Fine-tuning can be accessed from the following menu:
Fine-tuning > Start tuning
Training data is managed in a single table — every training document lives in one place, regardless of kind. Each document has a type, shown in the Type column and filterable via the All types dropdown:
- Conversations (
conversationalTrainingdocuments): conversational (instruction–answer) datasets — used by SFT, GRPO and CPT - Preferences (
generativeTrainingdocuments): preferred vs non-preferred response datasets — used by DPO and KTO - RL tasks (
rlTaskdocuments): task definitions (a prompt plus a programmatic checker) — used by RL with verifiable rewards (RLVR)
The document type you author or import decides what kind of data you prepare; the training_type you pick when you start a job decides how that data is used.

ToothFairyAI supports five training methods. Documents are stored as one of three types in a single table; the training_type you pick when you start a job decides how that data is used:
training_type | Method | Document type it draws from | What it optimises |
|---|---|---|---|
conversationalTraining | SFT (Supervised Fine-Tuning) | Conversations | Standard instruction–response adaptation |
generativeTraining | DPO (Direct Preference Optimisation) | Preferences | Preferred vs non-preferred responses |
grpoTraining | GRPO (Group Relative Policy Optimisation) | Conversations | Reward-driven; the model self-generates completions |
ktoTraining | KTO (Kahneman–Tversky Optimisation) | Preferences (unpaired) | Unpaired preference signal |
continuedPretraining | CPT (Continued Pre-Training) | Conversations | Plain-text domain adaptation (packed sequences) |
See Training data for the exact dataset format each document type expects.
grpoTraining combined with the rl.enabled config switches GRPO into RLVR mode: instead of a conversation dataset, it trains on rlTask documents — tasks the model attempts in a sandboxed environment, scored by programmatic checkers. See RL with Verifiable Rewards for the full guide, including when to choose it over SFT/DPO and its compute caveats.
:::
Fine-tuning process
The fine-tuning process consists of the following steps:
- Give a name to the fine-tuning process: The user can give a name to the fine-tuning process. The name of the fine-tuning job will be later used to identify the fine-tuned model in the
Hosting & Modelssection in the agents configuration. - Provide a description: The user can provide a description to the fine-tuning process (optional)
- Filter topics: Similarly to the
Knowledge HubandAgentsconfiguration, ToothFairyAI allows the user to filter the training data based on the topics selected. By default, all topics are selected which means all training data available in the workspace will be used for the fine-tuning process. - Select the model: Selection of the model to be fine-tuned. The selection influences both the dataset and the model output. The trainable catalogue is dynamic and environment-specific — the authoritative live list is returned by the public
GET /finetuning/modelsendpoint (see the Fine-Tuning API reference — the TF Fine-Tuning spec) and mirrored in the platform model picker. Each entry advertises itsmodelSize,maxBatchSize, thesupportsSft/supportsDpo/supportsVlmFinetuneflags, aloraConstraints.max_rank, and theinstanceTypeplus the estimated UoI cost per hour. The current catalogue spans:
| Family | Sizes available | Notable example |
|---|---|---|
| Llama | 1B, 3B, 8B, 70B, 3.3 70B, Llama 4 Scout 17B | unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit |
| Qwen | 1.5B, 3B, 7B, 14B, 32B, 72B | unsloth/Qwen2.5-32B-Instruct-bnb-4bit |
| DeepSeek-R1 Distill | 1.5B, 8B, 14B, 32B, 70B | unsloth/DeepSeek-R1-Distill-Qwen-14B-bnb-4bit |
| Mistral | 7B, Small 3.2 24B | unsloth/Mistral-Small-3.2-24B-Instruct-2506-bnb-4bit |
| Gemma | 1B, 3 4B, 2 9B, 3 12B, 3 27B, 4 31B | unsloth/gemma-3-27b-it-bnb-4bit |
| GLM | 4 32B | unsloth/GLM-4-32B-0414-unsloth-bnb-4bit |
| GPT-OSS | 120B | unsloth/gpt-oss-120b-unsloth-bnb-4bit |
| Vision (VLM) | Qwen2.5-VL 3B/7B/32B/72B, Qwen3-VL 4B/8B, Llama 3.2 11B Vision | unsloth/Qwen2.5-VL-7B-Instruct-unsloth-bnb-4bit |
All models ship as 4-bit quantised (bnb-4bit) variants and are trained with QLoRA. Vision (VLM) models support SFT on multimodal (image + text) data; DPO is not supported for VLMs. The max_rank is 32 for GPT-OSS 120B and 64 for every other model.
The base_model field is not constrained to the catalogue above — any valid HuggingFace model id is accepted. When a model is not in the registry the training engine uses it as-is and infers the model size (and therefore the training instance type) from the id, treating it as a non-VLM model of inferred size. On Enterprise, ToothFairyAI can additionally enable fine-tuning of the models already hosted on your agents — see Hosting & Models.
-
Datasets & model weights: When a job finishes it produces two kinds of artefact:
- Datasets — the training and evaluation JSONL (generated from your workspace documents plus any JSONL you imported), in a universal, model-agnostic format. Datasets are downloadable by every subscription tier and can be reused to fine-tune any model later, on or off the platform.
- Model weights — the trained LoRA adapter (
adapter_model.safetensors) together with itsadapter_config.json, plusmetrics.jsonand the training charts. Whether your tier can run the managed training job and download the weights is controlled by your subscription — a run blocked by quota surfaces as error code920("UoI quota exceeded").
By default:
Serverlessworkspaces can generate and download datasets only;Enterpriseworkspaces can run training and associate the fine-tuned model directly with their agents (Hosting & Models). Whether weight download is enabled for your plan is set at the subscription / UoI-quota layer, not in the fine-tuning handler itself, so confirm it with ToothFairyAI support before committing to a large run.
Both Llama 3.3 and Llama 3.1 models support tool calling and planning capabilities. Therefore, you can finetune not only text generation but also tooling such as API calls, DB queries and planning tasks!
In other words you can deeply customise even Orchestrator agents to suit your use cases!
Fine-tuning configuration parameters
When configuring your fine-tuning job, you'll encounter several technical parameters. Understanding these parameters helps you optimize the training process for your specific use case.
ToothFairyAI's managed fine-tuning runs on the ToothFairyAI inference and training architecture (4-bit QLoRA). The parameters documented in this section are the controls surfaced in the platform fine-tuning form. Three of them — Learning rate peak ratio, Number of evaluations, and Number of checkpoints — are honoured by the legacy hosted training path only and are ignored by the managed training path, which evaluates and checkpoints once per epoch automatically (and applies a linear LR schedule with a warmup ratio, not a peak ratio).
The managed-path defaults and the full per-method parameter set (including the LoRA, warmup, token-limit and drost beta controls not surfaced as form fields) are documented in the Managed fine-tuning reference section below. When driving training through the Fine-Tuning API, the CLI, or TF Code, use the config keys documented there.
Learning rate (%)
Default: 0.0001
The learning rate controls how quickly the model adapts to your training data. Think of it as the "step size" the model takes when learning.
- Lower values (e.g., 0.00001): More cautious learning, slower but more stable training. Recommended for large models or when you want to preserve the model's existing capabilities.
- Higher values (e.g., 0.001): Faster learning but may cause instability or "forgetting" of the base model's knowledge.
Learning rate peak ratio
Default: 0
This parameter controls the learning rate warmup schedule. When set to 0, no warmup is applied.
- Value of 0: Learning rate stays constant throughout training.
- Positive values (e.g., 0.1): The learning rate will increase from a lower starting point to the peak value, then potentially decrease. This helps stabilize early training.
Learning rate warmup ratio
Default: 0
Determines what fraction of training steps are used for learning rate warmup.
- Value of 0: No warmup period.
- Example value of 0.1: The first 10% of training steps gradually increase the learning rate from near-zero to the target learning rate.
This prevents large gradient updates early in training that could destabilize the model.
Min dataset for training test
Default: 200
The minimum number of examples required in your dataset to proceed with fine-tuning.
- This safety check ensures you have enough data for meaningful training.
- If your dataset has fewer examples than this threshold, the system will prevent training to avoid poor results.
Test dataset size (%)
Default: 0.1 (10%)
The percentage of your dataset reserved for evaluation (not used for training).
- 10% (0.1): Recommended default. For a 1,000-example dataset, 100 examples are used for testing, 900 for training.
- Lower values (e.g., 0.05): More data for training, less for evaluation. Use when you have limited data.
- Higher values (e.g., 0.2): More robust evaluation but less training data.
Number of evaluations
Default: 20
How many times during training the model's performance is evaluated on the test dataset.
- More evaluations (e.g., 50): Better tracking of training progress, helps identify overfitting early.
- Fewer evaluations (e.g., 5): Faster training but less insight into model performance during training.
Max epochs
Default: 20
An epoch is one complete pass through your entire training dataset. This sets the maximum number of passes.
- More epochs (e.g., 50): Model sees the data more times, potentially better learning but higher risk of overfitting.
- Fewer epochs (e.g., 3-5): Faster training, lower risk of overfitting but may not fully learn the patterns.
The training may stop early if the model converges before reaching max epochs.
Number of checkpoints
Default: 1
Checkpoints are saved snapshots of your model during training.
- 1 checkpoint: Only the final model is saved (most common).
- Multiple checkpoints (e.g., 5): Saves intermediate versions. Useful if you want to compare different training stages or if training might be interrupted.
Batch size
Default: 8
The number of training examples processed together in one training step.
- Larger batches (e.g., 32): More stable gradient estimates, faster training on powerful hardware, but requires more memory.
- Smaller batches (e.g., 2-4): Less memory required, can work on smaller GPUs, but may have more noisy training.
Batch size 8 is a balanced default for most use cases.
Rank for LoRA adapter weights
Default: 8
LoRA (Low-Rank Adaptation) is an efficient fine-tuning technique. The rank controls the capacity of the adaptation.
- Lower rank (e.g., 4): Fewer trainable parameters, faster training, smaller fine-tuned models, but less adaptation capacity.
- Higher rank (e.g., 16-32): More trainable parameters, can capture more complex patterns, but slower and requires more memory.
Rank 8 is optimal for most applications.
Alpha value for LoRA adapter
Default: 8
The alpha parameter scales the LoRA updates and works together with the rank parameter.
- Same as rank (e.g., 8): Standard configuration for balanced adaptation.
- Higher than rank (e.g., 16 for rank 8): Stronger LoRA influence on the base model.
- This ratio controls how much the LoRA adaptation influences the base model's behavior.
Dropout for LoRA adapter
Default: 0.1
Dropout randomly deactivates a percentage of neurons during training to prevent overfitting.
- 0.1 (10%): Standard dropout rate, provides good regularization for most datasets.
- Lower values (e.g., 0.05): Less regularization, use when you have limited training data.
- Higher values (e.g., 0.2-0.3): More aggressive regularization, helps prevent overfitting on large datasets.
- 0: No dropout, may lead to overfitting but can be useful for very small datasets.
Select LoRA layers
Choose which specific model layers to apply LoRA fine-tuning to. By default, common layer types are selected based on the model architecture.
Available layer types (depending on the selected model):
- k_proj: Key projection layers (used in attention mechanism)
- v_proj: Value projection layers (used in attention mechanism)
- q_proj: Query projection layers (used in attention mechanism)
- o_proj: Output projection layers (used in attention mechanism)
- up_proj: Up-projection layers (used in feed-forward networks)
- gate_proj: Gate projection layers (used in gated feed-forward networks)
- down_proj: Down-projection layers (used in feed-forward networks)
Selection strategies:
- All attention layers (k_proj, v_proj, q_proj, o_proj): Standard approach for fine-tuning, focuses on how the model processes relationships between tokens. Recommended for most use cases.
- Add feed-forward layers (up_proj, down_proj, gate_proj): More comprehensive fine-tuning that includes how the model transforms information. Use for complex domain adaptation.
- Selective layers: Choose specific layers to reduce memory usage and training time while targeting particular model behaviors.
When to customize:
- Memory constraints: Select fewer layers (e.g., only q_proj and v_proj) to reduce GPU memory requirements.
- Faster training: Fewer layers train faster but may have reduced adaptation capacity.
- Standard use: Keep the default selection which typically includes the key attention layers.
Train on inputs
Options: Auto / True / False (Default: Auto)
Controls whether the model is trained to predict both the input (prompt) and output (response) or only the output.
- Auto (Recommended): System automatically determines the best setting based on your dataset and use case. This intelligently analyzes your data and selects the optimal training approach.
- True: Model learns to predict both user inputs and assistant responses. This can improve contextual understanding and is useful when you want the model to learn the style and structure of both questions and answers.
- False: Model only learns to predict assistant responses (the standard supervised fine-tuning approach). The model focuses solely on generating appropriate outputs given inputs.
When to use each option:
- Use Auto for most cases unless you have specific requirements.
- Use True if you want the model to learn conversational patterns and input formatting.
- Use False for standard instruction-following fine-tuning where only response quality matters.
For most use cases, the default values provide a good starting point. Consider adjusting these parameters if:
- You have a very small dataset (< 500 examples): Reduce epochs to 3-5 to avoid overfitting
- You have a very large dataset (> 50,000 examples): You may increase batch size and epochs
- Training is unstable or the loss explodes: your learning rate is probably outside the safe band for the model — see Learning rate bands instead of guessing.
- Training is too slow: Increase batch size if memory allows
Managed fine-tuning reference
This section documents what the managed 4-bit QLoRA ToothFairyAI training engine actually honours, so you can configure jobs confidently from the platform, the Fine-Tuning API, the CLI, or TF Code. It is the authoritative reference for the config object on POST /finetuning/start/{trainingLogId}.
Suffixes by method family
Many config knobs are suffixed by method family — use the suffix matching the training_type you picked:
RCsuffix → SFT family:conversationalTraining,grpoTraining,continuedPretrainingGNsuffix → DPO family:generativeTraining,ktoTraining
For example, set learningRateRC for an SFT run and learningRateGN for a DPO run. A handful of keys (baseModel, maxSeqLength, gradientAccumulationSteps, enableManagedSpotTraining) are shared across methods and take no suffix.
Token limits
ToothFairyAI does not impose a fixed platform-wide token cap; the maximum sequence length is configurable per job:
| Setting | Behaviour |
|---|---|
maxSeqLength (default 2048) | Hard cap on tokens per sequence for SFT / DPO / KTO / CPT. Longer sequences are truncated by the tokenizer. |
| DPO / KTO prompt length | Capped to 50% of maxSeqLength (max_prompt_length). |
| VLM (vision) models | maxSeqLength is set to null — sequences are auto-sized per sample. |
| GRPO | Uses max_completion_length (baked-in 512), not maxSeqLength; this knob is not exposed in config. |
All models are trained 4-bit quantised (QLoRA) — use_4bit is always on and not configurable. Token accounting beyond these is governed by the HuggingFace tokenizer defaults.
Hyperparameters exposed per method
✅ = settable via config; ❌ = not exposed (baked-in default); ⚠ = advisory only.
| Knob | config key | Default | SFT | DPO | GRPO | KTO | CPT | VLM |
|---|---|---|---|---|---|---|---|---|
| LoRA rank | loraR{RC/GN} | 8 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ (all layers) |
| LoRA alpha | loraAlpha{RC/GN} | 8 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| LoRA dropout | loraDropout{RC/GN} | 0.0 |