File size: 6,682 Bytes
680147a
 
 
5b04d60
76d5d7b
 
 
5b04d60
 
 
 
 
76d5d7b
 
 
 
 
5b04d60
 
 
 
 
 
 
515fa5b
5b04d60
 
 
 
 
515fa5b
5b04d60
 
 
 
 
 
 
 
 
 
4b6a50b
 
 
 
5b04d60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3f7f0f
 
 
 
76d5d7b
f3f7f0f
76d5d7b
f3f7f0f
76d5d7b
f3f7f0f
76d5d7b
f3f7f0f
76d5d7b
f3f7f0f
76d5d7b
f3f7f0f
76d5d7b
f3f7f0f
 
43c5891
 
 
 
c4ff8b6
 
43c5891
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5b04d60
680147a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76d5d7b
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
---
library_name: peft
---

# About GPTeacher

GPTeacher๋Š” ๋กœ๋ด‡(Bot)์ด ์ถœ๋ ฅํ•˜๋Š” ๋“ฏํ•œ ๊ธฐ์กด LLM ๋ชจ๋ธ์˜ ์ถœ๋ ฅ๊ฐ’์„, ๊ฐ•์˜์ž๊ฐ€ ์‹ค์ œ๋กœ ํ•ด๋‹น ๋‚ด์šฉ์— ๋Œ€ํ•ด ๊ฐ•์˜ํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ํ’€์ด๊ณผ์ •์„ ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ์„ ๋ชฉํ‘œ๋กœ ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

## 1. ์‚ฌ์šฉ์ ˆ์ฐจ

* Install model and PEFT parameters

```
!pip install -U peft transformers optimum
!pip install auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu117/
```

```
import torch
from peft import PeftModel, PeftConfig
from transformers import AutoTokenizer, AutoModelForCausalLM, GPTQConfig

model_id = "TheBloke/WizardLM-13B-V1.2-GPTQ"

config = PeftConfig.from_pretrained("a2ran/GPTeacher-llama2-ko-13b")
tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=True)
quantization_config_loading = GPTQConfig(bits=4, disable_exllama=True)

model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=quantization_config_loading,
                                             torch_dtype=torch.float16, device_map="auto")
model = PeftModel.from_pretrained(model, "a2ran/GPTeacher-llama2-ko-13b")
```

* How to Generate Tokens

```
from transformers import TextStreamer

streamer = TextStreamer(tokenizer)

# your input sentence๊ฐ€ ๋“ค์–ด๊ฐˆ ๊ณณ
sentence = "์‚ฌ๊ณผ๊ฐ€ ๋ชธ์— ์ข‹์€ ์ด์œ ๋ฅผ ์•Œ๋ ค์ฃผ์„ธ์š”."

input = f"""
### input @ {sentence} \n\n### response @"""

output = tokenizer.decode(model.cuda().generate(
    **tokenizer(
        input,
        return_tensors='pt',
    ).to(0),
    max_new_tokens = 2048,
    temperature = 1.2,
    top_p = 0.7,
    early_stopping = True,
    eos_token_id = 2,
    do_sample = True,
    repetition_penalty = 1.1,
    streamer = streamer
)[0]).replace(input+" ", "")
```

* Output ์ƒ์„ฑ ์˜ˆ์‹œ

