lamhieu commited on
Commit
a9ec5a9
β€’
1 Parent(s): 97618f6

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +390 -0
README.md ADDED
@@ -0,0 +1,390 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - vi
5
+ license: mit
6
+ library_name: transformers
7
+ tags:
8
+ - ghost
9
+ - awq
10
+ pipeline_tag: text-generation
11
+ model-index:
12
+ - name: ghost-7b-v0.9.1
13
+ results:
14
+ - task:
15
+ type: text-generation
16
+ name: Text Generation
17
+ dataset:
18
+ name: AI2 Reasoning Challenge (25-Shot)
19
+ type: ai2_arc
20
+ config: ARC-Challenge
21
+ split: test
22
+ args:
23
+ num_few_shot: 25
24
+ metrics:
25
+ - type: acc_norm
26
+ value: 55.38
27
+ name: normalized accuracy
28
+ source:
29
+ url: >-
30
+ https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=lamhieu/ghost-7b-v0.9.1
31
+ name: Open LLM Leaderboard
32
+ - task:
33
+ type: text-generation
34
+ name: Text Generation
35
+ dataset:
36
+ name: HellaSwag (10-Shot)
37
+ type: hellaswag
38
+ split: validation
39
+ args:
40
+ num_few_shot: 10
41
+ metrics:
42
+ - type: acc_norm
43
+ value: 77.03
44
+ name: normalized accuracy
45
+ source:
46
+ url: >-
47
+ https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=lamhieu/ghost-7b-v0.9.1
48
+ name: Open LLM Leaderboard
49
+ - task:
50
+ type: text-generation
51
+ name: Text Generation
52
+ dataset:
53
+ name: MMLU (5-Shot)
54
+ type: cais/mmlu
55
+ config: all
56
+ split: test
57
+ args:
58
+ num_few_shot: 5
59
+ metrics:
60
+ - type: acc
61
+ value: 54.78
62
+ name: accuracy
63
+ source:
64
+ url: >-
65
+ https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=lamhieu/ghost-7b-v0.9.1
66
+ name: Open LLM Leaderboard
67
+ - task:
68
+ type: text-generation
69
+ name: Text Generation
70
+ dataset:
71
+ name: TruthfulQA (0-shot)
72
+ type: truthful_qa
73
+ config: multiple_choice
74
+ split: validation
75
+ args:
76
+ num_few_shot: 0
77
+ metrics:
78
+ - type: mc2
79
+ value: 43.96
80
+ source:
81
+ url: >-
82
+ https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=lamhieu/ghost-7b-v0.9.1
83
+ name: Open LLM Leaderboard
84
+ - task:
85
+ type: text-generation
86
+ name: Text Generation
87
+ dataset:
88
+ name: Winogrande (5-shot)
89
+ type: winogrande
90
+ config: winogrande_xl
91
+ split: validation
92
+ args:
93
+ num_few_shot: 5
94
+ metrics:
95
+ - type: acc
96
+ value: 72.53
97
+ name: accuracy
98
+ source:
99
+ url: >-
100
+ https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=lamhieu/ghost-7b-v0.9.1
101
+ name: Open LLM Leaderboard
102
+ - task:
103
+ type: text-generation
104
+ name: Text Generation
105
+ dataset:
106
+ name: GSM8k (5-shot)
107
+ type: gsm8k
108
+ config: main
109
+ split: test
110
+ args:
111
+ num_few_shot: 5
112
+ metrics:
113
+ - type: acc
114
+ value: 26.91
115
+ name: accuracy
116
+ source:
117
+ url: >-
118
+ https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard?query=lamhieu/ghost-7b-v0.9.1
119
+ name: Open LLM Leaderboard
120
+ widget:
121
+ - text: How many helicopters can a human eat in one sitting
122
+ output:
123
+ text: >-
124
+ Ahoy, me matey! A human can eat approximately one helicopter in one
125
+ sitting, but only if they're a giant sea monster with a stomach the size
126
+ of a small country. 🀒🀒 So, it's not advisable to try this, pirate! πŸ°πŸ›’οΈ
127
+ model_creator: Hieu Lam
128
+ model_name: Ghost 7B v0.9.1
129
+ model_type: mistral
130
+ prompt_template: <|system|>\n</s>\n<|user|>\n{prompt}</s><|assistant|>\n
131
+ ---
132
+
133
+ # Model Card for Model ID
134
+
135
+ **[Ghost 7B Alpha, flying, v0.9.1](https://huggingface.co/lamhieu/ghost-7b-v0.9.1)**, AWQ.
136
+
137
+ [▢️ Experience it on Colab](https://tinyurl.com/ghost7b091)
138
+
139
+ ### Come on, create yourself an AI assistant, according to your wishes!
140
+
141
+ In your language, maybe Vietnamese.
142
+
143
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/600ae38cc92b79f54efd4556/_4EmivXdOYjQpBVpIO9WL.png" width="600" align="center" />
144
+
145
+ Or, English.
146
+
147
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/600ae38cc92b79f54efd4556/ctmTOz5V7pHm0FnX8c6BD.png" width="600" align="center" />
148
+
149
+ ### Let the assistant become an expert, and more.
150
+
151
+ The challenge of the model's ability to understand the language.
152
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/600ae38cc92b79f54efd4556/N0RJUFFf1t8QRg8AVyxNj.png" width="600" align="center" />
153
+
154
+ Challenge the model's reasoning ability, in Vietnamese language.
155
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/600ae38cc92b79f54efd4556/KUXjV2XJK5vNy7genVtfN.png" width="600" align="center" />
156
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/600ae38cc92b79f54efd4556/ngX6unqUNnnBGq4R1gYY2.png" width="600" align="center" />
157
+
158
+ In case of using Vietnamese language, it lacks accents, abbreviations or uses slang.
159
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/600ae38cc92b79f54efd4556/xSL8WErn5girbKxUbEOsh.png" width="600" align="center" />
160
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/600ae38cc92b79f54efd4556/-IXPjLL_QGb_5frOKftUW.png" width="600" align="center" />
161
+
162
+ ## πŸ“š Model Details
163
+
164
+ ### Model Description
165
+
166
+ A version to consider comprehension in generating languages other than the original language being initially trained, here is the Vietnamese language. A brief summary of the effectiveness of the **Mistral 7B** model for training with a new language is excellent and low cost.
167
+
168
+ I have started training the [Ghost 7B v0.9.0](https://huggingface.co/lamhieu/ghost-7b-v0.9.0) model again, with a smaller amount of data, it is estimated to be only about 150MB. In that data, about 70% is Vietnamese, the rest is almost English.
169
+ The approach here uses QLora for training then merges them. Also, I am very thankful to Unsloth for their features.
170
+
171
+ ### About AWQ and AutoAWQ
172
+
173
+ The AWQ algorithm for 4-bit quantization with a 2x speedup during inference.
174
+
175
+ > AutoAWQ is an easy-to-use package for 4-bit quantized models. AutoAWQ speeds up models by 3x and reduces memory requirements by 3x compared to FP16. AutoAWQ implements the Activation-aware Weight Quantization (AWQ) algorithm for quantizing LLMs. AutoAWQ was created and improved upon from the original work from MIT.
176
+
177
+ ```
178
+ @article{lin2023awq,
179
+ title={AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration},
180
+ author={Lin, Ji and Tang, Jiaming and Tang, Haotian and Yang, Shang and Dang, Xingyu and Han, Song},
181
+ journal={arXiv},
182
+ year={2023}
183
+ }
184
+ ```
185
+
186
+ ## ⛹️‍♂️ Uses
187
+
188
+ ### Online using Google Colab
189
+
190
+ To make it easier to play around with the model, I created a notebook in [Google Colab](https://tinyurl.com/ghost7b091) so you can start experimenting.
191
+
192
+ ### Directly
193
+
194
+ For direct use, you can easily get started with the following steps.
195
+
196
+ * Firstly, you need to install **transformers** via the command below with `pip`.
197
+ ```bash
198
+ pip install -U transformers
199
+ ```
200
+
201
+ * Right now, you can start using the model directly.
202
+ ```python
203
+ import torch
204
+ from transformers import (
205
+ AutoModelForCausalLM,
206
+ AutoTokenizer,
207
+ )
208
+
209
+ base_model = "lamhieu/ghost-7b-v0.9.1"
210
+ model = AutoModelForCausalLM.from_pretrained(
211
+ base_model,
212
+ torch_dtype=torch.bfloat16,
213
+ trust_remote_code=True,
214
+ device_map="auto",
215
+ )
216
+ tokenizer = AutoTokenizer.from_pretrained(base_model)
217
+
218
+ messages = [
219
+ {"role": "system", "content": "You are a friendly chatbot who always responds in the style of a pirate"},
220
+ {"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
221
+ ]
222
+ prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
223
+ tokenized = tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
224
+ outputs = model.generate(**tokenized, max_new_tokens=512)
225
+ results = tokenizer.batch_decode(outputs)[0]
226
+ print(results)
227
+ ```
228
+
229
+ * Additionally, you can also use a model with **4bit quantization** to reduce the required resources at least. You can start with the code below.
230
+ ```python
231
+ import torch
232
+ from transformers import (
233
+ AutoModelForCausalLM,
234
+ AutoTokenizer,
235
+ BitsAndBytesConfig,
236
+ )
237
+
238
+ base_model = "lamhieu/ghost-7b-v0.9.1"
239
+ bnb_config = BitsAndBytesConfig(
240
+ load_in_4bit=True,
241
+ bnb_4bit_quant_type="nf4",
242
+ bnb_4bit_compute_dtype=torch.bfloat16,
243
+ bnb_4bit_use_double_quant=False,
244
+ )
245
+ model = AutoModelForCausalLM.from_pretrained(
246
+ base_model,
247
+ quantization_config=bnb_config,
248
+ trust_remote_code=True,
249
+ device_map="auto",
250
+ )
251
+ tokenizer = AutoTokenizer.from_pretrained(base_model)
252
+
253
+ messages = [
254
+ {"role": "system", "content": "You are a friendly chatbot who always responds in the style of a pirate"},
255
+ {"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
256
+ ]
257
+ prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
258
+ tokenized = tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
259
+ outputs = model.generate(**tokenized, max_new_tokens=512)
260
+ results = tokenizer.batch_decode(outputs)[0]
261
+ print(results)
262
+ ```
263
+
264
+
265
+ ### Summary
266
+
267
+ Although the amount of training data is small, it is "great". You don't need to worry too much that it won't be able to meet some of your requirements. Instead, try experimenting with the model of what you want.
268
+ One more thing, use it like you would **ChatGPT**, I've purposely tweaked it to be able to replace my app (for some tasks, and it does a good job). It's okay with both Vietnamese and English languages. It would be great to hear feedback about the experience, feel free to leave information in the discussion section.
269
+
270
+ Setting up the system prompt will have a great impact on the performance and quality of the content generated by the model. Keep this in mind to always ensure the model is used for your intended purpose, the goal is to achieve good results but.
271
+ It's best to always set system, you can still leave it empty if you always want to set it.
272
+
273
+ ## πŸ₯‡ Evaluation
274
+
275
+ ### [Open LLM Leaderboard Evaluation Results](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard)
276
+ Detailed results can be found [here](https://huggingface.co/datasets/open-llm-leaderboard/details_lamhieu__ghost-7b-v0.9.1)
277
+
278
+ | Metric |Value|
279
+ |---------------------------------|----:|
280
+ |Avg. |55.10|
281
+ |AI2 Reasoning Challenge (25-Shot)|55.38|
282
+ |HellaSwag (10-Shot) |77.03|
283
+ |MMLU (5-Shot) |54.78|
284
+ |TruthfulQA (0-shot) |43.96|
285
+ |Winogrande (5-shot) |72.53|
286
+ |GSM8k (5-shot) |26.91|
287
+
288
+ ### VMLU
289
+
290
+ A Vietnamese Multitask Language Understanding Benchmark Suite for Large Language Models.
291
+
292
+ With the score achieved, the model can rank **3rd** in VMLU's "Leaderboard of fine-tuned models" list, as of the date of evaluation.
293
+
294
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/600ae38cc92b79f54efd4556/yuDiym9y_o_tlRVr90pGX.png)
295
+
296
+ <details>
297
+ <summary>Details</summary>
298
+
299
+ ```json
300
+ {
301
+ "humanity": {
302
+ "administrative_law": 52.22,
303
+ "business_law": 40.22,
304
+ "civil_law": 46.11,
305
+ "criminal_law": 49.08,
306
+ "economic_law": 39.75,
307
+ "education_law": 42.17,
308
+ "elementary_history": 55.37,
309
+ "high_school_history": 36.67,
310
+ "high_school_literature": 37.78,
311
+ "history_of_world_civilization": 46.67,
312
+ "idealogical_and_moral_cultivation": 50,
313
+ "introduction_to_laws": 45.24,
314
+ "vietnamese_language_and_literature": 34.48,
315
+ "total": 43.3,
316
+ "revolutionary_policy_of_the_vietnamese_commununist_part": 51.11,
317
+ "introduction_to_vietnam_culture": 30.56,
318
+ "logic": 27.01,
319
+ "middle_school_history": 44.44,
320
+ "middle_school_literature": 50.57
321
+ },
322
+ "stem": {
323
+ "total": 34.73,
324
+ "applied_informatics": 50.56,
325
+ "computer_architecture": 33.89,
326
+ "computer_network": 43.02,
327
+ "discrete_mathematics": 31.52,
328
+ "electrical_engineering": 30.68,
329
+ "elementary_mathematics": 30,
330
+ "elementary_science": 58.89,
331
+ "high_school_biology": 38.33,
332
+ "high_school_chemistry": 28.89,
333
+ "high_school_mathematics": 26.35,
334
+ "high_school_physics": 29.44,
335
+ "introduction_to_chemistry": 27.37,
336
+ "introduction_to_physics": 31.79,
337
+ "introduction_to_programming": 36.31,
338
+ "metrology_engineer": 31.21,
339
+ "middle_school_biology": 46.47,
340
+ "middle_school_chemistry": 30.56,
341
+ "middle_school_mathematics": 30.56,
342
+ "middle_school_physics": 30,
343
+ "operating_system": 40.56,
344
+ "statistics_and_probability": 22.99
345
+ },
346
+ "total": 39.58,
347
+ "other": {
348
+ "accountant": 31.55,
349
+ "civil_servant": 42.11,
350
+ "clinical_pharmacology": 33.89,
351
+ "driving_license_certificate": 59.06,
352
+ "environmental_engineering": 28.07,
353
+ "internal_basic_medicine": 39.77,
354
+ "preschool_pedagogy": 46.08,
355
+ "tax_accountant": 22.41,
356
+ "tax_civil_servant": 47.95,
357
+ "total": 38.99
358
+ },
359
+ "social_science": {
360
+ "business_administration": 41.38,
361
+ "high_school_civil_education": 45,
362
+ "high_school_geography": 34.57,
363
+ "ho_chi_minh_ideology": 48.04,
364
+ "macroeconomics": 31.11,
365
+ "microeconomics": 37.22,
366
+ "middle_school_civil_education": 66.29,
367
+ "middle_school_geography": 48.3,
368
+ "principles_of_marxism_and_leninism": 30,
369
+ "sociology": 53.93,
370
+ "total": 43.58
371
+ }
372
+ }
373
+ ```
374
+
375
+ </details>
376
+
377
+
378
+ ## πŸ“œ More Information
379
+
380
+ Note, this is a personal research project with a limited budget, so the model only stops at the evaluation level with the developed approach. Apart from that, I think I can definitely build a model with better quality in terms of language and other performance using this approach.
381
+
382
+ ### Thanks for the support
383
+
384
+ Model trained with **Unsloth**, many thanks.
385
+
386
+ <img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/made with unsloth.png" width="200px" align="center" />
387
+
388
+ ## πŸ“¨ Model Card Contact
389
+
390
+ **Lam Hieu** (lamhieu.vk@gmail.com)