Giter VIP home page Giter VIP logo

baize-chatbot's Introduction

Project Baize

[๐Ÿ“„ Paper] | [๐Ÿค— Demo]


What's Baize?

Baize is an open-source chat model trained with LoRA. It uses 100k dialogs generated by letting ChatGPT chat with itself. We also use Alpaca's data to improve its performance. We have released 7B, 13B and 30B models. Please refer to the paper for more details.

Why it's called Baize?

Baize (็™ฝๆณฝ) is a mythical creature in Chinese folklore, who speaks human languages and knows everything. This is exactly what we expect from a chat model.

Overview

โš ๏ธ All model weights and data are for research use ONLY. Commercial use is strictly prohibited. We accept NO responsibility or liability for any use of our data, code or weights.

This is the repo for the Baize project, which aims to build a chat model with LLaMA. This repository contains:

  • 54K/57K/47K dialogs from Quora, StackOverFlow and MedQuAD questions
  • The code for collecting self-chat data
  • The code for training Baize
  • The code for chat model demo (forked from ChuanhuChatGPT)

Model Release

Demo

Open in Spaces Duplicate this Space

Demo

You can either host it on your local machine or access the online demo. The demo fetches the LLaMA model and the LoRA weights from the Hugging Face model hub, then runs a user-friendly Gradio interface for chatting.

How to Run Locally

First, make sure your Python version is 3.8, and then install the required packages using the command below:

cd demo
pip install -r requirements.txt

You can host the model on your local machine using the following command:

base_model=decapoda-research/llama-7b-hf
lora_model=project-baize/baize-lora-7B
python app.py $base_model $lora_model

GPU VRAM Requirements

Inference (without int8)
Baize-7B 16GB
Baize-13B 28GB
Baize-30B 67GB

If you have a GPU with smaller VRAM, you can do inference with int8, following this issue.

How to Reproduce

Setup

  1. Install dependencies
pip install -r requirements.txt
  1. If bitsandbytes doesn't work, install it from source. Windows users can follow these instructions.

Data Collecting

You can use our released data or collect the data from ChatGPT using the following command:

num_process=10 # The number of processes to collect data
max_total_tokens=500000 # Set maximum numbers of tokens to collect data
api_key=xxxxxxxxxxxxxxxxx # Set your openai api key
for ((i=0; i<$num_process; i++))
do
    python collect.py $api_key $max_total_tokens $i $num_process stackoverflow &
    python collect.py $api_key $max_total_tokens $i $num_process quora &
    python collect.py $api_key $max_total_tokens $i $num_process medical &
done

After collecting data, you use the following command to preprocess data:

python preprocess.py stackoverflow
python preprocess.py quora
python preprocess.py medical

Use your own data

If there's a specific dataset you want to use as seeds for ChatGPT self-chatting, you can simply modify collect.py to load your own data.

Training

The fine-tuning code is designed to run on an A100-80G GPU. The finetune.py script accepts three parameters: foundation model size (i.e., 7B, 13B, or 30B), batch size, learning rate and datasets. Note the total batch size is fixed to 64 (can be modified here) and the batch size here is the per device batch size before gradient accumulation. Set it to a smaller value if you are training on a GPU with smaller VRAM.

# For the 7B model (takes about 9 hours)
python finetune.py 7b 32 0.0002 alpaca,stackoverflow,quora

# For the 13B model (takes about 16 hours)
python finetune.py 13b 16 0.0001 alpaca,stackoverflow,quora

# For the 30B model (takes about 36 hours)
python finetune.py 30b 8 0.00005 alpaca,stackoverflow,quora

GPU VRAM Consumption

With the settings above:

Training (with int8)
Baize-7B 26GB
Baize-13B 25GB
Baize-30B 42GB

Citation

@article{xu2023baize,
  title={Baize: An Open-Source Chat Model with Parameter-Efficient Tuning on Self-Chat Data},
  author={Xu, Canwen and Guo, Daya and Duan, Nan and McAuley, Julian},
  journal={arXiv preprint arXiv:2304.01196},
  year={2023}
}

Share to Community

baize-chatbot's People

Contributors

jetrunner avatar guoday avatar cameronbergh 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.