{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [], "gpuType": "T4" }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" }, "accelerator": "GPU" }, "cells": [ { "cell_type": "markdown", "id": "cell-0", "metadata": {}, "source": [ "# Supervised Fine-tuning (SFT) with TRL\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_trl.ipynb) using a free NVIDIA T4 GPU instance.\n", "\n", "[](https://colab.research.google.com/github/Liquid4All/cookbook/blob/main/finetuning/notebooks/sft_with_trl.ipynb)\n", "\n", "### What's in this notebook?\n", "\n", "In this notebook you will learn how to perform Supervised Fine-tuning (SFT) using the Hugging Face TRL (Transformer Reinforcement Learning) library.\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 SmolTalk dataset. You'll learn both standard SFT and parameter-efficient fine-tuning with LoRA for constrained hardware.\n", "\n", "We will cover\n", "- Environment setup\n", "- Data preparation\n", "- Model training with TRL's SFTTrainer\n", "- LoRA for parameter-efficient fine-tuning\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", "