🔧 Fine-tune pre-trained models
Text fine-tuning
After preparing the dataset in correct format, you can start the text fine-tuning.
First, load the text dataset and initialize the model of your choice
from xturing.datasets import TextDataset
from xturing.models import BaseModel
# Load the dataset
dataset = TextDataset('...')
# Load the model
model = BaseModel.create('')
Next, we need to start the fine-tuning
model.finetune(dataset=dataset)
Instruction fine-tuning
First, make sure that you have prepared your fine-tuning dataset for instruction fine-tuning. To know how, refer here.
After preparing the dataset in correct format, you can start the instruction fine-tuning.
Start by loading the instruction dataset and initializing the model of your choice.
from xturing.datasets import InstructionDataset
from xturing.models import BaseModel
# Load the dataset
dataset = InstructionDataset('...')
# Load the model
model = BaseModel.create('')
A list of all the supported models can be found here.
Next, we need to start the fine-tuning
model.finetune(dataset=instruction_dataset)
Example: Qwen3 0.6B with LoRA
from xturing.datasets import InstructionDataset
from xturing.models import BaseModel
instruction_dataset = InstructionDataset("/path/to/your/dataset")
model = BaseModel.create("qwen3_0_6b_lora")
model.finetune(dataset=instruction_dataset)
You can find a runnable script at examples/models/qwen3/qwen3_lora_finetune.py.
xturing finetune --model qwen3_0_6b_lora --data-dir /path/to/your/dataset