joonavel commited on
Commit
52c8e22
·
verified ·
1 Parent(s): ebcbd64

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +77 -34
README.md CHANGED
@@ -19,7 +19,7 @@ tags:
19
  <!-- Provide a quick summary of what the model is/does. -->
20
  This Repo contains **LoRA (Low-Rank Adaptation) Adapter** for [unsloth/qwen2.5-coder-32b-instruct-bnb-4bit]
21
 
22
- The Adapter was trained for improving model's SQL generation capability in Korean question & multi-db context.
23
 
24
  This adapter was created through **instruction tuning**.
25
 
@@ -43,7 +43,7 @@ This adapter was created through **instruction tuning**.
43
  <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
44
  To use this LoRA adapter, refer to the following code:
45
 
46
- ### Load Apdater
47
 
48
  ```
49
  from transformers import BitsAndBytesConfig
@@ -62,7 +62,7 @@ from unsloth import FastLanguageModel
62
  model_name = "unsloth/Qwen2.5-Coder-32B-Instruct"
63
  adapter_revision = "checkpoint-200" # checkpoint-100 ~ 350, main(which is checkpoint-384)
64
 
65
- bnb_config = get_bnb_config(bit=8)
66
  model, tokenizer = FastLanguageModel.from_pretrained(
67
  model_name=model_name,
68
  dtype=None,
@@ -111,9 +111,7 @@ SELECT movie_title, movie_release_year, director_name FROM movies ORDER BY movie
111
  ```
112
 
113
 
114
- ### Inference
115
-
116
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
117
 
118
  ```
119
  messages = [
@@ -141,17 +139,36 @@ generated_ids = [
141
  response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
142
  ```
143
 
144
- ## Bias, Risks, and Limitations
145
 
146
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
 
147
 
148
- [More Information Needed]
 
 
 
 
149
 
150
- ### Recommendations
 
 
 
 
 
 
 
 
 
 
 
 
 
151
 
152
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
153
 
154
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
 
155
 
156
 
157
  ## Training Details
@@ -159,14 +176,21 @@ Users (both direct and downstream) should be made aware of the risks, biases and
159
  ### Training Data
160
 
161
  <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
 
 
 
 
 
162
 
163
- [More Information Needed]
164
 
165
  ### Training Procedure
166
 
167
  <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
168
 
 
 
169
  ```
 
170
  ```
171
 
172
  ### Preprocess Functions
@@ -194,39 +218,58 @@ def formatting_prompts_func(examples):
194
 
195
  #### Training Hyperparameters
196
 
197
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
 
199
  #### Speeds, Sizes, Times [optional]
200
 
201
  <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
202
-
203
- [More Information Needed]
 
 
 
204
 
205
  ## Citation [optional]
206
 
207
  <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
208
 
209
- **BibTeX:**
210
-
211
- [More Information Needed]
212
-
213
- **APA:**
214
-
215
- [More Information Needed]
216
-
217
- ## Glossary [optional]
218
-
219
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
220
-
221
- [More Information Needed]
222
-
223
- ## More Information [optional]
224
-
225
- [More Information Needed]
226
 
227
  ## Model Card Authors [optional]
228
 
229
- [More Information Needed]
230
 
231
  ## Model Card Contact
232
 
 
19
  <!-- Provide a quick summary of what the model is/does. -->
20
  This Repo contains **LoRA (Low-Rank Adaptation) Adapter** for [unsloth/qwen2.5-coder-32b-instruct-bnb-4bit]
21
 
22
+ The Adapter was trained for **improving model's SQL generation capability** in **Korean question & multi-db context**.
23
 
24
  This adapter was created through **instruction tuning**.
25
 
 
43
  <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
44
  To use this LoRA adapter, refer to the following code:
45
 
46
+ ### Adapter Loading
47
 
48
  ```
49
  from transformers import BitsAndBytesConfig
 
62
  model_name = "unsloth/Qwen2.5-Coder-32B-Instruct"
63
  adapter_revision = "checkpoint-200" # checkpoint-100 ~ 350, main(which is checkpoint-384)
64
 
65
+ bnb_config = get_bnb_config(bit=bit)
66
  model, tokenizer = FastLanguageModel.from_pretrained(
67
  model_name=model_name,
68
  dtype=None,
 
111
  ```
112
 
113
 
114
+ ### Inference - pytorch
 
 
115
 
116
  ```
117
  messages = [
 
139
  response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
140
  ```
141
 
142
+ ### Inference - LangChain & HuggingFacePipeline
143
 
