This project aims to fine-tune the Flan-T5 language model using Hugging Face's Transformers library. By following these steps, you can fine-tune the model and use it for inference.
Before getting started, make sure you have the following:
Clone this repository to your local machine.
git clone https://github.com/mltrev23/Fine-Tuning-LLaMA-2/Install the required packages using the following command:
pip install -r requirements.txtThere are four methods of fine-tuning available:
Additive Fine-Tuning: Adds layers to train.
python additive-fine-tuning.pyFull Fine-Tuning: Trains all weights of the model.
python full-fine-tuning.pySelective Fine-Tuning: Chooses specific layers of the original model to train.
python selective-fine-tuning.pyTemplate Fine-Tuning: Uses a predefined template for training. The template can be modified as needed.
To ingest your own data for fine-tuning, modify the code in your scripts to load your dataset. Here’s an example of loading a text dataset:
from transformers import LineByLineTextDataset
dataset = LineByLineTextDataset(tokenizer=tokenizer, file_path='datasets/bittensor.txt', block_size=128)To perform inference using the fine-tuned Flan-T5 model, you can use the following scripts:
Generate Using Forward Pass: This script demonstrates generating text using a forward pass approach.
python generate-using-forward.pyMain Inference Script: This script provides a straightforward way to generate outputs from the model.
python main.pyYou can modify the input text in the main.py file to test the model:
input_text = ["What is FAANG?"]This will generate an output based on the input provided.
Feel free to modify the scripts as needed for your specific tasks and datasets. If you encounter any issues, check the Hugging Face documentation or seek help from the community.
Feel free to adjust any sections further based on your specific needs!