aashish1904 commited on
Commit
00bb5a3
1 Parent(s): 8bfa08b

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +352 -0
README.md ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+
4
+ license: other
5
+ license_name: qwen
6
+ language:
7
+ - th
8
+ - en
9
+ library_name: transformers
10
+ pipeline_tag: text-generation
11
+ tags:
12
+ - openthaigpt
13
+ - qwen
14
+
15
+ ---
16
+
17
+ [![QuantFactory Banner](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeiuCm7c8lEwEJuRey9kiVZsRn2W-b4pWlu3-X534V3YmVuVc2ZL-NXg2RkzSOOS2JXGHutDuyyNAUtdJI65jGTo8jT9Y99tMi4H4MqL44Uc5QKG77B0d6-JfIkZHFaUA71-RtjyYZWVIhqsNZcx8-OMaA?key=xt3VSDoCbmTY7o-cwwOFwQ)](https://hf.co/QuantFactory)
18
+
19
+
20
+ # QuantFactory/openthaigpt1.5-7b-instruct-GGUF
21
+ This is quantized version of [openthaigpt/openthaigpt1.5-7b-instruct](https://huggingface.co/openthaigpt/openthaigpt1.5-7b-instruct) created using llama.cpp
22
+
23
+ # Original Model Card
24
+
25
+
26
+ # 🇹🇭 OpenThaiGPT 7b 1.5 Instruct
27
+ ![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)
28
+ [More Info](https://openthaigpt.aieat.or.th/)
29
+
30
+ 🇹🇭 **OpenThaiGPT 7b Version 1.5** is an advanced 7-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.
31
+
32
+ ## Online Demo:
33
+ https://demo72b.aieat.or.th/
34
+
35
+ ## Example code for API Calling
36
+ https://github.com/OpenThaiGPT/openthaigpt1.5_api_examples
37
+
38
+ ## Highlights
39
+ - **State-of-the-art Thai language LLM**, achieving the highest average scores across various Thai language exams compared to other open-source Thai LLMs.
40
+ - **Multi-turn conversation support** for extended dialogues.
41
+ - **Retrieval Augmented Generation (RAG) compatibility** for enhanced response generation.
42
+ - **Impressive context handling**: Processes up to 131,072 tokens of input and generates up to 8,192 tokens, enabling detailed and complex interactions.
43
+ - **Tool calling support**: Enables users to efficiently call various functions through intelligent responses.
44
+
45
+ ## Benchmark on [OpenThaiGPT Eval](https://huggingface.co/datasets/openthaigpt/openthaigpt_eval)
46
+ ** Please take a look at ``openthaigpt/openthaigpt1.5-7b-instruct`` for this model's evaluation result.
47
+ | **Exam names** | **scb10x/llama-3-typhoon-v1.5x-8b-instruct** | **meta-llama/Llama-3.1-7B-Instruct** | **Qwen/Qwen2.5-7B-Instruct_stat** | **openthaigpt/openthaigpt1.5-7b** |
48
+ |:------------------------------:|:--------------------------------------------:|:------------------------------------:|:---------------------------------:|:---------------------------------:|
49
+ | **01_a_level** | 46.67% | 47.50% | 58.33% | 60.00% |
50
+ | **02_tgat** | 32.00% | 36.00% | 32.00% | 36.00% |
51
+ | **03_tpat1** | 52.50% | 55.00% | 57.50% | 57.50% |
52
+ | **04_investment_consult** | 56.00% | 48.00% | 68.00% | 76.00% |
53
+ | **05_facebook_beleble_th_200** | 78.00% | 73.00% | 79.00% | 81.00% |
54
+ | **06_xcopa_th_200** | 79.50% | 69.00% | 80.50% | 81.00% |
55
+ | **07_xnli2.0_th_200** | 56.50% | 55.00% | 53.00% | 54.50% |
56
+ | **08_onet_m3_thai** | 48.00% | 32.00% | 72.00% | 64.00% |
57
+ | **09_onet_m3_social** | 75.00% | 50.00% | 90.00% | 80.00% |
58
+ | **10_onet_m3_math** | 25.00% | 18.75% | 31.25% | 31.25% |
59
+ | **11_onet_m3_science** | 46.15% | 42.31% | 46.15% | 46.15% |
60
+ | **12_onet_m3_english** | 70.00% | 76.67% | 86.67% | 83.33% |
61
+ | **13_onet_m6_thai** | 47.69% | 29.23% | 46.15% | 53.85% |
62
+ | **14_onet_m6_math** | 29.41% | 17.65% | 29.41% | 29.41% |
63
+ | **15_onet_m6_social** | 50.91% | 43.64% | 56.36% | 58.18% |
64
+ | **16_onet_m6_science** | 42.86% | 32.14% | 57.14% | 57.14% |
65
+ | **17_onet_m6_english** | 65.38% | 71.15% | 78.85% | 80.77% |
66
+ | **Micro Average** | 60.65% | 55.60% | 64.41% | <b style="color:blue">65.78%</b> |
67
+
68
+
69
+ 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
70
+
71
+ (Updated on: 30 September 2024)
72
+
73
+ ## Benchmark on [scb10x/thai_exam](https://huggingface.co/datasets/scb10x/thai_exam)
74
+
75
+ | Models | **Thai Exam (Acc)** |
76
+ |:----------------------------------------------------------:|:-------------------:|
77
+ | **api/claude-3-5-sonnet-20240620** | 69.2 |
78
+ | <b style="color:blue">**openthaigpt/openthaigpt1.5-72b-instruct***</b> | <b style="color:blue">64.07</b> |
79
+ | **api/gpt-4o-2024-05-13** | 63.89 |
80
+ | **hugging-quants/Meta-Llama-3.1-405B-Instruct-AWQ-INT4** | 63.54 |
81
+ | **Qwen/Qwen2-72B-Instruct** | 58.23 |
82
+ | **meta-llama/Meta-Llama-3.1-70B-Instruct** | 58.23 |
83
+ | **scb10x/llama-3-typhoon-v1.5x-70b-instruct** | 58.76 |
84
+ | **Qwen/Qwen2.5-14B-Instruct** | 57.35 |
85
+ | **api/gpt-4o-mini-2024-07-18** | 54.51 |
86
+ | <b style="color:blue">**openthaigpt/openthaigpt1.5-7b-instruct***</b> | <b style="color:blue">52.04</b> |
87
+ | **SeaLLMs/SeaLLMs-v3-7B-Chat** | 51.33 |
88
+ | **openthaigpt/openthaigpt-1.0.0-70b-chat** | 50.09 |
89
+
90
+ <b style="color:blue">*</b> Evaluated by OpenThaiGPT team using [scb10x/thai_exam](https://huggingface.co/datasets/scb10x/thai_exam).
91
+
92
+ ## Licenses
93
+ * Built with Qwen
94
+ * Qwen License: Allow **Research** and
95
+ **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>
96
+
97
+ ## Sponsors
98
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/5fcd9c426d942eaf4d1ebd30/3kjN6kuTzXDXQ6o1RFvHX.png" width="600px">
99
+
100
+ ## Supports
101
+ - Official website: https://openthaigpt.aieat.or.th
102
+ - Facebook page: https://web.facebook.com/groups/openthaigpt
103
+ - A Discord server for discussion and support [here](https://discord.gg/rUTp6dfVUF)
104
+ - E-mail: kobkrit@aieat.or.th
105
+
106
+ ## Prompt Format
107
+ Prompt format is based on ChatML.
108
+ ```
109
+ <|im_start|>system\n{sytem_prompt}<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n
110
+ ```
111
+
112
+ ### System prompt:
113
+ ```
114
+ คุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์
115
+ ```
116
+
117
+ ### Examples
118
+
119
+ #### Single Turn Conversation Example
120
+ ```
121
+ <|im_start|>system\nคุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์<|im_end|>\n<|im_start|>user\nสวัสดีครับ<|im_end|>\n<|im_start|>assistant\n
122
+ ```
123
+
124
+ #### Single Turn Conversation with Context (RAG) Example
125
+ ```
126
+ <|im_start|>system\nคุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์<|im_end|>\n<|im_start|>user\nกรุงเทพมหานคร เป็นเมืองหลวง นครและมหานครที่มีประชากรมากที่สุดของประเทศไทย กรุงเทพมหานครมีพื้นที่ทั้งหมด 1,568.737 ตร.กม. มีประชากรตามทะเบียนราษฎรกว่า 8 ล้านคน\nกรุงเทพมหานครมีพื้นที่เท่าไร่<|im_end|>\n<|im_start|>assistant\n
127
+ ```
128
+
129
+ #### Multi Turn Conversation Example
130
+
131
+ ##### First turn
132
+ ```
133
+ <|im_start|>system\nคุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์<|im_end|>\n<|im_start|>user\nสวัสดีครับ<|im_end|>\n<|im_start|>assistant\n
134
+ ```
135
+
136
+ ##### Second turn
137
+ ```
138
+ <|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
139
+ ```
140
+
141
+ ##### Result
142
+ ```
143
+ <|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ชื่อเต็มของกรุงเทพมหานครคือ \"กรุงเทพมหานคร อมรรัตนโกสินทร์ มหินทรายุธยา มหาดิลกภพ นพรัตนราชธานีบูรีรมย์ อุดมราชนิเวศน์มหาสถาน อมรพิมานอวตารสถิต สักกะทัตติยวิษณุกรรมประสิทธิ์\"
144
+ ```
145
+
146
+ ## How to use
147
+
148
+ ### Free API Service (hosted by Siam.Ai and Float16.cloud)
149
+
150
+ #### Siam.AI
151
+ ```bash
152
+ curl https://api.aieat.or.th/v1/completions \
153
+ -H "Content-Type: application/json" \
154
+ -H "Authorization: Bearer dummy" \
155
+ -d '{
156
+ "model": ".",
157
+ "prompt": "<|im_start|>system\nคุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์<|im_end|>\n<|im_start|>user\nกรุงเทพมหานครคืออะไร<|im_end|>\n<|im_start|>assistant\n",
158
+ "max_tokens": 512,
159
+ "temperature": 0.7,
160
+ "top_p": 0.8,
161
+ "top_k": 40,
162
+ "stop": ["<|im_end|>"]
163
+ }'
164
+ ```
165
+
166
+ #### Float16
167
+ ```bash
168
+ curl -X POST https://api.float16.cloud/dedicate/78y8fJLuzE/v1/chat/completions \
169
+ -H "Content-Type: application/json" \
170
+ -H "Authorization: Bearer float16-AG0F8yNce5s1DiXm1ujcNrTaZquEdaikLwhZBRhyZQNeS7Dv0X" \
171
+ -d '{
172
+ "model": "openthaigpt/openthaigpt1.5-7b-instruct",
173
+ "messages": [
174
+ {
175
+ "role": "system",
176
+ "content": "คุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์"
177
+ },
178
+ {
179
+ "role": "user",
180
+ "content": "สวัสดี"
181
+ }
182
+ ]
183
+ }'
184
+ ```
185
+
186
+ ### OpenAI Client Library (Hosted by VLLM, please see below.)
187
+ ```python
188
+ import openai
189
+
190
+ # Configure OpenAI client to use vLLM server
191
+ openai.api_base = "http://127.0.0.1:8000/v1"
192
+ openai.api_key = "dummy" # vLLM doesn't require a real API key
193
+
194
+ prompt = "<|im_start|>system\nคุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์<|im_end|>\n<|im_start|>user\nกรุงเทพมหานครคืออะไร<|im_end|>\n<|im_start|>assistant\n"
195
+
196
+ try:
197
+ response = openai.Completion.create(
198
+ model=".", # Specify the model you're using with vLLM
199
+ prompt=prompt,
200
+ max_tokens=512,
201
+ temperature=0.7,
202
+ top_p=0.8,
203
+ top_k=40,
204
+ stop=["<|im_end|>"]
205
+ )
206
+ print("Generated Text:", response.choices[0].text)
207
+ except Exception as e:
208
+ print("Error:", str(e))
209
+ ```
210
+
211
+
212
+ ### Huggingface
213
+ ```python
214
+ from transformers import AutoModelForCausalLM, AutoTokenizer
215
+
216
+ model_name = "openthaigpt/openthaigpt1.5-72b-instruct"
217
+
218
+ model = AutoModelForCausalLM.from_pretrained(
219
+ model_name,
220
+ torch_dtype="auto",
221
+ device_map="auto"
222
+ )
223
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
224
+
225
+ prompt = "ประเทศไทยคืออะไร"
226
+ messages = [
227
+ {"role": "system", "content": "คุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์"},
228
+ {"role": "user", "content": prompt}
229
+ ]
230
+ text = tokenizer.apply_chat_template(
231
+ messages,
232
+ tokenize=False,
233
+ add_generation_prompt=True
234
+ )
235
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
236
+
237
+ generated_ids = model.generate(
238
+ **model_inputs,
239
+ max_new_tokens=512
240
+ )
241
+ generated_ids = [
242
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
243
+ ]
244
+
245
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
246
+ ```
247
+
248
+ ### vLLM
249
+
250
+ 1. Install VLLM (https://github.com/vllm-project/vllm)
251
+
252
+ 2. Run server
253
+ ```bash
254
+ vllm serve openthaigpt/openthaigpt1.5-72b-instruct --tensor-parallel-size 4
255
+ ```
256
+ * Note, change ``--tensor-parallel-size 4`` to the amount of available GPU cards.
257
+
258
+ 3. Run inference (CURL example)
259
+ ```bash
260
+ curl -X POST 'http://127.0.0.1:8000/v1/completions' \
261
+ -H 'Content-Type: application/json' \
262
+ -d '{
263
+ "model": ".",
264
+ "prompt": "<|im_start|>system\nคุณคือผู้ช่วยตอบคำถามที่ฉลาดและซื่อสัตย์<|im_end|>\n<|im_start|>user\nสวัสดีครับ<|im_end|>\n<|im_start|>assistant\n",
265
+ "max_tokens": 512,
266
+ "temperature": 0.7,
267
+ "top_p": 0.8,
268
+ "top_k": 40,
269
+ "stop": ["<|im_end|>"]
270
+ }'
271
+ ```
272
+
273
+ ### Processing Long Texts
274
+ The current `config.json` is set for context length up to 32,768 tokens.
275
+ 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.
276
+
277
+ For supported frameworks, you could add the following to `config.json` to enable YaRN:
278
+ ```json
279
+ {
280
+ ...
281
+ "rope_scaling": {
282
+ "factor": 4.0,
283
+ "original_max_position_embeddings": 32768,
284
+ "type": "yarn"
285
+ }
286
+ }
287
+ ```
288
+
289
+
290
+ ### Tool Calling
291
+ 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.
292
+ 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.
293
+ 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.
294
+
295
+ #### Example:
296
+ ```python
297
+ import openai
298
+
299
+ def get_temperature(location, date=None, unit="celsius"):
300
+ """Get temperature for a location (current or specific date)."""
301
+ if date:
302
+ return {"temperature": 25.9, "location": location, "date": date, "unit": unit}
303
+ return {"temperature": 26.1, "location": location, "unit": unit}
304
+
305
+ tools = [
306
+ {
307
+ "name": "get_temperature",
308
+ "description": "Get temperature for a location (current or by date).",
309
+ "parameters": {
310
+ "location": "string", "date": "string (optional)", "unit": "enum [celsius, fahrenheit]"
311
+ },
312
+ }
313
+ ]
314
+
315
+ messages = [{"role": "user", "content": "อุณหภูมิที่ San Francisco วันนี้ีและพรุ้่งนี้คือเท่าไร่?"}]
316
+
317
+ # Simulated response flow using OpenThaiGPT Tool Calling
318
+ response = openai.ChatCompletion.create(
319
+ model=".", messages=messages, tools=tools, temperature=0.7, max_tokens=512
320
+ )
321
+
322
+ print(response)
323
+ ```
324
+ **Full example**: https://github.com/OpenThaiGPT/openthaigpt1.5_api_examples/blob/main/api_tool_calling_powered_by_siamai.py
325
+
326
+ ### GPU Memory Requirements
327
+ | **Number of Parameters** | **FP 16 bits** | **8 bits (Quantized)** | **4 bits (Quantized)** | **Example Graphic Card for 4 bits** |
328
+ |------------------|----------------|------------------------|------------------------|---------------------------------------------|
329
+ | **7b** | 24 GB | 12 GB | 6 GB | Nvidia RTX 4060 8GB |
330
+ | **13b** | 48 GB | 24 GB | 12 GB | Nvidia RTX 4070 16GB |
331
+ | **72b** | 192 GB | 96 GB | 48 GB | Nvidia RTX 4090 24GB x 2 cards |
332
+
333
+ ### Authors
334
+ * Sumeth Yuenyong (sumeth.yue@mahidol.edu)
335
+ * Kobkrit Viriyayudhakorn (kobkrit@aieat.or.th)
336
+ * Apivadee Piyatumrong (apivadee.piy@nectec.or.th)
337
+ * Jillaphat Jaroenkantasima (autsadang41@gmail.com)
338
+ * Thaweewat Rugsujarit (thaweewr@scg.com)
339
+ * Norapat Buppodom (new@norapat.com)
340
+ * Koravich Sangkaew (kwankoravich@gmail.com)
341
+ * Peerawat Rojratchadakorn (peerawat.roj@gmail.com)
342
+ * Surapon Nonesung (nonesungsurapon@gmail.com)
343
+ * Chanon Utupon (chanon.utupon@gmail.com)
344
+ * Sadhis Wongprayoon (sadhis.tae@gmail.com)
345
+ * Nucharee Thongthungwong (nuchhub@hotmail.com)
346
+ * Chawakorn Phiantham (mondcha1507@gmail.com)
347
+ * Patteera Triamamornwooth (patt.patteera@gmail.com)
348
+ * Nattarika Juntarapaoraya (natt.juntara@gmail.com)
349
+ * Kriangkrai Saetan (kraitan.ss21@gmail.com)
350
+ * Pitikorn Khlaisamniang (pitikorn32@gmail.com)
351
+
352
+ <i>Disclaimer: Provided responses are not guaranteed.</i>