144
+ ```
145
+ bnb_config = get_bnb_config(bit=bit)
146
 
147
+ model, tokenizer = FastLanguageModel.from_pretrained(
148
+ model_name=model_name,
149
+ dtype=None,
150
+ quantization_config=bnb_config,
151
+ )
152
 
153
+ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, max_new_tokens=max_new_tokens)
154
+ hf_llm = HuggingFacePipeline(pipeline=pipe)
155
+
156
+ prompt = ChatPromptTemplate.from_messages(
157
+ [
158
+ SystemMessage(
159
+ content=GENERAL_QUERY_PREFIX.format(context=context) + GENERATE_QUERY_INSTRUCTIONS
160
+ ),
161
+ (
162
+ "human",
163
+ "질문(user_question): {user_question}",
164
+ ),
165
+ ]
166
+ )
167
 
168
+ chain = prompt | hf_llm
169
 
170
+ response = chain.invoke({"user_question" : user_question})
171
+ ```
172
 
173
 
174
  ## Training Details
 
176
  ### Training Data
177
 
178
  <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
179
+ https://huggingface.co/datasets/100suping/ko-bird-sql-schema
180
+ - Naive translation of english quesiton to korean quesiton
181
+
182
+ https://huggingface.co/datasets/won75/text_to_sql_ko
183
+ - Generated data from 100 seed data
184
 
 
185
 
186
  ### Training Procedure
187
 
188
  <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
189
 
190
+ https://github.com/100suping/train_with_unsloth
191
+
192
  ```
193
+
194
  ```
195
 
196
  ### Preprocess Functions
 
218
 
219
  #### Training Hyperparameters
220
 
221
+ - **Training regime:** bf16 mixed-precision
222
+ - **Load-in-8bit:** True
223
+ - **LoRA config:**
224
+ - r=16
225
+ - lora_alpha=32
226
+ - lora_dropout=0.0
227
+ - target_modules = "q proj", "k_proj", "v_proj", "o_proj","gate_proj", "up_proj", "down_proj"
228
+ - bias = "none"
229
+ - use_gradient_checkpointing = "unsloth"
230
+ - use_rslora = False
231
+ - loftq_config = None
232
+ - **Training Data:** 100suping/ko-bird-sql-schema, won75/text_to_sql_ko
233
+ - **Max_seq_length:** 4096
234
+ - **Save_steps:** 50
235
+ - **Epochs:** 2
236
+ - **Global_steps:** 384
237
+ - **Batch_size:** 16
238
+ - **Gradient_accumulation_steps:** 2
239
+ - **Learning_rate:** 2e-4
240
+ - **Warmup_steps:** 20
241
 
242
  #### Speeds, Sizes, Times [optional]
243
 
244
  <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
245
+ - **Device:** G-NAHP-80 from EliceCloud(https://elice.io/ko/products/cloud/on-demand)
246
+ - A100 80GB PCle (However somehow if i use more than 60GB, error shows up)
247
+ - CPU 16 vCore
248
+ - Memory 192 GiB
249
+ - Storage 100 GiB
250
 
251
  ## Citation [optional]
252
 
253
  <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
254
 
255
+ ```
256
+ @article{hui2024qwen2,
257
+ title={Qwen2. 5-Coder Technical Report},
258
+ author={Hui, Binyuan and Yang, Jian and Cui, Zeyu and Yang, Jiaxi and Liu, Dayiheng and Zhang, Lei and Liu, Tianyu and Zhang, Jiajun and Yu, Bowen and Dang, Kai and others},
259
+ journal={arXiv preprint arXiv:2409.12186},
260
+ year={2024}
261
+ }
262
+ @article{qwen2,
263
+ title={Qwen2 Technical Report},
264
+ author={An Yang and Baosong Yang and Binyuan Hui and Bo Zheng and Bowen Yu and Chang Zhou and Chengpeng Li and Chengyuan Li and Dayiheng Liu and Fei Huang and Guanting Dong and Haoran Wei and Huan Lin and Jialong Tang and Jialin Wang and Jian Yang and Jianhong Tu and Jianwei Zhang and Jianxin Ma and Jin Xu and Jingren Zhou and Jinze Bai and Jinzheng He and Junyang Lin and Kai Dang and Keming Lu and Keqin Chen and Kexin Yang and Mei Li and Mingfeng Xue and Na Ni and Pei Zhang and Peng Wang and Ru Peng and Rui Men and Ruize Gao and Runji Lin and Shijie Wang and Shuai Bai and Sinan Tan and Tianhang Zhu and Tianhao Li and Tianyu Liu and Wenbin Ge and Xiaodong Deng and Xiaohuan Zhou and Xingzhang Ren and Xinyu Zhang and Xipin Wei and Xuancheng Ren and Yang Fan and Yang Yao and Yichang Zhang and Yu Wan and Yunfei Chu and Yuqiong Liu and Zeyu Cui and Zhenru Zhang and Zhihao Fan},
265
+ journal={arXiv preprint arXiv:2407.10671},
266
+ year={2024}
267
+ }
268
+ ```
 
 
 
269
 
270
  ## Model Card Authors [optional]
271
 
272
+ joonavel[https://github.com/joonavel] from 100suping [https://github.com/100suping]
273
 
274
  ## Model Card Contact
275