TheBloke commited on
Commit
7aa934a
1 Parent(s): 47cc670

Initial GPTQ model commit

Browse files
Files changed (1) hide show
  1. README.md +243 -0
README.md ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ inference: false
3
+ license: other
4
+ ---
5
+
6
+ # Project Baize V2 7B GPTQ
7
+
8
+ These files are GPTQ 4bit model files for [Project Baize V2 7B](https://huggingface.co/project-baize/baize-v2-7b).
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-7B-GPTQ)
15
+ * [4bit and 5bit GGML models for CPU inference](https://huggingface.co/TheBloke/Project-Baize-v2-7B-GGML)
16
+ * [Original unquantised fp16 model in HF format](https://huggingface.co/project-baize/baize-v2-7b)
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-7B-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-7B-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-7B-4bit-128g.no-act-order.safetensors**
37
+
38
+ In the `main` branch - the default one - you will find `Baize-v2-7B-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
+ * `wizard-vicuna-13B-GPTQ-4bit.compat.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-7B-GGML/HF wikitext2 --wbits 4 --true-sequential --groupsize 128 --save_safetenso
51
+ rs /workspace/ggml/TheBloke_Project-Baize-v2-7B-GGML/gptq/Baize-v2-7B-4bit-128g.no-act-order.safetensors
52
+ ```
53
+
54
+ # Original model info on Github
55
+
56
+ ## News
57
+ - **[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!
58
+ - **[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)!
59
+ - **[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!
60
+
61
+ ## What's Baize?
62
+ 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.
63
+
64
+ ## Why it's called Baize?
65
+ 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.
66
+
67
+ ## Overview
68
+ ⚠️ 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.
69
+
70
+ This is the repo for the Baize project, which aims to build a chat model with LLaMA. This repository contains:
71
+
72
+ - 54K/57K/47K [dialogs](data) from Quora, StackOverFlow and MedQuAD questions
73
+ - The [code](collect.py) for collecting self-chat data
74
+ - The [code](finetune.py) for training Baize
75
+ - The [code](demo/app.py) for chat model demo (forked from [ChuanhuChatGPT](https://github.com/GaiZhenbiao/ChuanhuChatGPT))
76
+
77
+ ### Model Release
78
+ #### V1
79
+ - [Baize-v1-7B (LoRA weights)](https://huggingface.co/project-baize/baize-lora-7B)
80
+ - [Baize-v1-13B (LoRA weights)](https://huggingface.co/project-baize/baize-lora-13B)
81
+ - [Baize-v1-30B (LoRA weights)](https://huggingface.co/project-baize/baize-lora-30B)
82
+ - [Baize Healthcare-7B (LoRA weights)](https://huggingface.co/project-baize/baize-healthcare-lora-7b)
83
+
84
+ #### V2
85
+ - [Baize-v2-7B](https://huggingface.co/project-baize/baize-v2-7b)
86
+ - [Baize-v2-13B](https://huggingface.co/project-baize/baize-v2-13b)
87
+
88
+ ### Community Models and Data
89
+ - [Fauno](https://github.com/RSTLess-research/Fauno-Italian-LLM/) is an Italian version of Baize.
90
+ - [Dutch Data](https://github.com/project-baize/baize-chatbot/issues/34): Baize data translated into Dutch.
91
+
92
+ ## CLI and API
93
+ Now you can use Baize with [Fastchat](https://github.com/lm-sys/FastChat) for the CLI and API provided by Fastchat!
94
+
95
+ First, install the latest version of Fastchat:
96
+ ```bash
97
+ pip install git+https://github.com/huggingface/peft.git
98
+ pip install git+https://github.com/lm-sys/FastChat.git
99
+ ```
100
+
101
+ (For v1 models only): Merge Baize's LoRA weights into LLaMA. Take 7B checkpoint as an example.
102
+ ```bash
103
+ # Note you have to include "baize" in the target directory so Fastchat can recognize Baize.
104
+ python3 -m fastchat.model.apply_lora --base huggyllama/llama-7b --target ./model_weights/baize-7b --lora project-baize/baize-lora-7B
105
+ ```
106
+
107
+ 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).
108
+ ```bash
109
+ # Optional: Add `--style rich` for better style.
110
+ python -m fastchat.serve.cli --model-path ./model_weights/baize-7b
111
+ ```
112
+
113
+ You can use Baize with OpenAI API or Hugging Face API following the instruction [here](https://github.com/lm-sys/FastChat#api).
114
+
115
+ ## Demo
116
+ [![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)
117
+ [![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)
118
+
119
+ <p align="center">
120
+ <img alt="Demo" src="https://user-images.githubusercontent.com/22514219/229863275-0e83c1cf-0661-4afa-9a47-1ce20fb521ae.gif">
121
+ </p>
122
+
123
+ 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.
124
+
125
+ ### How to Run Locally
126
+
127
+ First, make sure your Python version is 3.8, and then install the required packages using the command below:
128
+
129
+ ```bash
130
+ cd demo
131
+ pip install -r requirements.txt
132
+ ```
133
+
134
+ You can host the model on your local machine using the following command:
135
+
136
+ ```bash
137
+ # We assume you have obtained access to use LLaMA. The following LLaMA weights are from a 3rd party.
138
+ base_model=huggyllama/llama-7b
139
+ lora_model=project-baize/baize-lora-7B
140
+ python app.py $base_model $lora_model
141
+ ```
142
+ #### GPU VRAM Requirements
143
+ | | Inference (without int8) |
144
+ |-----------|--------------------------|
145
+ | Baize-7B | 16GB |
146
+ | Baize-13B | 28GB |
147
+ | Baize-30B | 67GB |
148
+
149
+ If you have a GPU with smaller VRAM, you can do inference with `int8`, by passing the 8bit argument:
150
+
151
+ ```bash
152
+ python app.py $base_model $lora_model 8bit
153
+ ```
154
+
155
+ ## How to Reproduce
156
+
157
+ ### Setup
158
+
159
+ 1. Install dependencies
160
+
161
+ ```bash
162
+ pip install -r requirements.txt
163
+ ```
164
+
165
+ 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).
166
+
167
+ ### Data Collecting
168
+
169
+ You can use our [released data](data) or collect the data from ChatGPT using the following command:
170
+
171
+ ```bash
172
+ num_process=10 # The number of processes to collect data
173
+ max_total_tokens=500000 # Set maximum numbers of tokens to collect data
174
+ api_key=xxxxxxxxxxxxxxxxx # Set your openai api key
175
+ for ((i=0; i<$num_process; i++))
176
+ do
177
+ python collect.py $api_key $max_total_tokens $i $num_process stackoverflow &
178
+ python collect.py $api_key $max_total_tokens $i $num_process quora &
179
+ python collect.py $api_key $max_total_tokens $i $num_process medical &
180
+ done
181
+ ```
182
+
183
+ After collecting data, you use the following command to preprocess data:
184
+
185
+ ```bash
186
+ python preprocess.py stackoverflow
187
+ python preprocess.py quora
188
+ python preprocess.py medical
189
+ ```
190
+
191
+ ### Use your own data
192
+
193
+ 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.
194
+
195
+ ### Training
196
+
197
+ 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.
198
+
199
+ ```bash
200
+ # For the 7B model (takes about 9 hours)
201
+ python finetune.py 7b 32 0.0002 alpaca,stackoverflow,quora
202
+
203
+ # For the 13B model (takes about 16 hours)
204
+ python finetune.py 13b 16 0.0001 alpaca,stackoverflow,quora
205
+
206
+ # For the 30B model (takes about 36 hours)
207
+ python finetune.py 30b 8 0.00005 alpaca,stackoverflow,quora
208
+ ```
209
+ #### GPU VRAM Consumption
210
+ With the settings ABOVE:
211
+
212
+ | | Training (with int8) |
213
+ |-----------|----------------------|
214
+ | Baize-7B | 26GB |
215
+ | Baize-13B | 25GB |
216
+ | Baize-30B | 42GB |
217
+
218
+ Got a question? See [this issue](https://github.com/project-baize/baize-chatbot/issues/26).
219
+
220
+ ### Merge LoRA into LLaMA
221
+ 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!
222
+
223
+ Here's an example for merging `baize-lora-7B` into LLaMA-7B.
224
+ ```bash
225
+ python merge_lora.py \
226
+ --base huggyllama/llama-7b \
227
+ --target ~/model_weights/baize-7b \
228
+ --lora project-baize/baize-lora-7B
229
+ ```
230
+
231
+ ## Citation
232
+ ```bibtex
233
+ @article{xu2023baize,
234
+ title={Baize: An Open-Source Chat Model with Parameter-Efficient Tuning on Self-Chat Data},
235
+ author={Xu, Canwen and Guo, Daya and Duan, Nan and McAuley, Julian},
236
+ journal={arXiv preprint arXiv:2304.01196},
237
+ year={2023}
238
+ }
239
+ ```
240
+ <hr>
241
+
242
+ [![Share to Community](https://huggingface.co/datasets/huggingface/badges/raw/main/powered-by-huggingface-light.svg)](https://huggingface.co)
243
+