```
output =
<s> ์•ˆ๋…•ํ•˜์„ธ์š”. ์˜ค๋Š˜์€ ์‚ฌ๊ณผ์˜ ์žฅ์ ์— ๋Œ€ํ•ด ๋ฐฐ์šฐ๊ฒ ์Šต๋‹ˆ๋‹ค. ์‚ฌ๊ณผ๋Š” ํฌ๋„์ฃผ, ์นด๋ฐ”์˜ˆ๋กœ, ์‹œํŠธ๋Ÿฌ์Šค, ํ”ผ๋ฅด๊ณ ํƒ€ํ†จ๋ฆฌ๊ทธ๋ฆญ์Šค ๋“ฑ ์—ฌ๋Ÿฌ ๋‹ค๋ฅธ ์‹๋ฌผ๋“ค๊ณผ ๋น„๊ตํ•˜๋ฉด์„œ ์šฐ๋ฆฌ์˜ ๊ฑด๊ฐ•์„ ์ตœ์ ํ™”ํ•˜๋Š” ์ค‘์š”ํ•œ ์‹๋ฌผ์ž…๋‹ˆ๋‹ค.

์ด์ œ, ์šฐ์„  ์‚ฌ๊ณผ์˜ ์„ฑ๋ถ„์„ ์‚ดํŽด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์‚ฌ๊ณผ๋Š” ๊ณ ํ˜ˆ์••์„ ๋‚ฎ์ถ”๋Š” ์—˜๋ฆฌ๊ฐ€ํ†จ๋ฆฐ๊ณผ ํšจ๋ชจ์™€ ๊ฐ™์€ ๋‹จ๋ฐฑ์งˆ, ํ”ผํŠธ์‚ฐ, ํ”ผ๋กœ๋‚˜์‚ฐ ๋“ฑ ์˜์–‘์†Œ๋ฅผ ํ’๋ถ€ํ•˜๊ฒŒ ํ•จ์œ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์„ฑ๋ถ„๋“ค์€ ์šฐ๋ฆฌ์˜ ์ฒด๋‚ด ์กฐ์ง์— ํ•„์ˆ˜์ ์ธ ๋ฌผ์งˆ๋“ค์ด๋ฏ€๋กœ ์‚ฌ๊ณผ๋ฅผ ์„ญ์ทจํ•  ๋งŒํ•œ ์ข‹์€ ์ด์œ  ์ค‘ ํ•˜๋‚˜์ž…๋‹ˆ๋‹ค.

๋˜ํ•œ, ์‚ฌ๊ณผ๋Š” ๊ณ ๊ธฐ ์†Œ๊ธˆ๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋ฉด ๋‹จ๋ฐฑ์งˆ์˜ ์†Œํ™”๋ฅผ ๋†’์ผ ์ˆ˜ ์žˆ์–ด์š”. ๋˜ํ•œ ์ง€๋ฐฉ ์†Œ๊ธˆ๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋ฉด ๋‹น์งˆ์˜ ํก์ˆ˜๋ฅผ ์ฆ๊ฐ€์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ์šฐ๋ฆฌ์˜ ์‹ ์ฒด ๊ธฐ๋Šฅ์„ ๊ฐœ์„ ํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.

๋˜ํ•œ, ์‚ฌ๊ณผ๋Š” ๋น ๋ฅด๊ฒŒ ์†Œํ™”๋˜์–ด ํƒ„์ˆ˜ํ™”๋ฌผ์„ ๊ณต๊ธ‰ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์ด ์žฅ์ ์ด์ฃ . ์ด๋Š” ์ฒด๋‚ด ์—๋„ˆ์ง€์›์œผ๋กœ ์ž‘๋™ํ•˜๋Š” ๋Šฅ๋ ฅ์„ ๋†’์—ฌ์ค๋‹ˆ๋‹ค. ์‚ฌ๊ณผ๋ฅผ ์ •๊ตํ•˜๊ฒŒ ๋จน์„ ๊ฒฝ์šฐ ๋ถˆ๊ทœ์น™ํ•œ ํ”ผ์ž„์„ ๋ฐฉ์ง€ํ•˜๊ณ  ์‹์ด๋งž์€ ์šด๋™์„ ์œ ์ง€ํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.

๋งˆ์ง€๋ง‰์œผ๋กœ, ์‚ฌ๊ณผ๋Š” ํ”ผ๋กœ๋‹น๊ณผ ์นดํด๋ผ๋‹ฌ๋ ˆ๊ฐ€ ๋งŽ์ด ๋“ค์–ด ์žˆ์–ด์š”. ์ด๋Š” ๊ทผ์œก์— ๋ฏธ์„ธํ•œ ํž˜์„ ์ œ๊ณตํ•˜์—ฌ ๋†๊ตฌ, ํ…Œ๋‹ˆ์Šค ๋“ฑ ๋‹ค์–‘ํ•œ ์ข…๋ฅ˜์˜ ์šด๋™์„ ์œ„ํ•ด ํ•„์š”ํ•œ ์š”์†Œ์ž…๋‹ˆ๋‹ค. ์ด๋Š” ์šฐ๋ฆฌ์˜ ์šด๋™์„ ๋” ์ž˜ ์ˆ˜ํ–‰ํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ, ์‚ฌ๊ณผ๋ฅผ ์„ญ์ทจํ•  ๋•Œ๋Š” ์ฃผ๋กœ ์•„์นจ์ด๋‚˜ ์•„์นจ ์‹์‚ฌ ์ „์— ๋จน๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ, ์‚ฌ๊ณผ๋Š” ๋งค์šฐ ํก์น˜๊ธฐ ์‰ฝ๊ณ  ๋‹ค์–‘ํ•œ ์žฌ๋ฃŒ๋ฅผ ๊ฐ€๋ณ€ํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์ฐฝ๊ณ ์— ๋ณด๊ด€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ฌ๋ฐ”๋ฅธ ์กฐ๋ฆฌ ๋ฐฉ๋ฒ•์„ ์•Œ๊ณ  ์žˆ์–ด์•ผ ํ•˜๋Š”๋ฐ, ์ฃผ๋กœ ํ• ์ธ์œผ๋กœ ๊ฐ€๊ณตํ•˜์—ฌ ์ถฉ๋ถ„ํ•œ ์Œ์‹์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด์ƒ์œผ๋กœ ์‚ฌ๊ณผ์— ๋Œ€ํ•ด ์•Œ๋ ค๋“œ๋ ธ์Šต๋‹ˆ๋‹ค. ์‚ฌ๊ณผ๋Š” ์šฐ๋ฆฌ์˜ ๊ฑด๊ฐ•์„ ์ตœ์ ํ™”ํ•˜๋Š” ๋ฐ ํ•„์ˆ˜์ ์ธ ์š”์†Œ์ž…๋‹ˆ๋‹ค. ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— ์„ญ์ทจํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.</๋></s>
```

