Giter Site home page Giter Site logo

leehanchung / lora-instruct Goto Github PK

View Code? Open in Web Editor NEW
97.0 3.0 12.0 21.22 MB

Finetune Falcon, LLaMA, MPT, and RedPajama on consumer hardware using PEFT LoRA

License: Apache License 2.0

Python 58.59% Jupyter Notebook 40.67% Shell 0.74%
agi gpt llm lora nlp falcon llama mpt redpajama

lora-instruct's Introduction

๐Ÿง‘โ€๐Ÿซ๐Ÿค LoRA-Instruct

This repository contains code for fine-tuning permissive open source LLMs using low-rank adaptation (LoRA).

Code is tested using Stanford Alpaca dataset.

  • Estimated training time for fine-tuning RedPajama-INCITE-Base-7B-v0.1 with a single RTX 3090 and Stanford Alpaca is ~12 hours.
  • Estimated training time for fine-tuning RedPajama-INCITE-Base-7B-v0.1 with RTX 3090 and RTX Titan and Stanford Alpaca is ~6.5 hours.
  • Currently only supports LoRA Instruct fine-tuning RedPajama-INCITE-Base-7B-v0.1.

Inspired by Alpaca-LoRA

Trained Models

Model Runs Training Time Link
LLaMA 3B โฌœ
LLaMA 7B โฌœ
RedPajama 3B โœ… 1:44:14
RedPajama 7B โœ… 3:09:58
MPT 3B โฌœ
MPT 7B โฌœ
Falcon 7B โœ…

Training Hardware Spec

Ubuntu 20.04.1 LTS (WSL2)

Driver Version: 531.41
CUDA Version: 12.1
cuDNN version: 8.5.0

Local Setup

Install dependencies

poetry install

To fine-tune using NVidia 2000 series GPU or earlier, please comment out this line in finetune.py

model = prepare_model_for_int8_training(model)

Training (finetune.py)

This file contains a straightforward application of PEFT / LoRA to decoder only model, as well as some code related to prompt construction and tokenization.

Example usage:

python finetune.py \
    --base_model 'togethercomputer/RedPajama-INCITE-Base-7B-v0.1' \
    --output_dir './lora-redpajama'

Distributed Training with ๐Ÿค— Accelerate

We uses HuggingFace's accelerate library for distributed training. The following is an example for distributed training with two GPUs.

  • NOTE: please set the following environment variables
export WORLD_SIZE=2
export CUDA_VISIBLE_DEVICES=0,1
torchrun \
    --nproc_per_node=2 \
    --master_port=1234 \
    finetune.py \
    --base_model 'togethercomputer/RedPajama-INCITE-Base-7B-v0.1' \
    --output_dir './lora-redpajama'

References

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.