TheBloke commited on
Commit
6f3d50c
1 Parent(s): 2bef996

Initial GPTQ model commit

Browse files
Files changed (1) hide show
  1. README.md +242 -0
README.md ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ inference: false
3
+ license: other
4
+ ---
5
+
6
+ # Project Baize V2 13B GPTQ
7
+
8
+ These files are GPTQ 4bit model files for [Project Baize V2 13B](https://huggingface.co/project-baize/baize-v2-13b).
9
+
10
+ It is the result of quantising to 4bit using [GPTQ-for-LLaMa](https://github.com/qwopqwop200/GPTQ-for-LLaMa).
11
+
12
+ ## Other repositories available
13
+
14
+ * [4bit GPTQ models for GPU inference](https://huggingface.co/TheBloke/Project-Baize-v2-13B-GPTQ)
15
+ * [4bit and 5bit GGML models for CPU inference](https://huggingface.co/TheBloke/Project-Baize-v2-13B-GGML)
16
+ * [Original unquantised fp16 model in HF format](https://huggingface.co/project-baize/baize-v2-13b)
17
+
18
+ ## How to easily download and use this model in text-generation-webui
19
+
20
+ Open the text-generation-webui UI as normal.
21
+
22
+ 1. Click the **Model tab**.
23
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/Project-Baize-v2-13B-GPTQ`.
24
+ 3. Click **Download**.
25
+ 4. Wait until it says it's finished downloading.
26
+ 5. Click the **Refresh** icon next to **Model** in the top left.
27
+ 6. In the **Model drop-down**: choose the model you just downloaded, `Project-Baize-v2-13B-GPTQ`.
28
+ 7. If you see an error in the bottom right, ignore it - it's temporary.
29
+ 8. Fill out the `GPTQ parameters` on the right: `Bits = 4`, `Groupsize = 128`, `model_type = Llama`
30
+ 9. Click **Save settings for this model** in the top right.
31
+ 10. Click **Reload the Model** in the top right.
32
+ 11. Once it says it's loaded, click the **Text Generation tab** and enter a prompt!
33
+
34
+ ## Provided files
35
+
36
+ **Compatible file - Baize-v2-13B-4bit-128g.no-act-order.safetensors**
37
+
38
+ In the `main` branch - the default one - you will find `Baize-v2-13B-4bit-128g.no-act-order.safetensors`
39
+
40
+ This will work with all versions of GPTQ-for-LLaMa. It has maximum compatibility
41
+
42
+ It was created without the `--act-order` parameter. It may have slightly lower inference quality compared to the other file, but is guaranteed to work on all versions of GPTQ-for-LLaMa and text-generation-webui.
43
+
44
+ * `Baize-v2-13B-4bit-128g.no-act-order.safetensors`
45
+ * Works with all versions of GPTQ-for-LLaMa code, both Triton and CUDA branches
46
+ * Works with text-generation-webui one-click-installers
47
+ * Parameters: Groupsize = 128g. No act-order.
48
+ * Command used to create the GPTQ:
49
+ ```
50
+ python llama.py /workspace/ggml/TheBloke_Project-Baize-v2-13B-GGML/HF wikitext2 --wbits 4 --true-sequential --groupsize 128 --save_safetensors /workspace/ggml/TheBloke_Project-Baize-v2-13B-GGML/gptq/Baize-v2-13B-4bit-128g.no-act-order.safetensors
51
+ ```
52
+
53
+ # Original model info on Github
54
+
55
+ ## News
56
+ - **[May 23, 2023]** We are releasing Baize v2! Check out the [7B](https://huggingface.co/project-baize/baize-v2-7b) and [13B](https://huggingface.co/project-baize/baize-v2-13b) model. Code coming soon!
57
+ - **[Apr. 27, 2023]** [Fastchat](https://github.com/lm-sys/FastChat) now supports Baize. Try the new [CLI and API](https://github.com/project-baize/baize-chatbot#cli-and-api)!
58
+ - **[Apr. 21, 2023]** We now have a [script](https://github.com/project-baize/baize-chatbot#merge-lora-into-llama) to merge LoRA weights into standard HF model so you can use it everywhere HF is supported!
59
+
60
+ ## What's Baize?
61
+ Baize is an open-source chat model trained with [LoRA](https://github.com/microsoft/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](https://arxiv.org/pdf/2304.01196.pdf) for more details.
62
+
63
+ ## Why it's called Baize?
64
+ Baize (pronounced as By-zor; Simplified Chinese 白泽, Traditional Chinese 白澤, Japanese 白沢, はくたく) is a mythical creature in Chinese folklore, who speaks human languages and knows everything. This is exactly what we expect from a chat model.
65
+
66
+ ## Overview
67
+ ⚠️ 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.
68
+
69
+ This is the repo for the Baize project, which aims to build a chat model with LLaMA. This repository contains:
70
+
71
+ - 54K/57K/47K [dialogs](data) from Quora, StackOverFlow and MedQuAD questions
72
+ - The [code](collect.py) for collecting self-chat data
73
+ - The [code](finetune.py) for training Baize
74
+ - The [code](demo/app.py) for chat model demo (forked from [ChuanhuChatGPT](https://github.com/GaiZhenbiao/ChuanhuChatGPT))
75
+
76
+ ### Model Release
77
+ #### V1
78
+ - [Baize-v1-7B (LoRA weights)](https://huggingface.co/project-baize/baize-lora-7B)
79
+ - [Baize-v1-13B (LoRA weights)](https://huggingface.co/project-baize/baize-lora-13B)
80
+ - [Baize-v1-30B (LoRA weights)](https://huggingface.co/project-baize/baize-lora-30B)
81
+ - [Baize Healthcare-7B (LoRA weights)](https://huggingface.co/project-baize/baize-healthcare-lora-7b)
82
+
83
+ #### V2
84
+ - [Baize-v2-7B](https://huggingface.co/project-baize/baize-v2-7b)
85
+ - [Baize-v2-13B](https://huggingface.co/project-baize/baize-v2-13b)
86
+
87
+ ### Community Models and Data
88
+ - [Fauno](https://github.com/RSTLess-research/Fauno-Italian-LLM/) is an Italian version of Baize.
89
+ - [Dutch Data](https://github.com/project-baize/baize-chatbot/issues/34): Baize data translated into Dutch.
90
+
91
+ ## CLI and API
92
+ Now you can use Baize with [Fastchat](https://github.com/lm-sys/FastChat) for the CLI and API provided by Fastchat!
93
+
94
+ First, install the latest version of Fastchat:
95
+ ```bash
96
+ pip install git+https://github.com/huggingface/peft.git
97
+ pip install git+https://github.com/lm-sys/FastChat.git
98
+ ```
99
+
100
+ (For v1 models only): Merge Baize's LoRA weights into LLaMA. Take 7B checkpoint as an example.
101
+ ```bash
102
+ # Note you have to include "baize" in the target directory so Fastchat can recognize Baize.
103
+ python3 -m fastchat.model.apply_lora --base huggyllama/llama-7b --target ./model_weights/baize-7b --lora project-baize/baize-lora-7B
104
+ ```
105
+
106
+ Now, run the CLI in your terminal! More options and configs can be found [here](https://github.com/lm-sys/FastChat#inference-with-command-line-interface).
107
+ ```bash
108
+ # Optional: Add `--style rich` for better style.
109
+ python -m fastchat.serve.cli --model-path ./model_weights/baize-7b
110
+ ```
111
+
112
+ You can use Baize with OpenAI API or Hugging Face API following the instruction [here](https://github.com/lm-sys/FastChat#api).
113
+
114
+ ## Demo
115
+ [![Open in Spaces](https://huggingface.co/datasets/huggingface/badges/raw/main/open-in-hf-spaces-md.svg)](https://huggingface.co/spaces/project-baize/Baize-7B)
116
+ [![Duplicate this Space](https://huggingface.co/datasets/huggingface/badges/raw/main/duplicate-this-space-md.svg)](https://huggingface.co/spaces/project-baize/Baize-7B?duplicate=true)
117
+
118
+ <p align="center">
119
+ <img alt="Demo" src="https://user-images.githubusercontent.com/22514219/229863275-0e83c1cf-0661-4afa-9a47-1ce20fb521ae.gif">
120
+ </p>
121
+
122
+ You can either host it on your local machine or access the [online demo](https://huggingface.co/spaces/project-baize/Baize-7B). The demo fetches the [LLaMA](https://huggingface.co/huggyllama/llama-7b) model and the [LoRA weights](https://huggingface.co/project-baize/baize-lora-7B) from the Hugging Face model hub, then runs a user-friendly Gradio interface for chatting.
123
+
124
+ ### How to Run Locally
125
+
126
+ First, make sure your Python version is 3.8, and then install the required packages using the command below:
127
+
128
+ ```bash
129
+ cd demo
130
+ pip install -r requirements.txt
131
+ ```
132
+
133
+ You can host the model on your local machine using the following command:
134
+
135
+ ```bash
136
+ # We assume you have obtained access to use LLaMA. The following LLaMA weights are from a 3rd party.
137
+ base_model=huggyllama/llama-7b
138
+ lora_model=project-baize/baize-lora-7B
139
+ python app.py $base_model $lora_model
140
+ ```
141
+ #### GPU VRAM Requirements
142
+ | | Inference (without int8) |
143
+ |-----------|--------------------------|
144
+ | Baize-7B | 16GB |
145
+ | Baize-13B | 28GB |
146
+ | Baize-30B | 67GB |
147
+
148
+ If you have a GPU with smaller VRAM, you can do inference with `int8`, by passing the 8bit argument:
149
+
150
+ ```bash
151
+ python app.py $base_model $lora_model 8bit
152
+ ```
153
+
154
+ ## How to Reproduce
155
+
156
+ ### Setup
157
+
158
+ 1. Install dependencies
159
+
160
+ ```bash
161
+ pip install -r requirements.txt
162
+ ```
163
+
164
+ 2. If `bitsandbytes` doesn't work, [install it from source](https://github.com/TimDettmers/bitsandbytes/blob/main/compile_from_source.md). Windows users can follow [these instructions](https://github.com/tloen/alpaca-lora/issues/17).
165
+
166
+ ### Data Collecting
167
+
168
+ You can use our [released data](data) or collect the data from ChatGPT using the following command:
169
+
170
+ ```bash
171
+ num_process=10 # The number of processes to collect data
172
+ max_total_tokens=500000 # Set maximum numbers of tokens to collect data
173
+ api_key=xxxxxxxxxxxxxxxxx # Set your openai api key
174
+ for ((i=0; i<$num_process; i++))
175
+ do
176
+ python collect.py $api_key $max_total_tokens $i $num_process stackoverflow &
177
+ python collect.py $api_key $max_total_tokens $i $num_process quora &
178
+ python collect.py $api_key $max_total_tokens $i $num_process medical &
179
+ done
180
+ ```
181
+
182
+ After collecting data, you use the following command to preprocess data:
183
+
184
+ ```bash
185
+ python preprocess.py stackoverflow
186
+ python preprocess.py quora
187
+ python preprocess.py medical
188
+ ```
189
+
190
+ ### Use your own data
191
+
192
+ 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.
193
+
194
+ ### Training
195
+
196
+ 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](https://github.com/project-baize/baize/blob/cbcf39902fcdfab8d935b7ea771a4e7d452a1be0/finetune.py#L24)) 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.
197
+
198
+ ```bash
199
+ # For the 7B model (takes about 9 hours)
200
+ python finetune.py 7b 32 0.0002 alpaca,stackoverflow,quora
201
+
202
+ # For the 13B model (takes about 16 hours)
203
+ python finetune.py 13b 16 0.0001 alpaca,stackoverflow,quora
204
+
205
+ # For the 30B model (takes about 36 hours)
206
+ python finetune.py 30b 8 0.00005 alpaca,stackoverflow,quora
207
+ ```
208
+ #### GPU VRAM Consumption
209
+ With the settings ABOVE:
210
+
211
+ | | Training (with int8) |
212
+ |-----------|----------------------|
213
+ | Baize-7B | 26GB |
214
+ | Baize-13B | 25GB |
215
+ | Baize-30B | 42GB |
216
+
217
+ Got a question? See [this issue](https://github.com/project-baize/baize-chatbot/issues/26).
218
+
219
+ ### Merge LoRA into LLaMA
220
+ Now you can easily merge the trained LoRA weights into a LLaMA model so you can use it with everything that supports standard Hugging Face API!
221
+
222
+ Here's an example for merging `baize-lora-7B` into LLaMA-7B.
223
+ ```bash
224
+ python merge_lora.py \
225
+ --base huggyllama/llama-7b \
226
+ --target ~/model_weights/baize-7b \
227
+ --lora project-baize/baize-lora-7B
228
+ ```
229
+
230
+ ## Citation
231
+ ```bibtex
232
+ @article{xu2023baize,
233
+ title={Baize: An Open-Source Chat Model with Parameter-Efficient Tuning on Self-Chat Data},
234
+ author={Xu, Canwen and Guo, Daya and Duan, Nan and McAuley, Julian},
235
+ journal={arXiv preprint arXiv:2304.01196},
236
+ year={2023}
237
+ }
238
+ ```
239
+ <hr>
240
+
241
+ [![Share to Community](https://huggingface.co/datasets/huggingface/badges/raw/main/powered-by-huggingface-light.svg)](https://huggingface.co)
242
+