davidkim205 commited on
Commit
092f9c6
β€’
1 Parent(s): b8ed0ff

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +137 -0
README.md ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - ko
5
+ pipeline_tag: text-generation
6
+ inference: false
7
+ tags:
8
+ - facebook
9
+ - meta
10
+ - pytorch
11
+ - llama
12
+ - llama-2
13
+ - llama-2-chat
14
+ library_name: peft
15
+ ---
16
+ # komt : korean multi task instruction tuning model
17
+ ![multi task instruction tuning.jpg](https://github.com/davidkim205/komt/assets/16680469/c7f6ade7-247e-4b62-a94f-47e19abea68e)
18
+
19
+ Recently, due to the success of ChatGPT, numerous large language models have emerged in an attempt to catch up with ChatGPT's capabilities.
20
+ However, when it comes to Korean language performance, it has been observed that many models still struggle to provide accurate answers or generate Korean text effectively.
21
+ This study addresses these challenges by introducing a multi-task instruction technique that leverages supervised datasets from various tasks to create training data for Large Language Models (LLMs).
22
+
23
+ ## Model Details
24
+
25
+ * **Model Developers** : davidkim(changyeon kim)
26
+ * **Repository** : https://github.com/davidkim205/komt
27
+ * **Lora target modules** : q_proj, o_proj, v_proj, gate_proj, down_proj, k_proj, up_proj
28
+ * **Model Size** : 84MB
29
+ * **Model Architecture** : The komt-mistral-7b-v1 is is a fine-tuned version of the Mistral-7B-Instruct-v0.1.
30
+
31
+
32
+ ## Dataset
33
+ korean multi-task instruction dataset
34
+
35
+ ## Hardware and Software
36
+ - nvidia driver : 535.54.03
37
+ - CUDA Version: 12.2
38
+
39
+ ## Training
40
+ Refer https://github.com/davidkim205/komt
41
+
42
+ ## Prompt template: Mistral
43
+ ```
44
+ <s>[INST] {prompt} [/INST]</s>
45
+ ```
46
+
47
+ ## Usage
48
+ ```
49
+ import torch
50
+
51
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
52
+ from peft import PeftModel, PeftConfig
53
+ from transformers import TextStreamer, GenerationConfig
54
+
55
+
56
+ model='davidkim205/komt-mistral-7b-v1'
57
+ peft_model_name = 'davidkim205/komt-mistral-7b-v1-lora'
58
+ config = PeftConfig.from_pretrained(peft_model_name)
59
+ bnb_config = BitsAndBytesConfig(
60
+ load_in_4bit=True,
61
+ bnb_4bit_use_double_quant=True,
62
+ bnb_4bit_quant_type="nf4",
63
+ bnb_4bit_compute_dtype=torch.bfloat16
64
+ )
65
+ config.base_model_name_or_path =model
66
+ model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, quantization_config=bnb_config, device_map="auto")
67
+ model = PeftModel.from_pretrained(model, peft_model_name)
68
+ tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
69
+ streamer = TextStreamer(tokenizer)
70
+
71
+ def gen(x):
72
+ generation_config = GenerationConfig(
73
+ temperature=0.8,
74
+ top_p=0.8,
75
+ top_k=100,
76
+ max_new_tokens=1024,
77
+ early_stopping=True,
78
+ do_sample=True,
79
+ )
80
+ q = f"[INST]{x} [/INST]"
81
+ gened = model.generate(
82
+ **tokenizer(
83
+ q,
84
+ return_tensors='pt',
85
+ return_token_type_ids=False
86
+ ).to('cuda'),
87
+ generation_config=generation_config,
88
+ pad_token_id=tokenizer.eos_token_id,
89
+ eos_token_id=tokenizer.eos_token_id,
90
+ streamer=streamer,
91
+ )
92
+ result_str = tokenizer.decode(gened[0])
93
+
94
+ start_tag = f"[/INST]"
95
+ start_index = result_str.find(start_tag)
96
+
97
+ if start_index != -1:
98
+ result_str = result_str[start_index + len(start_tag):].strip()
99
+ return result_str
100
+
101
+ result = gen('μ œμ£Όλ„λ₯Ό 1λ°•2일둜 혼자 μ—¬ν–‰ν•˜λ €κ³  ν•˜λŠ”λ° μ—¬ν–‰ μ½”μŠ€λ₯Ό λ§Œλ“€μ–΄μ€˜')
102
+
103
+ print('##########')
104
+ print(result)
105
+ ```
106
+ output
107
+ ```
108
+ <s> [INST]μ œμ£Όλ„λ₯Ό 1λ°•2일둜 혼자 μ—¬ν–‰ν•˜λ €κ³  ν•˜λŠ”λ° μ—¬ν–‰ μ½”μŠ€λ₯Ό λ§Œλ“€μ–΄μ€˜ [/INST]μ œμ£Όλ„μ˜ μ•„λ¦„λ‹€μš΄ μžμ—° κ²½κ΄€κ³Ό λ¬Έν™”μœ μ‚°μ„ 느끼고 μ‹Άλ‹€λ©΄ λ‹€μŒκ³Ό 같은 μ½”μŠ€λ₯Ό μΆ”μ²œν•œλ‹€.
109
+
110
+ 첫 번째 μ½”μŠ€λŠ” μ•„λ¦„λ‹€μš΄ ν•΄μ•ˆ κ²½κ΄€κ³Ό ν•΄μ•ˆμ‚¬κ΅¬λ₯Ό κ°μƒν•˜κΈ° μœ„ν•΄ 제주 μ„œλΆ€ ν•΄μ•ˆμœΌλ‘œ μ΄λ™ν•˜λŠ” 것이닀. 제주 μ‹œλ‚΄μ—μ„œ μ™Όμͺ½ λ°©ν–₯으둜 νƒλ‚˜λ©΄ ν•œλ¦Όν•΄μˆ˜μš•μž₯, μ„±μ‚°ν•΄μˆ˜μš•μž₯, λ΄‰λ™ν•΄μˆ˜μš•μž₯ λ“± 유λͺ…ν•œ ν•΄μˆ˜μš•μž₯을 κ²½μœ ν•  수 μžˆλ‹€. 이 지역은 맑은 바닀와 넓은 ν•΄μ•ˆμ—μ„œ ν•΄μˆ˜μš•μ„ 즐길 수 있으며, ν•΄μˆ˜μš•μž₯ μ£Όλ³€μ—λŠ” λ§Žμ€ μŒμ‹μ μ΄ μžˆμ–΄ 배식을 즐길 수 μžˆλ‹€. μ„œμͺ½ ν•΄μ•ˆμœΌλ‘œ μ΄λ™ν•˜λŠ” λ™μ•ˆ 제주 λŒ€ν‘œ μ‚¬κ³„μ ˆ 맛집인 ν—ˆλΈŒ μˆ˜ν”„ 및 μ†ŒλΌλΉ„ λ“± λ§›μžˆλŠ” μŒμ‹μ„ 맛볼 수 μžˆλ‹€. μ„œλΆ€ ν•΄μ•ˆμ„ λŒμ•„ λ‹€μ‹œ 제주 μ‹œλ‚΄λ‘œ λŒμ•„μ˜€λŠ” λ™μ•ˆ 제주 νŠΉμ‚°ν’ˆ μ‹œμž₯μ—μ„œ 제주 νŠΉμ‚°ν’ˆμ„ μ‚΄ 수 μžˆλ‹€.
111
+
112
+ 두 번째 μ½”μŠ€λŠ” 동뢀 ν•΄μ•ˆμ„ λŒμ•„λ³΄λŠ” 것이닀. 제주 μ‹œλ‚΄μ—μ„œ 였λ₯Έμͺ½ λ°©ν–₯으둜 νƒλ‚˜λ©΄ μ•„μ΄μŠ€ν¬λ¦Ό 거리인 ν•œλ¦Όν•΄μˆ˜μš•μž₯, μ„±μ‚°ν•΄μˆ˜μš•μž₯, λ΄‰λ™ν•΄μˆ˜μš•μž₯ λ“± λ‹€μ‹œ ν•œ 번 유λͺ…ν•œ ν•΄μˆ˜μš•μž₯을 κ²½μœ ν•  수 μžˆλ‹€. 이 지역은 ν•΄μˆ˜μš•μž₯ μ£Όλ³€μ—λŠ” λ§Žμ€ μŒμ‹μ μ΄ μžˆμ–΄ 배식을 즐길 수 μžˆλ‹€. 동뢀 ν•΄μ•ˆμ„ λŒμ•„ λ‹€μ‹œ 제주 μ‹œλ‚΄λ‘œ λŒμ•„μ˜€λŠ” λ™μ•ˆ 제주 νŠΉμ‚°ν’ˆ μ‹œμž₯μ—μ„œ 제주 νŠΉμ‚°ν’ˆμ„ μ‚΄ 수 μžˆλ‹€. 이 μ§€μ—­μ—λŠ” λ§Žμ€ μŒμ‹μ μ΄ μžˆμ–΄ λ§›μžˆλŠ” μŒμ‹μ„ 맛볼 수 μžˆλ‹€.
113
+
114
+ μ„Έ 번째 μ½”μŠ€λŠ” 제주 λ‚¨λΆ€λ‘œ μ΄λ™ν•˜λŠ” 것이닀. 제주 μ‹œλ‚΄μ—μ„œ 였λ₯Έμͺ½ λ°©ν–₯으둜 νƒλ‚˜λ©΄ 제주 λ‚¨λΆ€λ‘œ 이동할 수 μžˆλ‹€. 이 지역은 ���라산 ꡭ립곡원이 μœ„μΉ˜ν•΄ μžˆμ–΄ μžμ—° 경관을 감상할 수 μžˆλ‹€. ν•œλΌμ‚° ꡭ립곡원 λ‚΄μ—λŠ” λ‹€μ–‘ν•œ μžμ—° κ²½κ΄€κ³Ό μ‚°μ•… 경둜λ₯Ό 즐길 수 μžˆλŠ” 탐방 μ½”μŠ€κ°€ μžˆλ‹€. λ˜ν•œ, 제주 λ‚¨λΆ€λŠ” λ§Žμ€ ν•΄μˆ˜μš•μž₯κ³Ό 골프μž₯이 μœ„μΉ˜ν•΄ μžˆμ–΄ ν•΄μˆ˜μš•κ³Ό 골프λ₯Ό 즐길 수 μžˆλ‹€. λ‚¨λΆ€λ‘œ μ΄λ™ν•˜λŠ” λ™μ•ˆ 제주 νŠΉμ‚°ν’ˆ μ‹œμž₯μ—μ„œ 제주 νŠΉμ‚°ν’ˆμ„ μ‚΄ 수 μžˆλ‹€.
115
+
116
+
117
+ ```
118
+ ## Evaluation
119
+ For objective model evaluation, we initially used EleutherAI's lm-evaluation-harness but obtained unsatisfactory results. Consequently, we conducted evaluations using ChatGPT, a widely used model, as described in [Self-Alignment with Instruction Backtranslation](https://arxiv.org/pdf/2308.06502.pdf) and [Three Ways of Using Large Language Models to Evaluate Chat](https://arxiv.org/pdf/2308.06259.pdf) .
120
+
121
+
122
+ | model | score | average(0~5) | percentage |
123
+ | --------------------------------------- |---------| ------------ | ---------- |
124
+ | gpt-3.5-turbo(close) | 147 | 3.97 | 79.45% |
125
+ | naver Cue(close) | 140 | 3.78 | 75.67% |
126
+ | clova X(close) | 136 | 3.67 | 73.51% |
127
+ | WizardLM-13B-V1.2(open) | 96 | 2.59 | 51.89% |
128
+ | Llama-2-7b-chat-hf(open) | 67 | 1.81 | 36.21% |
129
+ | Llama-2-13b-chat-hf(open) | 73 | 1.91 | 38.37% |
130
+ | nlpai-lab/kullm-polyglot-12.8b-v2(open) | 70 | 1.89 | 37.83% |
131
+ | kfkas/Llama-2-ko-7b-Chat(open) | 96 | 2.59 | 51.89% |
132
+ | beomi/KoAlpaca-Polyglot-12.8B(open) | 100 | 2.70 | 54.05% |
133
+ | **komt-llama2-7b-v1 (open)(ours)** | **117** | **3.16** | **63.24%** |
134
+ | **komt-llama2-13b-v1 (open)(ours)** | **129** | **3.48** | **69.72%** |
135
+ | **komt-llama-30b-v1 (open)(ours)** | **129** | **3.16** | **63.24%** |
136
+ | **komt-mistral-7b-v1 (open)(ours)** | **131** | **3.54** | **70.81%** |
137
+