SuperkingbasSKB
commited on
Commit
•
7fb8ef2
1
Parent(s):
b7f9ac4
Update README.md
Browse files
README.md
CHANGED
@@ -17,4 +17,89 @@ tags:
|
|
17 |
- code
|
18 |
- medical
|
19 |
- text-generation-inference
|
20 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
- code
|
18 |
- medical
|
19 |
- text-generation-inference
|
20 |
+
---
|
21 |
+
# OpenThaiLLM-Prebuilt: Thai & China & English Large Language Model
|
22 |
+
**OpenThaiLLM-Prebuilt** is an 7 billion parameter instruct model designed for Thai 🇹🇭 & China 🇨🇳 language.
|
23 |
+
It demonstrates an amazing result, and is optimized for application use cases, Retrieval-Augmented Generation (RAG), Web deployment
|
24 |
+
constrained generation, and reasoning tasks.is a Thai 🇹🇭 & China 🇨🇳 large language model with 7 billion parameters, and it is based on Qwen2.5-7B.
|
25 |
+
## Introduction
|
26 |
+
|
27 |
+
Qwen2.5 is the new series of Qwen large language models. For Qwen2, we release a number of base language models and instruction-tuned language models ranging from 0.5 to 72 billion parameters, including a Mixture-of-Experts model. This repo contains the instruction-tuned 7B Qwen2 model.
|
28 |
+
|
29 |
+
Compared with the state-of-the-art opensource language models, including the previous released Qwen1.5, Qwen2 has generally surpassed most opensource models and demonstrated competitiveness against proprietary models across a series of benchmarks targeting for language understanding, language generation, multilingual capability, coding, mathematics, reasoning, etc.
|
30 |
+
|
31 |
+
Qwen2.5-7B-Instruct supports a context length of up to 131,072 tokens, enabling the processing of extensive inputs. Please refer to [this section](#processing-long-texts) for detailed instructions on how to deploy Qwen2 for handling long texts.
|
32 |
+
|
33 |
+
For more details, please refer to our [blog](https://qwenlm.github.io/blog/qwen2/), [GitHub](https://github.com/QwenLM/Qwen2), and [Documentation](https://qwen.readthedocs.io/en/latest/).
|
34 |
+
<br>
|
35 |
+
|
36 |
+
## Model Details
|
37 |
+
Qwen2 is a language model series including decoder language models of different model sizes. For each size, we release the base language model and the aligned chat model. It is based on the Transformer architecture with SwiGLU activation, attention QKV bias, group query attention, etc. Additionally, we have an improved tokenizer adaptive to multiple natural languages and codes.
|
38 |
+
|
39 |
+
## Training details
|
40 |
+
We pretrained the models with a large amount of data, and we post-trained the models with both supervised finetuning and direct preference optimization.
|
41 |
+
|
42 |
+
|
43 |
+
## Requirements
|
44 |
+
The code of Qwen2 has been in the latest Hugging face transformers and we advise you to install `transformers>=4.37.0`, or you might encounter the following error:
|
45 |
+
```
|
46 |
+
KeyError: 'qwen2'
|
47 |
+
```
|
48 |
+
|
49 |
+
## Implementation
|
50 |
+
|
51 |
+
Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
|
52 |
+
|
53 |
+
```python
|
54 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
55 |
+
device = "cuda" # the device to load the model onto
|
56 |
+
|
57 |
+
model = AutoModelForCausalLM.from_pretrained(
|
58 |
+
"nectec/OpenThaiLLM-DoodNiLT-V1.0.0-Beta-7B-Instruct",
|
59 |
+
torch_dtype="auto",
|
60 |
+
device_map="auto"
|
61 |
+
)
|
62 |
+
tokenizer = AutoTokenizer.from_pretrained("nectec/OpenThaiLLM-DoodNiLT-V1.0.0-Beta-7B-Instruct")
|
63 |
+
|
64 |
+
prompt = "บริษัท A มีต้นทุนคงที่ 100,000 บาท และต้นทุนผันแปรต่อหน่วย 50 บาท ขายสินค้าได้ในราคา 150 บาทต่อหน่วย ต้องขายสินค้าอย่างน้อยกี่หน่วยเพื่อให้ถึงจุดคุ้มทุน?"
|
65 |
+
messages = [
|
66 |
+
{"role": "system", "content": "คุณคือ DoodNiLT Assistant จงตอบคำถามอธิบายเป็นภาษาไทย"},
|
67 |
+
{"role": "user", "content": prompt}
|
68 |
+
]
|
69 |
+
text = tokenizer.apply_chat_template(
|
70 |
+
messages,
|
71 |
+
tokenize=False,
|
72 |
+
add_generation_prompt=True
|
73 |
+
)
|
74 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
75 |
+
|
76 |
+
generated_ids = model.generate(
|
77 |
+
model_inputs.input_ids,
|
78 |
+
max_new_tokens=4096,
|
79 |
+
repetition_penalty=1.2
|
80 |
+
)
|
81 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
82 |
+
print(response)
|
83 |
+
```
|
84 |
+
|
85 |
+
## Evaluation Performance Few-shot (5 shot)
|
86 |
+
| Model | ONET | IC | TGAT | TPAT-1 | A-Level | Average ThaiExam) | MMLU | M3Exam (1 shot) | M6Exam(5shot) |
|
87 |
+
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
88 |
+
| OpenthaiLLM-Prebuilt-7B | **0.5493** | **0.6315** | **0.6307** | **0.4655** | **0.37** | **0.5294** | **0.7054** | **0.5705** | **0.596** |
|
89 |
+
| llama-3-typhoon-v1.5-8b | 0.3765 | 0.3473 | 0.5538 | 0.4137 | 0.2913 | 0.3965 | 0.4312 | 0.6451 |
|
90 |
+
| OpenThaiGPT-1.0.0-7B | 0.3086 | 0.3052 | 0.4153 | 0.3017 | 0.2755 | 0.3213 | 0.255 | 0.3512 |
|
91 |
+
| Meta-Llama-3.1-8B | 0.3641 | 0.2631 | 0.2769 | 0.3793 | 0.1811 | 0.2929 | 0.4239 | 0.6591 |
|
92 |
+
| SeaLLM-v3-7B | 0.4753 | 0.6421 | 0.6153 | 0.3275 | 0.3464 | 0.4813 | 0.4907 | ***0.7037*** |
|
93 |
+
|
94 |
+
## Evaluation Performance Few-shot (2 shot)
|
95 |
+
|
96 |
+
## Citation
|
97 |
+
|
98 |
+
If you find our work helpful, feel free to give us a cite.
|
99 |
+
|
100 |
+
```
|
101 |
+
@article{qwen2,
|
102 |
+
title={Qwen2 Technical Report},
|
103 |
+
year={2024}
|
104 |
+
}
|
105 |
+
```
|