GPTeacher ํ”„๋กœ์ ํŠธ๋ฅผ ํ†ตํ•ด ์ถ”๊ตฌํ•˜๊ณ ์ž ํ•˜๋Š” ๋ชฉํ‘œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

1. ์˜คํ”ˆ ๋ฐ์ดํ„ฐ์…‹ ์ œ๊ณต : [kullm-v2](https://huggingface.co/datasets/nlpai-lab/kullm-v2), [ko-alpaca](https://huggingface.co/datasets/beomi/KoAlpaca-v1.1a) ๋ฐ์ดํ„ฐ์…‹์˜ output์„ ๊ฐ•์˜ ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ, ๊ธฐ์กด ๋ฐ์ดํ„ฐ์…‹์˜ output๊ณผ ๋”๋ถˆ์–ด extended_output ์นผ๋Ÿผ์„ ์ถ”๊ฐ€ํ•ด ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
2. PEFTmodel ํ˜น์€ ko-llama2 ๋ชจ๋ธ ์ œ๊ณต : ํ˜„์žฌ ๋ฒ„์ „์€ academic research purpose๋กœ ๋ณ€ํ˜• ๊ฐ€๋Šฅํ•œ [wizardLM](https://github.com/nlpxucan/WizardLM/tree/main)์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์ปค์Šคํ…€ ๋ฐ์ดํ„ฐ์…‹์„ ์ ์šฉํ•œ PEFTmodel ํ•™์Šต๋ฐฉ์‹์„ ํ†ตํ•ด ํŒŒ์ธํŠœ๋‹ํ•œ ๋ฒ„์ „์ž…๋‹ˆ๋‹ค. ์—ฌ๋Ÿฌ ๋ฒ„์ „ ์—…๋ฐ์ดํŠธ๋ฅผ ํ†ตํ•ด, ๋‹ค๋ฅธ ๋ชจ๋ธ๋กœ๋ถ€ํ„ฐ ํŒŒ์ธํŠœ๋‹์„ ํ•  ์ˆ˜ ์žˆ๋Š” ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ์ œ๊ณตํ•˜๊ฑฐ๋‚˜, GPTeacher-ko-llama2 ๋ชจ๋ธ์„ ์ œ์ž‘ํ•ด ์ œ๊ณตํ•˜๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค.
3. ํ˜„์žฌ ์ œ์ž‘์ค‘์ธ ๋ฐ์ดํ„ฐ์…‹ ์˜ˆ์‹œ : [https://huggingface.co/datasets/a2ran/ex_dataset](https://huggingface.co/datasets/a2ran/ex_dataset)


**ํ˜„์žฌ ์‚ฌ์šฉ๋ชจ๋ธ : WizardLM-13B-v1.2**

*/*์˜์–ด๊ถŒ ๋ฐ์ดํ„ฐ๋ฅผ ์ค‘์‹ฌ์œผ๋กœ ํ•™์Šตํ•œ WizardLM ๋ชจ๋ธ์„ ํŒŒ์ธํŠœ๋‹ ํ•˜์˜€๊ธฐ์— generalํ•œ ํ•œ๊ตญ ์ •๋ณด์— ๊ด€ํ•œ ์งˆ๋ฌธ์— ๋ฏธ์ˆ™ํ•ฉ๋‹ˆ๋‹ค.*/*


| Model                | Checkpoint  | Paper        | MT-Bench | AlpacaEval | GSM8k | HumanEval | Demo | License        |
|----------------------|-------------|--------------|----------|------------|-------|-----------|------|----------------|
| WizardLM-70B-V1.0    | ๐Ÿค— HF Link  | ๐Ÿ“ƒComing Soon| 7.78     | 92.91%     | 77.6% | 50.6      |      | Llama 2 License|
| WizardLM-13B-V1.2    | ๐Ÿค— HF Link  |              | 7.06     | 89.17%     | 55.3% | 36.6      | Demo | Llama 2 License|

ํ–ฅํ›„ ์ง„ํ–‰ ๋ฐฉํ–ฅ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค
1. more custom dataset์œผ๋กœ ํŒŒ์ธํŠœ๋‹
2. ์—ฌ๋Ÿฌ ํŒŒ๋ผ๋ฏธํ„ฐ ๋ชจ๋ธ์— ๋Œ€ํ•ด PEFT learning ์ง„ํ–‰ (30B, 7B, 70B...)
3. ko-llama2 ๋ชจ๋ธ์— ๋Œ€ํ•ด ํŒŒ์ธํŠœ๋‹



## 2. Training procedure


The following `bitsandbytes` quantization config was used during training:
- quant_method: gptq
- bits: 4
- tokenizer: None
- dataset: None
- group_size: 128
- damp_percent: 0.1
- desc_act: False
- sym: True
- true_sequential: True
- use_cuda_fp16: False
- model_seqlen: None
- block_name_to_quantize: None
- module_name_preceding_first_block: None
- batch_size: 1
- pad_token_id: None
- disable_exllama: True
- max_input_length: None
### Framework versions


- PEFT 0.6.0.dev0

@misc{xu2023wizardlm,
      title={WizardLM: Empowering Large Language Models to Follow Complex Instructions}, 
      author={Can Xu and Qingfeng Sun and Kai Zheng and Xiubo Geng and Pu Zhao and Jiazhan Feng and Chongyang Tao and Daxin Jiang},
      year={2023},
      eprint={2304.12244},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}