This repository contains a Jupyter Notebook for fine-tuning the Llama-3.2-1B-Instruct model using the Unsloth library. The workflow demonstrates how to prepare a custom dataset, apply the correct chat template, and train the model using HuggingFace’s Trainer API.
-
Environment Setup
Installs Unsloth, Xformers, and other required packages for efficient training. -
Model Loading
Loads the Llama-3.2-1B-Instruct model and tokenizer using Unsloth. -
Dataset Preparation
Loads a Bhojpuri language dataset from HuggingFace and reformats it into a conversational format suitable for instruction tuning. -
Chat Template Application
Applies the Llama-3 chat template to the tokenizer for proper formatting. -
Dataset Conversion
Converts the conversation data into a HuggingFace Dataset, ensuring compatibility with the SFT Trainer. -
PEFT Model Setup
Configures the model for parameter-efficient fine-tuning (PEFT) using LoRA. -
Training Arguments
Defines training parameters such as batch size, learning rate, and optimizer. -
Trainer Initialization & Training
Initializes the SFTTrainer and starts the training process. -
Model Testing
Tests the finetuned model with a sample Bhojpuri prompt.
- Python 3.8+
- Jupyter Notebook
- Packages:
unsloth,xformers,trl,peft,accelerate,bitsandbytes,datasets,pandas,transformers
- Clone this repository.
- Open
Finetune_002.ipynbin Jupyter Notebook or VS Code. - Run each cell sequentially to install dependencies, prepare data, train, and test the model.
- Uses the alpaca_data_cleaned_bhojpuri dataset for instruction tuning.