Code Monkey home page Code Monkey logo

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

lora-instruct's People

Contributors

leehanchung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lora-instruct's Issues

Error message during training

Hi, I truncated "alpaca_data.json" to reduce training time and saved it in another file for training. Unfortunately, using this file gives me the error "pyarrow.lib.ArrowInvalid: JSON parse error: Column() changed from object to array in row 0".

Support for QLORA

Hello. Is there support for quantized lora finetuning of those llms?
Thanks

Falcon -7B training loss not reducing

Thanks for the wonderful code. While training Falcon-7B on Alpaca dataset, the training loss is not reducing. It used to work fine. Were there any recent changes?

MPTForCausalLM.forward() got an unexpected keyword argument 'inputs_embeds'

i 'm trying to finetune MPT-7b instruct, but getting this error.

File "/home/sulabh/new_gen_data/lora-instruct/finetune.py", line 383, in train
    trainer.train(resume_from_checkpoint=resume_from_checkpoint)
  File "/opt/conda/envs/lora-instruct/lib/python3.10/site-packages/transformers/trainer.py", line 1664, in train
    return inner_training_loop(
  File "/opt/conda/envs/lora-instruct/lib/python3.10/site-packages/transformers/trainer.py", line 1940, in _inner_training_loop
    tr_loss_step = self.training_step(model, inputs)
  File "/opt/conda/envs/lora-instruct/lib/python3.10/site-packages/transformers/trainer.py", line 2735, in training_step
    loss = self.compute_loss(model, inputs)
  File "/opt/conda/envs/lora-instruct/lib/python3.10/site-packages/transformers/trainer.py", line 2767, in compute_loss
    outputs = model(**inputs)
  File "/opt/conda/envs/lora-instruct/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/opt/conda/envs/lora-instruct/lib/python3.10/site-packages/peft/peft_model.py", line 678, in forward
    return self.base_model(
  File "/opt/conda/envs/lora-instruct/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/opt/conda/envs/lora-instruct/lib/python3.10/site-packages/accelerate/hooks.py", line 165, in new_forward
    output = old_forward(*args, **kwargs)
TypeError: MPTForCausalLM.forward() got an unexpected keyword argument 'inputs_embeds' 

Error message when training MPT-7B

Hi I got a message when I try to use Lora to train MPT-B, do you have any ideas to solve it?

ValueError: Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' 'truncation=True' to have batched tensors with the same length. Perhaps your features (instruction in this case) have excessive nesting (inputs type list where type int is expected).

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.