mav23 commited on
Commit
e222fd7
·
verified ·
1 Parent(s): c743f37

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ openthaigpt1.5-72b-instruct.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,344 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: qwen
4
+ language:
5
+ - th
6
+ - en
7
+ library_name: transformers
8
+ pipeline_tag: text-generation
9
+ tags:
10
+ - openthaigpt
11
+ - qwen
12
+ ---
13
+
14
+ # 🇹🇭 OpenThaiGPT 72b 1.5 Instruct
15
+ ![OpenThaiGPT](https://1173516064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvvbWvIIe82Iv1yHaDBC5%2Fuploads%2Fb8eiMDaqiEQL6ahbAY0h%2Fimage.png?alt=media&token=6fce78fd-2cca-4c0a-9648-bd5518e644ce)
16
+ [More Info](https://openthaigpt.aieat.or.th/)
17
+
18
+ 🇹🇭 **OpenThaiGPT 72b Version 1.5** is an advanced 72-billion-parameter Thai language chat model based on Qwen v2.5 released on September 30, 2024. It has been specifically fine-tuned on over 2,000,000 Thai instruction pairs and is capable of answering Thai-specific domain questions.
19
+
20
+ <a href="https://cdn-uploads.huggingface.co/production/uploads/5fcd9c426d942eaf4d1ebd30/NoVK86trV6I8LSEduOQ_K.png" target="_blank"><img src="https://cdn-uploads.huggingface.co/production/uploads/5fcd9c426d942eaf4d1ebd30/NoVK86trV6I8LSEduOQ_K.png" style="width:800px"></a>
21
+
22
+ ## Online Demo:
23
+ https://demo72b.aieat.or.th/
24
+
25
+ ## Example code for API Calling
26
+ https://github.com/OpenThaiGPT/openthaigpt1.5_api_examples
27
+
28
+ ## Highlights
29
+ - **State-of-the-art Thai language LLM**, achieving the highest average scores across various Thai language exams compared to other open-source Thai LLMs.
30
+ - **Multi-turn conversation support** for extended dialogues.
31
+ - **Retrieval Augmented Generation (RAG) compatibility** for enhanced response generation.
32
+ - **Impressive context handling**: Processes up to 131,072 tokens of input and generates up to 8,192 tokens, enabling detailed and complex interactions.
33
+ - **Tool calling support**: Enables users to efficiently call various functions through intelligent responses.
34
+
35
+ ## Benchmark on [OpenThaiGPT Eval](https://huggingface.co/datasets/openthaigpt/openthaigpt_eval)
36
+ ** Please take a look at ``openthaigpt/openthaigpt1.5-72b-instruct`` for this model's evaluation result.
37
+ | **Exam names** | **scb10x/llama-3-typhoon-v1.5x-70b-instruct** | **meta-llama/Llama-3.1-70B-Instruct** | **Qwen/Qwen2.5-72B-Instruct** | **openthaigpt/openthaigpt1.5-72b-instruct** |
38
+ |:------------------------------:|:---------------------------------------------:|:-------------------------------------:|:-----------------------------:|:----------------------------------:|
39
+ | **01_a_level** | 59.17% | 61.67% | 75.00% | 76.67% |
40
+ | **02_tgat** | 46.00% | 40.00% | 48.00% | 46.00% |
41
+ | **03_tpat1** | 52.50% | 50.00% | 55.00% | 55.00% |
42
+ | **04_investment_consult** | 60.00% | 52.00% | 80.00% | 72.00% |
43
+ | **05_facebook_beleble_th_200** | 87.50% | 88.00% | 90.00% | 90.00% |
44
+ | **06_xcopa_th_200** | 84.50% | 85.50% | 90.00% | 90.50% |
45
+ | **07_xnli2.0_th_200** | 62.50% | 63.00% | 65.50% | 70.50% |
46
+ | **08_onet_m3_thai** | 76.00% | 56.00% | 76.00% | 84.00% |
47
+ | **09_onet_m3_social** | 95.00% | 95.00% | 90.00% | 95.00% |
48
+ | **10_onet_m3_math** | 43.75% | 25.00% | 37.50% | 37.50% |
49
+ | **11_onet_m3_science** | 53.85% | 61.54% | 65.38% | 73.08% |
50
+ | **12_onet_m3_english** | 93.33% | 93.33% | 96.67% | 96.67% |
51
+ | **13_onet_m6_thai** | 55.38% | 60.00% | 60.00% | 56.92% |
52
+ | **14_onet_m6_math** | 41.18% | 58.82% | 23.53% | 41.18% |
53
+ | **15_onet_m6_social** | 67.27% | 76.36% | 63.64% | 65.45% |
54
+ | **16_onet_m6_science** | 50.00% | 57.14% | 64.29% | 67.86% |
55
+ | **17_onet_m6_english** | 73.08% | 82.69% | 86.54% | 90.38% |
56
+ | **Micro Average** | 69.97% | 71.09% | 75.02% | <b style="color:blue">76.73%</b> |
57
+
58
+
59
+ Thai language multiple choice exams, Test on unseen test set, Zero-shot learning. Benchmark source code and exams information: https://github.com/OpenThaiGPT/openthaigpt_eval
60
+
61
+ (Updated on: 30 September 2024)
62
+
63
+ ## Benchmark on [scb10x/thai_exam](https://huggingface.co/datasets/scb10x/thai_exam)
64
+
65
+ | Models | **Thai Exam (Acc)** |
66
+ |:----------------------------------------------------------:|:-------------------:|
67
+ | **api/claude-3-5-sonnet-20240620** | 69.2 |
68
+ | <b style="color:blue">**openthaigpt/openthaigpt1.5-72b-instruct***</b> | <b style="color:blue">64.07</b> |
69
+ | **api/gpt-4o-2024-05-13** | 63.89 |
70
+ | **hugging-quants/Meta-Llama-3.1-405B-Instruct-AWQ-INT4** | 63.54 |
71
+ | <b style="color:blue">**openthaigpt/openthaigpt1.5-14b-instruct***</b> | <b style="color:blue">59.65</b> |
72
+ | **scb10x/llama-3-typhoon-v1.5x-70b-instruct** | 58.76 |
73
+ | **Qwen/Qwen2-72B-Instruct** | 58.23 |
74
+ | **meta-llama/Meta-Llama-3.1-70B-Instruct** | 58.23 |
75
+ | **Qwen/Qwen2.5-14B-Instruct** | 57.35 |
76
+ | **api/gpt-4o-mini-2024-07-18** | 54.51 |
77
+ | <b style="color:blue">**openthaigpt/openthaigpt1.5-7b-instruct***</b> | <b style="color:blue">52.04</b> |
78
+ | **SeaLLMs/SeaLLMs-v3-7B-Chat** | 51.33 |
79
+ | **openthaigpt/openthaigpt-1.0.0-70b-chat** | 50.09 |
80
+
81
+ <b style="color:blue">*</b> Evaluated by OpenThaiGPT team using [scb10x/thai_exam](https://huggingface.co/datasets/scb10x/thai_exam).
82
+
83
+ (Updated on: 13 October 2024)
84
+
85
+ ## Licenses
86
+ * Built with Qwen
87
+ * Qwen License: Allow **Research** and **Commercial uses** but if your user base exceeds 100 million monthly active users, you need to negotiate a separate commercial license. Please see LICENSE file for more information.<br>
88
+
89
+ ## Sponsors
90
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/5fcd9c426d942eaf4d1ebd30/3kjN6kuTzXDXQ6o1RFvHX.png" width="600px">
91
+
92
+ ## Supports
93
+ - Official website: https://openthaigpt.aieat.or.th
94
+ - Facebook page: https://web.facebook.com/groups/openthaigpt
95
+ - A Discord server for discussion and support [here](https://discord.gg/rUTp6dfVUF)
96
+ - E-mail: [email protected]
97
+
98
+ ## Prompt Format
99
+ Prompt format is based on ChatML.
100
+ ```
101
+ <|im_start|>system\n{sytem_prompt}<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n
102
+ ```
103
+
104
+ ### System prompt:
105
+ ```
106
+ คุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์
107
+ ```
108
+
109
+ ### Examples
110
+
111
+ #### Single Turn Conversation Example
112
+ ```
113
+ <|im_start|>system\nคุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์<|im_end|>\n<|im_start|>user\nสวัสดีครับ<|im_end|>\n<|im_start|>assistant\n
114
+ ```
115
+
116
+ #### Single Turn Conversation with Context (RAG) Example
117
+ ```
118
+ <|im_start|>system\nคุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์<|im_end|>\n<|im_start|>user\nกรุงเทพมหานคร เป็นเมืองหลวง นครและมหานครที่มีประชากรมากที่สุดของประเทศไทย กรุงเทพมหานครมีพื้นที่ทั้งหมด 1,568.737 ตร.กม. มีประชากรตามทะเบียนราษฎรกว่า 8 ล้านคน\nกรุงเทพมหานครมีพื้นที่เท่าไร่<|im_end|>\n<|im_start|>assistant\n
119
+ ```
120
+
121
+ #### Multi Turn Conversation Example
122
+
123
+ ##### First turn
124
+ ```
125
+ <|im_start|>system\nคุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์<|im_end|>\n<|im_start|>user\nสวัสดีครับ<|im_end|>\n<|im_start|>assistant\n
126
+ ```
127
+
128
+ ##### Second turn
129
+ ```
130
+ <|im_start|>system\nคุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์<|im_end|>\n<|im_start|>user\nสวัสดีครับ<|im_end|>\n<|im_start|>assistant\nสวัสดีครับ ยินดีต้อนรับครับ คุณต้องการให้ฉันช่วยอะไรครับ?<|im_end|>\n<|im_start|>user\nกรุงเทพมหานคร ชื่อเต็มยาวๆคืออะไร<|im_end|>\n<|im_start|>assistant\n
131
+ ```
132
+
133
+ ##### Result
134
+ ```
135
+ <|im_start|>system\nคุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์<|im_end|>\n<|im_start|>user\nสวัสดีครับ<|im_end|>\n<|im_start|>assistant\nสวัสดีครับ ยินดีต้อนรับครับ คุณต้องการให้ฉันช่วยอะไรครับ?<|im_end|>\n<|im_start|>user\nกรุงเทพมหานคร ชื่อเต็มยาวๆคืออะไร<|im_end|>\n<|im_start|>assistant\nชื่อเต็มของกรุงเทพมหานครคือ \"กรุงเทพมหานคร อมรรัตนโกสินทร์ มหินทรายุธยา มหาดิลกภพ นพรัตนราชธานีบูรีรมย์ อุดมราชนิเวศน์มหาสถาน อมรพิมานอวตารสถิต สักกะทัตติยวิษณุกรรมประสิทธิ์\"
136
+ ```
137
+
138
+ ## How to use
139
+
140
+
141
+ ### Free API Service (hosted by Siam.Ai and Float16.cloud)
142
+
143
+ #### Siam.AI
144
+ ```bash
145
+ curl https://api.aieat.or.th/v1/completions \
146
+ -H "Content-Type: application/json" \
147
+ -H "Authorization: Bearer dummy" \
148
+ -d '{
149
+ "model": ".",
150
+ "prompt": "<|im_start|>system\nคุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์<|im_end|>\n<|im_start|>user\nกรุงเทพมหานครคืออะไร<|im_end|>\n<|im_start|>assistant\n",
151
+ "max_tokens": 512,
152
+ "temperature": 0.7,
153
+ "top_p": 0.8,
154
+ "top_k": 40,
155
+ "stop": ["<|im_end|>"]
156
+ }'
157
+ ```
158
+
159
+ #### Float16
160
+ ```bash
161
+ curl -X POST https://api.float16.cloud/dedicate/78y8fJLuzE/v1/chat/completions \
162
+ -H "Content-Type: application/json" \
163
+ -H "Authorization: Bearer float16-AG0F8yNce5s1DiXm1ujcNrTaZquEdaikLwhZBRhyZQNeS7Dv0X" \
164
+ -d '{
165
+ "model": "openthaigpt/openthaigpt1.5-7b-instruct",
166
+ "messages": [
167
+ {
168
+ "role": "system",
169
+ "content": "คุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์"
170
+ },
171
+ {
172
+ "role": "user",
173
+ "content": "สวัสดี"
174
+ }
175
+ ]
176
+ }'
177
+ ```
178
+
179
+ ### OpenAI Client Library (Hosted by VLLM, please see below.)
180
+ ```python
181
+ import openai
182
+
183
+ # Configure OpenAI client to use vLLM server
184
+ openai.api_base = "http://127.0.0.1:8000/v1"
185
+ openai.api_key = "dummy" # vLLM doesn't require a real API key
186
+
187
+ prompt = "<|im_start|>system\nคุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์<|im_end|>\n<|im_start|>user\nกรุงเทพมหานครคืออะไร<|im_end|>\n<|im_start|>assistant\n"
188
+
189
+ try:
190
+ response = openai.Completion.create(
191
+ model=".", # Specify the model you're using with vLLM
192
+ prompt=prompt,
193
+ max_tokens=512,
194
+ temperature=0.7,
195
+ top_p=0.8,
196
+ top_k=40,
197
+ stop=["<|im_end|>"]
198
+ )
199
+ print("Generated Text:", response.choices[0].text)
200
+ except Exception as e:
201
+ print("Error:", str(e))
202
+ ```
203
+
204
+ ### Huggingface
205
+ ```python
206
+ from transformers import AutoModelForCausalLM, AutoTokenizer
207
+
208
+ model_name = "openthaigpt/openthaigpt1.5-72b-instruct"
209
+
210
+ model = AutoModelForCausalLM.from_pretrained(
211
+ model_name,
212
+ torch_dtype="auto",
213
+ device_map="auto"
214
+ )
215
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
216
+
217
+ prompt = "ประเทศไทยคืออะไร"
218
+ messages = [
219
+ {"role": "system", "content": "คุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์"},
220
+ {"role": "user", "content": prompt}
221
+ ]
222
+ text = tokenizer.apply_chat_template(
223
+ messages,
224
+ tokenize=False,
225
+ add_generation_prompt=True
226
+ )
227
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
228
+
229
+ generated_ids = model.generate(
230
+ **model_inputs,
231
+ max_new_tokens=512
232
+ )
233
+ generated_ids = [
234
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
235
+ ]
236
+
237
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
238
+ ```
239
+
240
+ ### vLLM
241
+
242
+ 1. Install VLLM (https://github.com/vllm-project/vllm)
243
+
244
+ 2. Run server
245
+ ```bash
246
+ vllm serve openthaigpt/openthaigpt1.5-72b-instruct --tensor-parallel-size 4
247
+ ```
248
+ * Note, change ``--tensor-parallel-size 4`` to the amount of available GPU cards.
249
+
250
+ 3. Run inference (CURL example)
251
+ ```bash
252
+ curl -X POST 'http://127.0.0.1:8000/v1/completions' \
253
+ -H 'Content-Type: application/json' \
254
+ -d '{
255
+ "model": ".",
256
+ "prompt": "<|im_start|>system\nคุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์<|im_end|>\n<|im_start|>user\nสวัสดีครับ<|im_end|>\n<|im_start|>assistant\n",
257
+ "max_tokens": 512,
258
+ "temperature": 0.7,
259
+ "top_p": 0.8,
260
+ "top_k": 40,
261
+ "stop": ["<|im_end|>"]
262
+ }'
263
+ ```
264
+
265
+ ### Processing Long Texts
266
+
267
+ The current `config.json` is set for context length up to 32,768 tokens.
268
+ To handle extensive inputs exceeding 32,768 tokens, we utilize [YaRN](https://arxiv.org/abs/2309.00071), a technique for enhancing model length extrapolation, ensuring optimal performance on lengthy texts.
269
+
270
+ For supported frameworks, you could add the following to `config.json` to enable YaRN:
271
+ ```json
272
+ {
273
+ ...,
274
+ "rope_scaling": {
275
+ "factor": 4.0,
276
+ "original_max_position_embeddings": 32768,
277
+ "type": "yarn"
278
+ }
279
+ }
280
+ ```
281
+
282
+ ### Tool Calling
283
+ The Tool Calling feature in OpenThaiGPT 1.5 enables users to efficiently call various functions through intelligent responses. This includes making external API calls to retrieve real-time data, such as current temperature information, or predicting future data simply by submitting a query.
284
+ For example, a user can ask OpenThaiGPT, “What is the current temperature in San Francisco?” and the AI will execute a pre-defined function to provide an immediate response without the need for additional coding.
285
+ This feature also allows for broader applications with external data sources, including the ability to call APIs for services such as weather updates, stock market information, or data from within the user’s own system.
286
+
287
+ #### Example:
288
+ ```python
289
+ import openai
290
+
291
+ def get_temperature(location, date=None, unit="celsius"):
292
+ """Get temperature for a location (current or specific date)."""
293
+ if date:
294
+ return {"temperature": 25.9, "location": location, "date": date, "unit": unit}
295
+ return {"temperature": 26.1, "location": location, "unit": unit}
296
+
297
+ tools = [
298
+ {
299
+ "name": "get_temperature",
300
+ "description": "Get temperature for a location (current or by date).",
301
+ "parameters": {
302
+ "location": "string", "date": "string (optional)", "unit": "enum [celsius, fahrenheit]"
303
+ },
304
+ }
305
+ ]
306
+
307
+ messages = [{"role": "user", "content": "อุณหภูมิที่ San Francisco วันนี้ีและพรุ้่งนี้คือเท่าไร่?"}]
308
+
309
+ # Simulated response flow using OpenThaiGPT Tool Calling
310
+ response = openai.ChatCompletion.create(
311
+ model=".", messages=messages, tools=tools, temperature=0.7, max_tokens=512
312
+ )
313
+
314
+ print(response)
315
+ ```
316
+ **Full example**: https://github.com/OpenThaiGPT/openthaigpt1.5_api_examples/blob/main/api_tool_calling_powered_by_siamai.py
317
+
318
+ ### GPU Memory Requirements
319
+ | **Number of Parameters** | **FP 16 bits** | **8 bits (Quantized)** | **4 bits (Quantized)** | **Example Graphic Card for 4 bits** |
320
+ |------------------|----------------|------------------------|------------------------|---------------------------------------------|
321
+ | **7b** | 24 GB | 12 GB | 6 GB | Nvidia RTX 4060 8GB |
322
+ | **13b** | 48 GB | 24 GB | 12 GB | Nvidia RTX 4070 16GB |
323
+ | **72b** | 192 GB | 96 GB | 48 GB | Nvidia RTX 4090 24GB x 2 cards |
324
+
325
+ ### Authors
326
+ * Sumeth Yuenyong ([email protected])
327
+ * Kobkrit Viriyayudhakorn ([email protected])
328
+ * Apivadee Piyatumrong ([email protected])
329
+ * Jillaphat Jaroenkantasima ([email protected])
330
+ * Thaweewat Rugsujarit ([email protected])
331
+ * Norapat Buppodom ([email protected])
332
+ * Koravich Sangkaew ([email protected])
333
+ * Peerawat Rojratchadakorn ([email protected])
334
+ * Surapon Nonesung ([email protected])
335
+ * Chanon Utupon ([email protected])
336
+ * Sadhis Wongprayoon ([email protected])
337
+ * Nucharee Thongthungwong ([email protected])
338
+ * Chawakorn Phiantham ([email protected])
339
+ * Patteera Triamamornwooth ([email protected])
340
+ * Nattarika Juntarapaoraya ([email protected])
341
+ * Kriangkrai Saetan ([email protected])
342
+ * Pitikorn Khlaisamniang ([email protected])
343
+
344
+ <i>Disclaimer: Provided responses are not guaranteed.</i>
openthaigpt1.5-72b-instruct.Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e9f8faaea3a4a519a48ecee15411dbb00eb9125f35cfc5a39ed14013a40d8f84
3
+ size 41231737920