parinzee commited on
Commit
3853fc0
1 Parent(s): 4118854

Updated Readme

Browse files
Files changed (1) hide show
  1. README.md +171 -3
README.md CHANGED
@@ -1,3 +1,171 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🇹🇭 OpenThaiGPT 1.0.0-beta
2
+ <img src="https://1173516064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvvbWvIIe82Iv1yHaDBC5%2Fuploads%2Fb8eiMDaqiEQL6ahbAY0h%2Fimage.png?alt=media&token=6fce78fd-2cca-4c0a-9648-bd5518e644ce" width="200px">
3
+
4
+ OpenThaiGPT Version 1.0.0-beta is a 7B-parameter LLaMA model finetuned to follow Thai translated instructions below and makes use of the Huggingface LLaMA implementation.
5
+
6
+ ## Support
7
+ - Official website: https://openthaigpt.aieat.or.th
8
+ - Facebook page: https://web.facebook.com/groups/openthaigpt
9
+ - A Discord server for discussion and support [here](https://discord.gg/rUTp6dfVUF)
10
+ - E-mail: kobkrit@iapp.co.th
11
+
12
+ ## License
13
+ - **Source Code**: Apache Software License 2.0.<br>
14
+ - **Weight**: For research use only (due to the Facebook LLama's Weight LICENSE).<br>
15
+ - <i>Note that: A commercial use license for OpenThaiGPT 0.1.0 weight will be released later soon!</i>
16
+
17
+ ## Code and Weight
18
+
19
+ - **Libary Code**: https://github.com/OpenThaiGPT/openthaigpt<br>
20
+ - **Finetune Code**: https://github.com/OpenThaiGPT/openthaigpt-finetune-010beta<br>
21
+ - **Weight**: https://huggingface.co/kobkrit/openthaigpt-0.1.0-beta
22
+
23
+ ## Sponsors
24
+ Pantip.com, ThaiSC<br>
25
+ <table>
26
+ <tr><td>
27
+ <img src="https://1173516064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvvbWvIIe82Iv1yHaDBC5%2Fuploads%2FiWjRxBQgo0HUDcpZKf6A%2Fimage.png?alt=media&token=4fef4517-0b4d-46d6-a5e3-25c30c8137a6" width="100px"></td><td>
28
+ <img src="https://1173516064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvvbWvIIe82Iv1yHaDBC5%2Fuploads%2Ft96uNUI71mAFwkXUtxQt%2Fimage.png?alt=media&token=f8057c0c-5c5f-41ac-bb4b-ad02ee3d4dc2" width="100px"></td>
29
+ </tr><table>
30
+
31
+ ### Powered by
32
+ OpenThaiGPT Volunteers, Artificial Intelligence Entrepreneur Association of Thailand (AIEAT), and Artificial Intelligence Association of Thailand (AIAT)
33
+
34
+ <table>
35
+ <tr>
36
+ <td>
37
+ <img src="https://1173516064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvvbWvIIe82Iv1yHaDBC5%2Fuploads%2F6yWPXxdoW76a4UBsM8lw%2Fimage.png?alt=media&token=1006ee8e-5327-4bc0-b9a9-a02e93b0c032" width="100px"></td><td><img src="https://1173516064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvvbWvIIe82Iv1yHaDBC5%2Fuploads%2FBwsmSovEIhW9AEOlHTFU%2Fimage.png?alt=media&token=5b550289-e9e2-44b3-bb8f-d3057d74f247" width="100px"></td></tr><table>
38
+
39
+ ### Authors
40
+ Kobkrit Viriyayudhakorn (kobkrit@iapp.co.th), Sumeth Yuenyong (sumeth.yue@mahidol.edu) and Thaweewat Ruksujarit (thaweewr@scg.com).
41
+
42
+ <i>Disclaimer: Provided responses are not guaranteed.</i>
43
+
44
+ ### Local Setup
45
+
46
+ 1. Install dependencies
47
+
48
+ ```bash
49
+ pip install -r requirements.txt
50
+ ```
51
+
52
+ 1. 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).
53
+
54
+ ### Training (`finetune.py`)
55
+
56
+ This file contains a straightforward application of PEFT to the LLaMA model,
57
+ as well as some code related to prompt construction and tokenization.
58
+ PRs adapting this code to support larger models are always welcome.
59
+
60
+ Example usage:
61
+
62
+ ```bash
63
+ python finetune.py \
64
+ --base_model 'decapoda-research/llama-7b-hf' \
65
+ --data_path 'Thaweewat/alpaca-cleaned-52k-th' \
66
+ --output_dir './openthaigpt-010-beta'
67
+ ```
68
+
69
+ We can also tweak our hyperparameters:
70
+
71
+ ```bash
72
+ python finetune.py \
73
+ --base_model 'decapoda-research/llama-7b-hf' \
74
+ --data_path 'Thaweewat/alpaca-cleaned-52k-th' \
75
+ --output_dir './openthaigpt-010-beta' \
76
+ --batch_size 128 \
77
+ --micro_batch_size 4 \
78
+ --num_epochs 3 \
79
+ --learning_rate 1e-4 \
80
+ --cutoff_len 512 \
81
+ --val_set_size 2000 \
82
+ --lora_r 8 \
83
+ --lora_alpha 16 \
84
+ --lora_dropout 0.05 \
85
+ --lora_target_modules '[q_proj,v_proj]' \
86
+ --train_on_inputs \
87
+ --group_by_length
88
+ ```
89
+
90
+ ### Inference (`generate.py`)
91
+
92
+ This file reads the foundation model from the Hugging Face model hub and the LoRA weights from `kobkrit/openthaigpt-0.1.0-beta`, and runs a Gradio interface for inference on a specified input. Users should treat this as example code for the use of the model, and modify it as needed.
93
+
94
+ Example usage:
95
+
96
+ ```bash
97
+ python generate.py \
98
+ --load_8bit \
99
+ --base_model 'decapoda-research/llama-7b-hf' \
100
+ --lora_weights 'kobkrit/openthaigpt-0.1.0-beta'
101
+ ```
102
+
103
+ ### Official weights
104
+
105
+ The most recent "official" OpenThaiGPT 0.1.0-beta adapter available at [`kobkrit/openthaigpt-0.1.0-beta`](https://huggingface.co/kobkrit/openthaigpt-0.1.0-beta) was trained on May 13 with the following command:
106
+
107
+ ```bash
108
+ python finetune.py \
109
+ --base_model='decapoda-research/llama-7b-hf' \
110
+ --data_path '../datasets/cleaned' \
111
+ --num_epochs=3 \
112
+ --cutoff_len=2048 \
113
+ --group_by_length \
114
+ --output_dir='./openthaigpt-010-beta' \
115
+ --lora_target_modules='[q_proj,k_proj,v_proj,o_proj]' \
116
+ --lora_r=64 \
117
+ --batch_size=64 \
118
+ --micro_batch_size=4
119
+ ```
120
+
121
+ ### Checkpoint export (`export_*_checkpoint.py`)
122
+
123
+ These files contain scripts that merge the LoRA weights back into the base model
124
+ for export to Hugging Face format and to PyTorch `state_dicts`.
125
+ They should help users
126
+ who want to run inference in projects like [llama.cpp](https://github.com/ggerganov/llama.cpp)
127
+ or [alpaca.cpp](https://github.com/antimatter15/alpaca.cpp).
128
+
129
+ ### Docker Setup & Inference
130
+
131
+ 1. Build the container image:
132
+
133
+ ```bash
134
+ docker build -t openthaigpt-finetune-010beta .
135
+ ```
136
+
137
+ 2. Run the container (you can also use `finetune.py` and all of its parameters as shown above for training):
138
+
139
+ ```bash
140
+ docker run --gpus=all --shm-size 64g -p 7860:7860 -v ${HOME}/.cache:/root/.cache --rm openthaigpt-finetune-010beta generate.py \
141
+ --load_8bit \
142
+ --base_model 'decapoda-research/llama-7b-hf' \
143
+ --lora_weights 'kobkrit/openthaigpt-0.1.0-beta'
144
+ ```
145
+
146
+ 3. Open `https://localhost:7860` in the browser
147
+
148
+ ### Docker Compose Setup & Inference
149
+
150
+ 1. (optional) Change desired model and weights under `environment` in the `docker-compose.yml`
151
+
152
+ 2. Build and run the container
153
+
154
+ ```bash
155
+ docker-compose up -d --build
156
+ ```
157
+
158
+ 3. Open `https://localhost:7860` in the browser
159
+
160
+ 4. See logs:
161
+
162
+ ```bash
163
+ docker-compose logs -f
164
+ ```
165
+
166
+ 5. Clean everything up:
167
+
168
+ ```bash
169
+ docker-compose down --volumes --rmi all
170
+ ```
171
+