kobkrit's picture
Update README.md
c3768d3 verified
---
license: other
license_name: qwen
language:
- th
- en
library_name: transformers
pipeline_tag: text-generation
tags:
- openthaigpt
- qwen
- reasoning
model-index:
- name: openthaigpt-r1-32b-instruct
results:
- task:
type: reasoning
dataset:
name: SkyThought
type: mathematical_reasoning
metrics:
- name: AIME24-TH
type: accuracy
value: 56.67
- name: AIME24
type: accuracy
value: 63.36
source:
name: 🇹🇭 OpenThaiGPT R1 Benchmark
url: https://openthaigpt.aieat.or.th/
---
# 🇹🇭 OpenThaiGPT R1 32b
![OpenThaiGPT](https://cdn-uploads.huggingface.co/production/uploads/5fcd9c426d942eaf4d1ebd30/tByCXPW7JG3krRcTn1IlN.png)
[More Info](https://openthaigpt.aieat.or.th/)
🇹🇭 **OpenThaiGPT R1 32b** is an advanced 32-billion-parameter Thai language reasoning model that outperforms larger models like DeepSeek R1 70b and Typhoon R1 70b, while being less than half their size. This model excels at complex reasoning tasks, including mathematics, logic, and code reasoning in Thai language.
## Highlights
- **State-of-the-art Thai reasoning model**, outperforming larger models on mathematical and logical reasoning tasks
- **Explicit reasoning capabilities** with the ability to show step-by-step thought processes
- **Significantly smaller size** (32b) while outperforming 70b models
- **Specialized for Thai language reasoning** including complex mathematics and logic problems
- **High performance on code reasoning** in both Thai and English
## Benchmark Results
| **SkyThought** | **OpenThaiGPT R1 32b** | **DeepSeek R1 70b** | **Typhoon R1 Distill 70b** |
|----------------------|-----------------------------------------------------------------------|--------------------------|----------------------------|
| **AIME24-TH** | <b>56.67</b> | 33.33 | 53.33 |
| **AIME24** | <b>63.36</b> | 53.33 | 53.33 |
| **MATH500-TH** | <b>83.8</b> | 75.4 | 81 |
| **MATH500** | 89.4 | 88.88 | <b>90.2</b> |
| **LiveCodeBench-TH** | <b>62.16</b> | 53.15 | 47.75 |
| **LiveCodeBench** | <b>69.67</b> | 64.97 | 54.79 |
| **OpenThaiEval** | 76.05 | 74.17 | <b>77.59</b> |
| **AVERAGE** | <b style="color:blue">71.58</b> | 63.31 | 65.42 |
## Recommended System Prompt
```
<No system prompt>
```
## Model Technical Report
https://arxiv.org/abs/2504.01789
If OpenThaiGPT has been beneficial for your work, kindly consider citing it as follows:
```tex
@misc{yuenyong2025openthaigpt16r1thaicentric,
title={OpenThaiGPT 1.6 and R1: Thai-Centric Open Source and Reasoning Large Language Models},
author={Sumeth Yuenyong and Thodsaporn Chay-intr and Kobkrit Viriyayudhakorn},
year={2025},
eprint={2504.01789},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2504.01789},
}
```
## How to use
### Online Web Interface
https://chindax.iapp.co.th
### Transformers
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "openthaigpt/openthaigpt-r1-32b-instruct"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "จงหาพื้นที่ของวงกลมที่มีรัศมี 7 หน่วย"
messages = [
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(
**model_inputs,
max_new_tokens=16384,
temperature=0.6
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
```
### vLLM
1. Install VLLM (https://github.com/vllm-project/vllm)
2. Run server
```bash
vllm serve openthaigpt/openthaigpt-r1-32b --tensor-parallel-size 2
```
* Note, change `--tensor-parallel-size 2` to the amount of available GPU cards.
3. Run inference (CURL example)
```bash
curl -X POST 'http://127.0.0.1:8000/v1/chat/completions' \
-H 'Content-Type: application/json' \
-d '{
"model": "openthaigpt/openthaigpt-r1-32b-instruct",
"messages": [
{
"role": "user",
"content": "จงหาพื้นที่ของวงกลมที่มีรัศมี 7 หน่วย"
}
],
"max_tokens": 16384,
"temperature": 0.6,
"top_p": 0.95,
"top_k": 40
}'
```
### GPU Memory Requirements
| **Number of Parameters** | **FP 16 bits** | **8 bits (Quantized)** | **4 bits (Quantized)** |
|------------------|----------------|------------------------|------------------------|
| **32b** | 64 GB | 32 GB | 16 GB |
## Chat Template
```python
{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='') %}{%- for message in messages %}{%- if message['role'] == 'system' %}{% set ns.system_prompt = message['content'] %}{%- endif %}{%- endfor %}{{bos_token}}{{ns.system_prompt}}{%- for message in messages %}{%- if message['role'] == 'user' %}{%- set ns.is_tool = false -%}{{'<|User|>' + message['content']}}{%- endif %}{%- if message['role'] == 'assistant' and message['content'] is none %}{%- set ns.is_tool = false -%}{%- for tool in message['tool_calls']%}{%- if not ns.is_first %}{{'<|Assistant|><|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + tool['function']['arguments'] + '\\n' + '```' + '<|tool▁call▁end|>'}}{%- set ns.is_first = true -%}{%- else %}{{'\\n' + '<|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + tool['function']['arguments'] + '\\n' + '```' + '<|tool▁call▁end|>'}}{{'<|tool▁calls▁end|><|end▁of▁sentence|>'}}{%- endif %}{%- endfor %}{%- endif %}{%- if message['role'] == 'assistant' and message['content'] is not none %}{%- if ns.is_tool %}{{'<|tool▁outputs▁end|>' + message['content'] + '<|end▁of▁sentence|>'}}{%- set ns.is_tool = false -%}{%- else %}{% set content = message['content'] %}{% if '</think>' in content %}{% set content = content.split('</think>')[-1] %}{% endif %}{{'<|Assistant|>' + content + '<|end▁of▁sentence|>'}}{%- endif %}{%- endif %}{%- if message['role'] == 'tool' %}{%- set ns.is_tool = true -%}{%- if ns.is_output_first %}{{'<|tool▁outputs▁begin|><|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}{%- set ns.is_output_first = false %}{%- else %}{{'\\n<|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}{%- endif %}{%- endif %}{%- endfor -%}{% if ns.is_tool %}{{'<|tool▁outputs▁end|>'}}{% endif %}{% if add_generation_prompt and not ns.is_tool %}{{'<|Assistant|>'}}{% endif %}
```
## Licenses
* This model is available for **Research** and **Commercial uses** under the specified terms. Please see the LICENSE file for more information.
## Supports
- Official website: https://openthaigpt.aieat.or.th
- Facebook page: https://web.facebook.com/groups/openthaigpt
- A Discord server for discussion and support [here](https://discord.gg/rUTp6dfVUF)
- E-mail: [email protected]
### OpenThaiGPT Team
<img src="https://cdn-uploads.huggingface.co/production/uploads/5fcd9c426d942eaf4d1ebd30/e8gT15eRfNbyEZhu-UzMX.png" width="200px">
* Kobkrit Viriyayudhakorn ([email protected] / [email protected])
* Sumeth Yuenyong ([email protected])
* Thodsaporn Chay-intr ([email protected])
## Sponsors
<img src="https://cdn-uploads.huggingface.co/production/uploads/5fcd9c426d942eaf4d1ebd30/zSEA_n0cIOZk5pV_t2qii.png" width="400px">
* ได้รับการสนับสนุน GPU Nvidia H100 x 8 จากบริษัท บริษัท สยาม เอไอ คอร์เปอเรชั่น จำกัด: https://siam.ai/
* ได้รับทุนวิจัยสนับสนุนจากกองทุนส่งเสริมวิทยาศาสตร์ วิจัยและนวัตกรรม โดยหน่วยบริหารและจัดการทุนด้านการเพิ่มความสามารถในการแข่งขันของประเทศ (บพข.) ร่วมกับ บริษัท ไอแอพพ์เทคโนโลยี จำกัด ซึ่งมี สมาคมผู้ประกอบการปัญญาประดิษฐ์ประเทศไทย เป็นผู้ดำเนินงานโครงการ
<i>Disclaimer: Provided responses are not guaranteed.</i>