Skip to main content

🔧 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)