Efficient fine-tuning with Unsloth involves the following key processes:
- Model loading: Loads a pre-trained model using the standard transformer interface, with the ability to specify parameters such as the context window:
model = AutoModelForCausalLM.from_pretrained("unslothai/llama-3.3", context_window=89000) - Training configuration: Setting the core parameters via TrainingArguments is recommended to enable dynamic quantization:
training_args = TrainingArguments(
output_dir="./results",
quantization="dynamic_4bit",
per_device_train_batch_size=4
) - Start training: Initiate the training process using the encapsulated Trainer class, which automatically optimizes memory and computational resources:
trainer = Trainer(model, args=training_args, train_dataset=dataset)
trainer.train() - Model Export: Supports a variety of industry-standard formats, such as HuggingFace format:
model.save_pretrained("./finetuned_model")
The Jupyter notebooks provided with the project contain complete end-to-end examples, and it is recommended that users prioritize these live examples.
This answer comes from the articleUnsloth: an open source tool for efficiently fine-tuning and training large language modelsThe































