Skip to content

Latest commit

 

History

History
82 lines (54 loc) · 1.46 KB

README.finetuning.md

File metadata and controls

82 lines (54 loc) · 1.46 KB

Fine tuning example - from OK-VQA dataset

Ref: https://wandb.ai/byyoung3/ml-news/reports/How-to-Fine-Tune-LLaVA-on-a-Custom-Dataset--Vmlldzo2NjUwNTc1

  1. setup LLaVA, with the extra libraries for training

On Uxix:

a. Install Packages

conda create -n llava python=3.10 -y
conda activate llava
pip install --upgrade pip  # enable PEP 660 support
pip install -e .

b. Install additional packages for training cases

pip install -e ".[train]"
pip install flash-attn --no-build-isolation
  1. install git lfs:
chmod +x *.sh

./install-lfs__sr.sh
  1. get/create the data (change to use your data!)
pip install datasets

python prep_data__OK-VQA__sr.py
  1. download the base model:
./download_llava_weights__sr.sh
  1. review the script below, and the comments section.

You need to check the values for xxx to match your hardware.

cat ./train_qlora__wandb.sh
  1. execute the script:
./train_qlora__wandb.sh
  1. monitor the progress - if quality is high enough, you can stop the training early
  • if you run out of GPU memory, then adjust the script to offload more work to CPU
  1. To test inference with the QLORA layer - run this script:
./infer_example.sh

To infer with a given prompt and image:

./infer_qlora_v1.5__wandb.sh <path to image> "my prompt"

To infer WITHOUT the lora layer (to see the behaviour BEFORE fine-tuning):

./infer_example__no_lora.sh