This repository contains a Jupyter notebook that serves as a follow along guide for my blog post surrounding this finetune.
This tutorial is around 80% modular for many models available on huggingface. If you prepare your own data, clean it, and fit it into this structure you should be able to train other models as well.
- Clone this repository to your local machine.
- Create a virtual environment (optional but recommended).
- Install the required libraries using the command
pip install -r requirements.txt
.
- Navigate to the cloned repository.
- Launch Jupyter Notebook by running
jupyter notebook
. - Open the
marlin-mistral-ft.ipynb
notebook. - Execute the cells in the notebook to run the code.
The training script, training.py
, covers the following steps:
- Setting up the accelerator.
- Loading and processing the training dataset.
- Loading the base model and tokenizer.
- Tokenizing and formatting the dataset.
- Checking and evaluating the base model.
- Fine-tuning the model using the Peft approach.
- Training the model using the Transformers library.
- Evaluating the fine-tuned model.
- Pushing the model to the HuggingFace Hub.
To run the training script:
python training.py
The current setup for this script will evaluate the original model and the finetuned model based on the loaded dataset.