davidkim205
commited on
Commit
Β·
390e33b
1
Parent(s):
a815363
Update README.md
Browse files
README.md
CHANGED
@@ -38,20 +38,92 @@ korean multi-task instruction dataset
|
|
38 |
- CUDA Version: 12.2
|
39 |
|
40 |
## Training
|
41 |
-
Refer github
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
## Evaluation
|
44 |
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
-
| model | score | average score | % |
|
48 |
-
| ------------------------------ | ------- |---------------|------------|
|
49 |
-
| gpt-3.5-turbo | 147 | 3.97 | 79.45% |
|
50 |
-
| WizardLM-13B-V1.2 | 96 | 2.59 | 51.89% |
|
51 |
-
| Llama-2-7b-chat-hf | 67 | 1.81 | 36.21% |
|
52 |
-
| Llama-2-13b-chat-hf | 73 | 1.91 | 38.37% |
|
53 |
-
| **komt-llama2-7b-v1 (ours)** | **117** | **3.16** | **63.24%** |
|
54 |
-
| **komt-llama2-13b-v1 (ours)** | **129** | **3.48** | **69.72%** |
|
55 |
|
56 |
------------------------------------------------
|
57 |
# Original model card: Meta's Llama 2 7B-chat
|
|
|
38 |
- CUDA Version: 12.2
|
39 |
|
40 |
## Training
|
41 |
+
Refer https://github.com/davidkim205/komt
|
42 |
+
|
43 |
+
## Usage
|
44 |
+
```
|
45 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
46 |
+
from peft import PeftModel, PeftConfig
|
47 |
+
from transformers import TextStreamer, GenerationConfig
|
48 |
+
|
49 |
+
|
50 |
+
model='davidkim205/komt-llama2-13b-v1'
|
51 |
+
peft_model_name = 'davidkim205/komt-llama2-13b-v1-lora'
|
52 |
+
config = PeftConfig.from_pretrained(peft_model_name)
|
53 |
+
bnb_config = BitsAndBytesConfig(
|
54 |
+
load_in_4bit=True,
|
55 |
+
bnb_4bit_use_double_quant=True,
|
56 |
+
bnb_4bit_quant_type="nf4",
|
57 |
+
bnb_4bit_compute_dtype=torch.bfloat16
|
58 |
+
)
|
59 |
+
config.base_model_name_or_path =model
|
60 |
+
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, quantization_config=bnb_config, device_map="auto")
|
61 |
+
model = PeftModel.from_pretrained(model, peft_model_name)
|
62 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
63 |
+
streamer = TextStreamer(tokenizer)
|
64 |
+
|
65 |
+
def gen(x):
|
66 |
+
generation_config = GenerationConfig(
|
67 |
+
temperature=0.8,
|
68 |
+
top_p=0.8,
|
69 |
+
top_k=100,
|
70 |
+
max_new_tokens=512,
|
71 |
+
early_stopping=True,
|
72 |
+
do_sample=True,
|
73 |
+
)
|
74 |
+
q = f"### instruction: {x}\n\n### Response: "
|
75 |
+
gened = model.generate(
|
76 |
+
**tokenizer(
|
77 |
+
q,
|
78 |
+
return_tensors='pt',
|
79 |
+
return_token_type_ids=False
|
80 |
+
).to('cuda'),
|
81 |
+
generation_config=generation_config,
|
82 |
+
pad_token_id=tokenizer.eos_token_id,
|
83 |
+
eos_token_id=tokenizer.eos_token_id,
|
84 |
+
streamer=streamer,
|
85 |
+
)
|
86 |
+
result_str = tokenizer.decode(gened[0])
|
87 |
+
|
88 |
+
start_tag = f"\n\n### Response: "
|
89 |
+
start_index = result_str.find(start_tag)
|
90 |
+
|
91 |
+
if start_index != -1:
|
92 |
+
result_str = result_str[start_index + len(start_tag):].strip()
|
93 |
+
return result_str
|
94 |
+
|
95 |
+
print(gen('μ μ£Όλλ₯Ό 1λ°2μΌλ‘ νΌμ μ¬ννλ €κ³ νλλ° μ¬ν μ½μ€λ₯Ό λ§λ€μ΄μ€'))
|
96 |
+
```
|
97 |
+
output
|
98 |
+
```
|
99 |
+
### Response: μ μ£Όλλ₯Ό 1λ°2μΌλ‘ νΌμ μ¬ννλ €λ©΄ λ€μκ³Ό κ°μ μ¬ν μ½μ€λ₯Ό λ§λ€μ΄ κ³νν μ μμ΅λλ€:
|
100 |
+
|
101 |
+
1μΌμ°¨:
|
102 |
+
- μμΉ¨: μ μ£Όλμ μλ¦λ€μ΄ ν΄λ³μ ꡬ경νκΈ° μν΄ ν΄λ³μ λμ°©νμΈμ. μΌμΆμ κ°μνλ©° μμ°μ μλ¦λ€μμ λ§λ½νμΈμ.
|
103 |
+
- μ€ν: μ μ£Όλμ λνμ μΈ κ΄κ΄μ§μΈ νλΌμ°μ νννμΈμ. λ±μ°λ‘λ₯Ό λ°λΌ μ¬λΌκ°λ©΄μ κ²½μΉλ₯Ό μ¦κΈ°κ³ μ€λͺ
μ λ£μΌλ©° μ¬μ΄ μ°μ±
μ μ¦κΈ°μΈμ.
|
104 |
+
- μ λ
: μ μ£Όλμ λ§μλ μμμ μμ μ λ
μ 보λ΄μΈμ. μ μ ν ν΄μ°λ¬Όκ³Ό ν₯μ λ£λ‘ λ§λ μμμ λ§λ³΄λ κ²μ μ μ£Όλ μ¬νμ μλ²½ν κ²½νμ΄ λ κ²μ
λλ€.
|
105 |
+
|
106 |
+
2μΌμ°¨:
|
107 |
+
- μμΉ¨: νλΌμ° μΌλλ₯Ό νννκΈ° μν΄ νλΌμ° μΌμ΄νλ‘ μ΄λνμΈμ. μ΄ μΌμ΄νλ λ±μ°μ μ¦κΈ°λ μ¬λλ€μκ² μ΅μ μ μ νμ
λλ€.
|
108 |
+
|
109 |
+
```
|
110 |
## Evaluation
|
111 |
|
112 |
+
| model | score | average(0~5) | percentage |
|
113 |
+
| --------------------------------------- | ------- | ------------ | ---------- |
|
114 |
+
| gpt-3.5-turbo(close) | 147 | 3.97 | 79.45% |
|
115 |
+
| naver Cue(close) | 140 | 3.78 | 75.67% |
|
116 |
+
| clova X(close) | 136 | 3.67 | 73.51% |
|
117 |
+
| WizardLM-13B-V1.2(open) | 96 | 2.59 | 51.89% |
|
118 |
+
| Llama-2-7b-chat-hf(open) | 67 | 1.81 | 36.21% |
|
119 |
+
| Llama-2-13b-chat-hf(open) | 73 | 1.91 | 38.37% |
|
120 |
+
| nlpai-lab/kullm-polyglot-12.8b-v2(open) | 70 | 1.89 | 37.83% |
|
121 |
+
| kfkas/Llama-2-ko-7b-Chat(open) | 96 | 2.59 | 51.89% |
|
122 |
+
| beomi/KoAlpaca-Polyglot-12.8B(open) | 100 | 2.70 | 54.05% |
|
123 |
+
| **komt-llama2-7b-v1 (open)(ours)** | **117** | **3.16** | **63.24%** |
|
124 |
+
| **komt-llama2-13b-v1 (open)(ours)** | **129** | **3.48** | **69.72%** |
|
125 |
+
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
------------------------------------------------
|
129 |
# Original model card: Meta's Llama 2 7B-chat
|