GithubHelp home page GithubHelp logo

alpaca_lora_4bit's Introduction

Alpaca Lora 4bit

Made some adjust for the code in peft and gptq for llama, and make it possible for lora finetuning with a 4 bits base model. The same adjustment can be made for 2, 3 and 8 bits.

Update Logs

  • Resolved numerically unstable issue
  • Reconstruct fp16 matrix from 4bit data and call torch.matmul largely increased the inference speed.
  • Added install script for windows and linux.
  • Added Gradient Checkpointing. Now It can finetune 30b model 4bit on a single GPU with 24G VRAM with Gradient Checkpointing enabled. (finetune.py updated) (but would reduce training speed, so if having enough VRAM this option is not needed)
  • Added install manual by s4rduk4r
  • Added pip install support by sterlind, preparing to merge changes upstream
  • Added V2 model support (with groupsize, both inference + finetune)
  • Added some options on finetune: set default to use eos_token instead of padding, add resume_checkpoint to continue training
  • Added offload support. load_llama_model_4bit_low_ram_and_offload_to_cpu function can be used.

Requirements

gptq-for-llama
peft
The specific version is inside requirements.txt

Install

copy files from GPTQ-for-LLaMa into GPTQ-for-LLaMa path and re-compile cuda extension
copy files from peft/tuners/lora.py to peft path, replace it

NOTE: Install scripts are no longer needed! requirements.txt now pulls from forks with the necessary patches.

pip install -r requirements.txt

Finetune

The same finetune script from https://github.com/tloen/alpaca-lora can be used.

After installation, this script can be used:

python finetune.py

Inference

After installation, this script can be used:

python inference.py

Text Generation Webui Monkey Patch

Clone the latest version of text generation webui and copy all the files into ./text-generation-webui/

git clone https://github.com/oobabooga/text-generation-webui.git

Open server.py and insert a line at the beginning

import custom_monkey_patch # apply monkey patch
import gc
import io
...

Use the command to run

python server.py

alpaca_lora_4bit's People

Contributors

johnsmith0031 avatar kooshi avatar ph0rk0z avatar s4rduk4r avatar sterlind avatar winglian avatar

Watchers

 avatar  avatar

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.