--- 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** | 56.67 | 33.33 | 53.33 | | **AIME24** | 63.36 | 53.33 | 53.33 | | **MATH500-TH** | 83.8 | 75.4 | 81 | | **MATH500** | 89.4 | 88.88 | 90.2 | | **LiveCodeBench-TH** | 62.16 | 53.15 | 47.75 | | **LiveCodeBench** | 69.67 | 64.97 | 54.79 | | **OpenThaiEval** | 76.05 | 74.17 | 77.59 | | **AVERAGE** | 71.58 | 63.31 | 65.42 | ## Recommended 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 '' in content %}{% set content = content.split('')[-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: kobkrit@iapp.co.th ### OpenThaiGPT Team * Kobkrit Viriyayudhakorn (kobkrit@iapp.co.th / kobkrit@aieat.or.th) * Sumeth Yuenyong (sumeth.yue@mahidol.edu) * Thodsaporn Chay-intr (thodsaporn@iapp.co.th) ## Sponsors * āđ„āļ”āđ‰āļĢāļąāļšāļāļēāļĢāļŠāļ™āļąāļšāļŠāļ™āļļāļ™ GPU Nvidia H100 x 8 āļˆāļēāļāļšāļĢāļīāļĐāļąāļ— āļšāļĢāļīāļĐāļąāļ— āļŠāļĒāļēāļĄ āđ€āļ­āđ„āļ­ āļ„āļ­āļĢāđŒāđ€āļ›āļ­āđ€āļĢāļŠāļąāđˆāļ™ āļˆāļģāļāļąāļ”: https://siam.ai/ * āđ„āļ”āđ‰āļĢāļąāļšāļ—āļļāļ™āļ§āļīāļˆāļąāļĒāļŠāļ™āļąāļšāļŠāļ™āļļāļ™āļˆāļēāļāļāļ­āļ‡āļ—āļļāļ™āļŠāđˆāļ‡āđ€āļŠāļĢāļīāļĄāļ§āļīāļ—āļĒāļēāļĻāļēāļŠāļ•āļĢāđŒ āļ§āļīāļˆāļąāļĒāđāļĨāļ°āļ™āļ§āļąāļ•āļāļĢāļĢāļĄ āđ‚āļ”āļĒāļŦāļ™āđˆāļ§āļĒāļšāļĢāļīāļŦāļēāļĢāđāļĨāļ°āļˆāļąāļ”āļāļēāļĢāļ—āļļāļ™āļ”āđ‰āļēāļ™āļāļēāļĢāđ€āļžāļīāđˆāļĄāļ„āļ§āļēāļĄāļŠāļēāļĄāļēāļĢāļ–āđƒāļ™āļāļēāļĢāđāļ‚āđˆāļ‡āļ‚āļąāļ™āļ‚āļ­āļ‡āļ›āļĢāļ°āđ€āļ—āļĻ (āļšāļžāļ‚.) āļĢāđˆāļ§āļĄāļāļąāļš āļšāļĢāļīāļĐāļąāļ— āđ„āļ­āđāļ­āļžāļžāđŒāđ€āļ—āļ„āđ‚āļ™āđ‚āļĨāļĒāļĩ āļˆāļģāļāļąāļ” āļ‹āļķāđˆāļ‡āļĄāļĩ āļŠāļĄāļēāļ„āļĄāļœāļđāđ‰āļ›āļĢāļ°āļāļ­āļšāļāļēāļĢāļ›āļąāļāļāļēāļ›āļĢāļ°āļ”āļīāļĐāļāđŒāļ›āļĢāļ°āđ€āļ—āļĻāđ„āļ—āļĒ āđ€āļ›āđ‡āļ™āļœāļđāđ‰āļ”āļģāđ€āļ™āļīāļ™āļ‡āļēāļ™āđ‚āļ„āļĢāļ‡āļāļēāļĢ Disclaimer: Provided responses are not guaranteed.