{ "cells": [ { "cell_type": "markdown", "id": "cell-0", "metadata": {}, "source": [ "# Supervised Fine-tuning (SFT) with Unsloth\n", "\n", "Fine-tuning requires a GPU. If you don't have one locally, you can run this notebook for free on [Google Colab](https://colab.research.google.com/github/Liquid4All/cookbook/blob/main/finetuning/notebooks/sft_with_unsloth.ipynb) using a free NVIDIA T4 GPU instance.\n", "\n", "[](https://colab.research.google.com/github/Liquid4All/cookbook/blob/main/finetuning/notebooks/sft_with_unsloth.ipynb)\n", "\n", "### What's in this notebook?\n", "\n", "In this notebook you will learn how to perform Supervised Fine-tuning (SFT) using Unsloth for efficient, memory-optimized training.\n", "We will use the [LFM2.5-1.2B-Instruct](https://docs.liquid.ai/docs/models/lfm25-1.2b-instruct) model and fine-tune it on the FineTome-100k dataset using LoRA adapters and Unsloth's optimizations for 2x faster training with reduced memory consumption.\n", "\n", "We will cover\n", "- Environment setup\n", "- Data preparation\n", "- Model training\n", "- Local inference with your new model\n", "- Model saving and exporting it into the format you need for **deployment**.\n", "\n", "### Deployment options\n", "\n", "LFM2.5 models are small and efficient, enabling deployment across a wide range of platforms:\n", "\n", "
| Deployment Target | \n", "Use Case | \n", "
|---|---|
| 📱 Android | \n", "Mobile apps on Android devices | \n", "
| 📱 iOS | \n", "Mobile apps on iPhone/iPad | \n", "
| 🍎 Apple Silicon Mac | \n", "Local inference on Mac with MLX | \n", "
| 🦙 llama.cpp | \n", "Local deployments on any hardware | \n", "
| 🦙 Ollama | \n", "Local inference with easy setup | \n", "
| 🖥️ LM Studio | \n", "Desktop app for local inference | \n", "
| ⚡ vLLM | \n", "Cloud deployments with high throughput | \n", "
| ☁️ Modal | \n", "Serverless cloud deployment | \n", "
| 🏗️ Baseten | \n", "Production ML infrastructure | \n", "
| 🚀 Fal | \n", "Fast inference API | \n", "
| Step | \n", "Training Loss | \n", "
|---|---|
| 1 | \n", "0.863600 | \n", "
| 2 | \n", "0.912900 | \n", "
| 3 | \n", "0.840000 | \n", "
| 4 | \n", "0.534600 | \n", "
| 5 | \n", "0.774800 | \n", "
| 6 | \n", "0.785900 | \n", "
| 7 | \n", "0.837100 | \n", "
| 8 | \n", "0.824400 | \n", "
| 9 | \n", "0.922100 | \n", "
| 10 | \n", "0.972900 | \n", "
| 11 | \n", "0.793100 | \n", "
| 12 | \n", "0.875400 | \n", "
| 13 | \n", "0.559400 | \n", "
| 14 | \n", "0.604100 | \n", "
| 15 | \n", "0.652200 | \n", "
| 16 | \n", "0.688400 | \n", "
| 17 | \n", "0.772600 | \n", "
| 18 | \n", "0.917400 | \n", "
| 19 | \n", "0.717700 | \n", "
| 20 | \n", "0.807300 | \n", "
| 21 | \n", "0.786400 | \n", "
| 22 | \n", "0.572400 | \n", "
| 23 | \n", "0.833100 | \n", "
| 24 | \n", "0.641900 | \n", "
| 25 | \n", "0.935800 | \n", "
| 26 | \n", "0.621100 | \n", "
| 27 | \n", "0.642300 | \n", "
| 28 | \n", "0.922300 | \n", "
| 29 | \n", "0.634500 | \n", "
| 30 | \n", "0.811700 | \n", "
| 31 | \n", "0.698200 | \n", "
| 32 | \n", "0.650500 | \n", "
| 33 | \n", "0.735700 | \n", "
| 34 | \n", "0.646300 | \n", "
| 35 | \n", "0.794400 | \n", "
| 36 | \n", "0.704900 | \n", "
| 37 | \n", "0.829200 | \n", "
| 38 | \n", "1.035000 | \n", "
| 39 | \n", "0.839700 | \n", "
| 40 | \n", "0.639900 | \n", "
| 41 | \n", "0.886400 | \n", "
| 42 | \n", "0.608500 | \n", "
| 43 | \n", "0.530600 | \n", "
| 44 | \n", "0.693500 | \n", "
| 45 | \n", "0.567800 | \n", "
| 46 | \n", "0.762600 | \n", "
| 47 | \n", "0.769500 | \n", "
| 48 | \n", "0.767300 | \n", "
| 49 | \n", "0.676400 | \n", "
| 50 | \n", "0.616500 | \n", "
| 51 | \n", "0.648600 | \n", "
| 52 | \n", "0.485100 | \n", "
| 53 | \n", "0.537600 | \n", "
| 54 | \n", "0.682300 | \n", "
| 55 | \n", "0.675400 | \n", "
| 56 | \n", "0.687300 | \n", "
| 57 | \n", "0.632200 | \n", "
| 58 | \n", "0.699200 | \n", "
| 59 | \n", "0.663700 | \n", "
| 60 | \n", "0.684200 | \n", "
"
],
"text/plain": [
"