Instructions to use openthaigpt/openthaigpt1.5-72b-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openthaigpt/openthaigpt1.5-72b-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openthaigpt/openthaigpt1.5-72b-instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("openthaigpt/openthaigpt1.5-72b-instruct") model = AutoModelForCausalLM.from_pretrained("openthaigpt/openthaigpt1.5-72b-instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - llama-cpp-python
How to use openthaigpt/openthaigpt1.5-72b-instruct with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="openthaigpt/openthaigpt1.5-72b-instruct", filename="gguf/openthaigpt1.5-72B-F16-00001-of-00008.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use openthaigpt/openthaigpt1.5-72b-instruct with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf openthaigpt/openthaigpt1.5-72b-instruct:F16 # Run inference directly in the terminal: llama-cli -hf openthaigpt/openthaigpt1.5-72b-instruct:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf openthaigpt/openthaigpt1.5-72b-instruct:F16 # Run inference directly in the terminal: llama-cli -hf openthaigpt/openthaigpt1.5-72b-instruct:F16
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf openthaigpt/openthaigpt1.5-72b-instruct:F16 # Run inference directly in the terminal: ./llama-cli -hf openthaigpt/openthaigpt1.5-72b-instruct:F16
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf openthaigpt/openthaigpt1.5-72b-instruct:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf openthaigpt/openthaigpt1.5-72b-instruct:F16
Use Docker
docker model run hf.co/openthaigpt/openthaigpt1.5-72b-instruct:F16
- LM Studio
- Jan
- vLLM
How to use openthaigpt/openthaigpt1.5-72b-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openthaigpt/openthaigpt1.5-72b-instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openthaigpt/openthaigpt1.5-72b-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/openthaigpt/openthaigpt1.5-72b-instruct:F16
- SGLang
How to use openthaigpt/openthaigpt1.5-72b-instruct with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "openthaigpt/openthaigpt1.5-72b-instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openthaigpt/openthaigpt1.5-72b-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "openthaigpt/openthaigpt1.5-72b-instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openthaigpt/openthaigpt1.5-72b-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use openthaigpt/openthaigpt1.5-72b-instruct with Ollama:
ollama run hf.co/openthaigpt/openthaigpt1.5-72b-instruct:F16
- Unsloth Studio new
How to use openthaigpt/openthaigpt1.5-72b-instruct with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for openthaigpt/openthaigpt1.5-72b-instruct to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for openthaigpt/openthaigpt1.5-72b-instruct to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for openthaigpt/openthaigpt1.5-72b-instruct to start chatting
- Pi new
How to use openthaigpt/openthaigpt1.5-72b-instruct with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf openthaigpt/openthaigpt1.5-72b-instruct:F16
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "openthaigpt/openthaigpt1.5-72b-instruct:F16" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use openthaigpt/openthaigpt1.5-72b-instruct with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf openthaigpt/openthaigpt1.5-72b-instruct:F16
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default openthaigpt/openthaigpt1.5-72b-instruct:F16
Run Hermes
hermes
- Docker Model Runner
How to use openthaigpt/openthaigpt1.5-72b-instruct with Docker Model Runner:
docker model run hf.co/openthaigpt/openthaigpt1.5-72b-instruct:F16
- Lemonade
How to use openthaigpt/openthaigpt1.5-72b-instruct with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull openthaigpt/openthaigpt1.5-72b-instruct:F16
Run and chat with the model
lemonade run user.openthaigpt1.5-72b-instruct-F16
List all available models
lemonade list
πΉπ OpenThaiGPT 72b 1.5 Instruct
πΉπ 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.
Online Demo:
Example code for API Calling
https://github.com/OpenThaiGPT/openthaigpt1.5_api_examples
Highlights
- State-of-the-art Thai language LLM, achieving the highest average scores across various Thai language exams compared to other open-source Thai LLMs.
- Multi-turn conversation support for extended dialogues.
- Retrieval Augmented Generation (RAG) compatibility for enhanced response generation.
- Impressive context handling: Processes up to 131,072 tokens of input and generates up to 8,192 tokens, enabling detailed and complex interactions.
- Tool calling support: Enables users to efficiently call various functions through intelligent responses.
Benchmark on OpenThaiGPT Eval
** Please take a look at openthaigpt/openthaigpt1.5-72b-instruct for this model's evaluation result.
| 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 |
|---|---|---|---|---|
| 01_a_level | 59.17% | 61.67% | 75.00% | 76.67% |
| 02_tgat | 46.00% | 40.00% | 48.00% | 46.00% |
| 03_tpat1 | 52.50% | 50.00% | 55.00% | 55.00% |
| 04_investment_consult | 60.00% | 52.00% | 80.00% | 72.00% |
| 05_facebook_beleble_th_200 | 87.50% | 88.00% | 90.00% | 90.00% |
| 06_xcopa_th_200 | 84.50% | 85.50% | 90.00% | 90.50% |
| 07_xnli2.0_th_200 | 62.50% | 63.00% | 65.50% | 70.50% |
| 08_onet_m3_thai | 76.00% | 56.00% | 76.00% | 84.00% |
| 09_onet_m3_social | 95.00% | 95.00% | 90.00% | 95.00% |
| 10_onet_m3_math | 43.75% | 25.00% | 37.50% | 37.50% |
| 11_onet_m3_science | 53.85% | 61.54% | 65.38% | 73.08% |
| 12_onet_m3_english | 93.33% | 93.33% | 96.67% | 96.67% |
| 13_onet_m6_thai | 55.38% | 60.00% | 60.00% | 56.92% |
| 14_onet_m6_math | 41.18% | 58.82% | 23.53% | 41.18% |
| 15_onet_m6_social | 67.27% | 76.36% | 63.64% | 65.45% |
| 16_onet_m6_science | 50.00% | 57.14% | 64.29% | 67.86% |
| 17_onet_m6_english | 73.08% | 82.69% | 86.54% | 90.38% |
| Micro Average | 69.97% | 71.09% | 75.02% | 76.73% |
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
(Updated on: 30 September 2024)
Benchmark on scb10x/thai_exam
| Models | Thai Exam (Acc) |
|---|---|
| api/claude-3-5-sonnet-20240620 | 69.2 |
| openthaigpt/openthaigpt1.5-72b-instruct* | 64.07 |
| api/gpt-4o-2024-05-13 | 63.89 |
| hugging-quants/Meta-Llama-3.1-405B-Instruct-AWQ-INT4 | 63.54 |
| openthaigpt/openthaigpt1.5-14b-instruct* | 59.65 |
| scb10x/llama-3-typhoon-v1.5x-70b-instruct | 58.76 |
| Qwen/Qwen2-72B-Instruct | 58.23 |
| meta-llama/Meta-Llama-3.1-70B-Instruct | 58.23 |
| Qwen/Qwen2.5-14B-Instruct | 57.35 |
| api/gpt-4o-mini-2024-07-18 | 54.51 |
| openthaigpt/openthaigpt1.5-7b-instruct* | 52.04 |
| SeaLLMs/SeaLLMs-v3-7B-Chat | 51.33 |
| openthaigpt/openthaigpt-1.0.0-70b-chat | 50.09 |
* Evaluated by OpenThaiGPT team using scb10x/thai_exam.
(Updated on: 13 October 2024)
Licenses
- Built with Qwen
- 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.
Sponsors
Supports
- Official website: https://openthaigpt.aieat.or.th
- Facebook page: https://web.facebook.com/groups/openthaigpt
- A Discord server for discussion and support here
- E-mail: kobkrit@aieat.or.th
Prompt Format
Prompt format is based on ChatML.
<|im_start|>system\n{sytem_prompt}<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n
System prompt:
ΰΈΰΈΈΰΈΰΈΰΈ·ΰΈΰΈΰΈΉΰΉΰΈΰΉΰΈ§ΰΈ’ΰΈΰΈΰΈΰΈΰΈ³ΰΈΰΈ²ΰΈ‘ΰΈΰΈ΅ΰΉΰΈΰΈ₯ΰΈ²ΰΈΰΉΰΈ₯ΰΈ°ΰΈΰΈ·ΰΉΰΈΰΈͺΰΈ±ΰΈΰΈ’ΰΉ
Examples
Single Turn Conversation Example
<|im_start|>system\nΰΈΰΈΈΰΈΰΈΰΈ·ΰΈΰΈΰΈΉΰΉΰΈΰΉΰΈ§ΰΈ’ΰΈΰΈΰΈΰΈΰΈ³ΰΈΰΈ²ΰΈ‘ΰΈΰΈ΅ΰΉΰΈΰΈ₯ΰΈ²ΰΈΰΉΰΈ₯ΰΈ°ΰΈΰΈ·ΰΉΰΈΰΈͺΰΈ±ΰΈΰΈ’ΰΉ<|im_end|>\n<|im_start|>user\nΰΈͺΰΈ§ΰΈ±ΰΈͺΰΈΰΈ΅ΰΈΰΈ£ΰΈ±ΰΈ<|im_end|>\n<|im_start|>assistant\n
Single Turn Conversation with Context (RAG) Example
<|im_start|>system\nΰΈΰΈΈΰΈΰΈΰΈ·ΰΈΰΈΰΈΉΰΉΰΈΰΉΰΈ§ΰΈ’ΰΈΰΈΰΈΰΈΰΈ³ΰΈΰΈ²ΰΈ‘ΰΈΰΈ΅ΰΉΰΈΰΈ₯ΰΈ²ΰΈΰΉΰΈ₯ΰΈ°ΰΈΰΈ·ΰΉΰΈΰΈͺΰΈ±ΰΈΰΈ’ΰΉ<|im_end|>\n<|im_start|>user\nΰΈΰΈ£ΰΈΈΰΈΰΉΰΈΰΈΰΈ‘ΰΈ«ΰΈ²ΰΈΰΈΰΈ£ ΰΉΰΈΰΉΰΈΰΉΰΈ‘ΰΈ·ΰΈΰΈΰΈ«ΰΈ₯ΰΈ§ΰΈ ΰΈΰΈΰΈ£ΰΉΰΈ₯ΰΈ°ΰΈ‘ΰΈ«ΰΈ²ΰΈΰΈΰΈ£ΰΈΰΈ΅ΰΉΰΈ‘ΰΈ΅ΰΈΰΈ£ΰΈ°ΰΈΰΈ²ΰΈΰΈ£ΰΈ‘ΰΈ²ΰΈΰΈΰΈ΅ΰΉΰΈͺΰΈΈΰΈΰΈΰΈΰΈΰΈΰΈ£ΰΈ°ΰΉΰΈΰΈ¨ΰΉΰΈΰΈ’ ΰΈΰΈ£ΰΈΈΰΈΰΉΰΈΰΈΰΈ‘ΰΈ«ΰΈ²ΰΈΰΈΰΈ£ΰΈ‘ΰΈ΅ΰΈΰΈ·ΰΉΰΈΰΈΰΈ΅ΰΉΰΈΰΈ±ΰΉΰΈΰΈ«ΰΈ‘ΰΈ 1,568.737 ΰΈΰΈ£.ΰΈΰΈ‘. ΰΈ‘ΰΈ΅ΰΈΰΈ£ΰΈ°ΰΈΰΈ²ΰΈΰΈ£ΰΈΰΈ²ΰΈ‘ΰΈΰΈ°ΰΉΰΈΰΈ΅ΰΈ’ΰΈΰΈ£ΰΈ²ΰΈ©ΰΈΰΈ£ΰΈΰΈ§ΰΉΰΈ² 8 ΰΈ₯ΰΉΰΈ²ΰΈΰΈΰΈ\nΰΈΰΈ£ΰΈΈΰΈΰΉΰΈΰΈΰΈ‘ΰΈ«ΰΈ²ΰΈΰΈΰΈ£ΰΈ‘ΰΈ΅ΰΈΰΈ·ΰΉΰΈΰΈΰΈ΅ΰΉΰΉΰΈΰΉΰΈ²ΰΉΰΈ£ΰΉ<|im_end|>\n<|im_start|>assistant\n
Multi Turn Conversation Example
First turn
<|im_start|>system\nΰΈΰΈΈΰΈΰΈΰΈ·ΰΈΰΈΰΈΉΰΉΰΈΰΉΰΈ§ΰΈ’ΰΈΰΈΰΈΰΈΰΈ³ΰΈΰΈ²ΰΈ‘ΰΈΰΈ΅ΰΉΰΈΰΈ₯ΰΈ²ΰΈΰΉΰΈ₯ΰΈ°ΰΈΰΈ·ΰΉΰΈΰΈͺΰΈ±ΰΈΰΈ’ΰΉ<|im_end|>\n<|im_start|>user\nΰΈͺΰΈ§ΰΈ±ΰΈͺΰΈΰΈ΅ΰΈΰΈ£ΰΈ±ΰΈ<|im_end|>\n<|im_start|>assistant\n
Second turn
<|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
Result
<|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ΰΈΰΈ·ΰΉΰΈΰΉΰΈΰΉΰΈ‘ΰΈΰΈΰΈΰΈΰΈ£ΰΈΈΰΈΰΉΰΈΰΈΰΈ‘ΰΈ«ΰΈ²ΰΈΰΈΰΈ£ΰΈΰΈ·ΰΈ \"ΰΈΰΈ£ΰΈΈΰΈΰΉΰΈΰΈΰΈ‘ΰΈ«ΰΈ²ΰΈΰΈΰΈ£ ΰΈΰΈ‘ΰΈ£ΰΈ£ΰΈ±ΰΈΰΈΰΉΰΈΰΈͺΰΈ΄ΰΈΰΈΰΈ£ΰΉ ΰΈ‘ΰΈ«ΰΈ΄ΰΈΰΈΰΈ£ΰΈ²ΰΈ’ΰΈΈΰΈΰΈ’ΰΈ² ΰΈ‘ΰΈ«ΰΈ²ΰΈΰΈ΄ΰΈ₯ΰΈΰΈ ΰΈ ΰΈΰΈΰΈ£ΰΈ±ΰΈΰΈΰΈ£ΰΈ²ΰΈΰΈΰΈ²ΰΈΰΈ΅ΰΈΰΈΉΰΈ£ΰΈ΅ΰΈ£ΰΈ‘ΰΈ’ΰΉ ΰΈΰΈΈΰΈΰΈ‘ΰΈ£ΰΈ²ΰΈΰΈΰΈ΄ΰΉΰΈ§ΰΈ¨ΰΈΰΉΰΈ‘ΰΈ«ΰΈ²ΰΈͺΰΈΰΈ²ΰΈ ΰΈΰΈ‘ΰΈ£ΰΈΰΈ΄ΰΈ‘ΰΈ²ΰΈΰΈΰΈ§ΰΈΰΈ²ΰΈ£ΰΈͺΰΈΰΈ΄ΰΈ ΰΈͺΰΈ±ΰΈΰΈΰΈ°ΰΈΰΈ±ΰΈΰΈΰΈ΄ΰΈ’ΰΈ§ΰΈ΄ΰΈ©ΰΈΰΈΈΰΈΰΈ£ΰΈ£ΰΈ‘ΰΈΰΈ£ΰΈ°ΰΈͺΰΈ΄ΰΈΰΈΰΈ΄ΰΉ\"
How to use
Free API Service (hosted by Siam.Ai and Float16.cloud)
Siam.AI
curl https://api.aieat.or.th/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer dummy" \
-d '{
"model": ".",
"prompt": "<|im_start|>system\nΰΈΰΈΈΰΈΰΈΰΈ·ΰΈΰΈΰΈΉΰΉΰΈΰΉΰΈ§ΰΈ’ΰΈΰΈΰΈΰΈΰΈ³ΰΈΰΈ²ΰΈ‘ΰΈΰΈ΅ΰΉΰΈΰΈ₯ΰΈ²ΰΈΰΉΰΈ₯ΰΈ°ΰΈΰΈ·ΰΉΰΈΰΈͺΰΈ±ΰΈΰΈ’ΰΉ<|im_end|>\n<|im_start|>user\nΰΈΰΈ£ΰΈΈΰΈΰΉΰΈΰΈΰΈ‘ΰΈ«ΰΈ²ΰΈΰΈΰΈ£ΰΈΰΈ·ΰΈΰΈΰΈ°ΰΉΰΈ£<|im_end|>\n<|im_start|>assistant\n",
"max_tokens": 512,
"temperature": 0.7,
"top_p": 0.8,
"top_k": 40,
"stop": ["<|im_end|>"]
}'
Float16
curl -X POST https://api.float16.cloud/dedicate/78y8fJLuzE/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer float16-AG0F8yNce5s1DiXm1ujcNrTaZquEdaikLwhZBRhyZQNeS7Dv0X" \
-d '{
"model": "openthaigpt/openthaigpt1.5-7b-instruct",
"messages": [
{
"role": "system",
"content": "ΰΈΰΈΈΰΈΰΈΰΈ·ΰΈΰΈΰΈΉΰΉΰΈΰΉΰΈ§ΰΈ’ΰΈΰΈΰΈΰΈΰΈ³ΰΈΰΈ²ΰΈ‘ΰΈΰΈ΅ΰΉΰΈΰΈ₯ΰΈ²ΰΈΰΉΰΈ₯ΰΈ°ΰΈΰΈ·ΰΉΰΈΰΈͺΰΈ±ΰΈΰΈ’ΰΉ"
},
{
"role": "user",
"content": "ΰΈͺΰΈ§ΰΈ±ΰΈͺΰΈΰΈ΅"
}
]
}'
OpenAI Client Library (Hosted by VLLM, please see below.)
import openai
# Configure OpenAI client to use vLLM server
openai.api_base = "http://127.0.0.1:8000/v1"
openai.api_key = "dummy" # vLLM doesn't require a real API key
prompt = "<|im_start|>system\nΰΈΰΈΈΰΈΰΈΰΈ·ΰΈΰΈΰΈΉΰΉΰΈΰΉΰΈ§ΰΈ’ΰΈΰΈΰΈΰΈΰΈ³ΰΈΰΈ²ΰΈ‘ΰΈΰΈ΅ΰΉΰΈΰΈ₯ΰΈ²ΰΈΰΉΰΈ₯ΰΈ°ΰΈΰΈ·ΰΉΰΈΰΈͺΰΈ±ΰΈΰΈ’ΰΉ<|im_end|>\n<|im_start|>user\nΰΈΰΈ£ΰΈΈΰΈΰΉΰΈΰΈΰΈ‘ΰΈ«ΰΈ²ΰΈΰΈΰΈ£ΰΈΰΈ·ΰΈΰΈΰΈ°ΰΉΰΈ£<|im_end|>\n<|im_start|>assistant\n"
try:
response = openai.Completion.create(
model=".", # Specify the model you're using with vLLM
prompt=prompt,
max_tokens=512,
temperature=0.7,
top_p=0.8,
top_k=40,
stop=["<|im_end|>"]
)
print("Generated Text:", response.choices[0].text)
except Exception as e:
print("Error:", str(e))
Huggingface
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "openthaigpt/openthaigpt1.5-72b-instruct"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "ΰΈΰΈ£ΰΈ°ΰΉΰΈΰΈ¨ΰΉΰΈΰΈ’ΰΈΰΈ·ΰΈΰΈΰΈ°ΰΉΰΈ£"
messages = [
{"role": "system", "content": "ΰΈΰΈΈΰΈΰΈΰΈ·ΰΈΰΈΰΈΉΰΉΰΈΰΉΰΈ§ΰΈ’ΰΈΰΈΰΈΰΈΰΈ³ΰΈΰΈ²ΰΈ‘ΰΈΰΈ΅ΰΉΰΈΰΈ₯ΰΈ²ΰΈΰΉΰΈ₯ΰΈ°ΰΈΰΈ·ΰΉΰΈΰΈͺΰΈ±ΰΈΰΈ’ΰΉ"},
{"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=512
)
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
Install VLLM (https://github.com/vllm-project/vllm)
Run server
vllm serve openthaigpt/openthaigpt1.5-72b-instruct --tensor-parallel-size 4
- Note, change
--tensor-parallel-size 4to the amount of available GPU cards.
If you wish to enable tool calling feature, add --enable-auto-tool-choice --tool-call-parser hermes into command. e.g.,
vllm serve openthaigpt/openthaigpt1.5-72b-instruct --tensor-parallel-size 4 --enable-auto-tool-choice --tool-call-parser hermes
- Run inference (CURL example)
curl -X POST 'http://127.0.0.1:8000/v1/completions' \
-H 'Content-Type: application/json' \
-d '{
"model": ".",
"prompt": "<|im_start|>system\nΰΈΰΈΈΰΈΰΈΰΈ·ΰΈΰΈΰΈΉΰΉΰΈΰΉΰΈ§ΰΈ’ΰΈΰΈΰΈΰΈΰΈ³ΰΈΰΈ²ΰΈ‘ΰΈΰΈ΅ΰΉΰΈΰΈ₯ΰΈ²ΰΈΰΉΰΈ₯ΰΈ°ΰΈΰΈ·ΰΉΰΈΰΈͺΰΈ±ΰΈΰΈ’ΰΉ<|im_end|>\n<|im_start|>user\nΰΈͺΰΈ§ΰΈ±ΰΈͺΰΈΰΈ΅ΰΈΰΈ£ΰΈ±ΰΈ<|im_end|>\n<|im_start|>assistant\n",
"max_tokens": 512,
"temperature": 0.7,
"top_p": 0.8,
"top_k": 40,
"stop": ["<|im_end|>"]
}'
Processing Long Texts
The current config.json is set for context length up to 32,768 tokens.
To handle extensive inputs exceeding 32,768 tokens, we utilize YaRN, a technique for enhancing model length extrapolation, ensuring optimal performance on lengthy texts.
For supported frameworks, you could add the following to config.json to enable YaRN:
{
...,
"rope_scaling": {
"factor": 4.0,
"original_max_position_embeddings": 32768,
"type": "yarn"
}
}
Tool Calling
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. 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. 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.
Example:
import openai
def get_temperature(location, date=None, unit="celsius"):
"""Get temperature for a location (current or specific date)."""
if date:
return {"temperature": 25.9, "location": location, "date": date, "unit": unit}
return {"temperature": 26.1, "location": location, "unit": unit}
tools = [
{
"name": "get_temperature",
"description": "Get temperature for a location (current or by date).",
"parameters": {
"location": "string", "date": "string (optional)", "unit": "enum [celsius, fahrenheit]"
},
}
]
messages = [{"role": "user", "content": "ΰΈΰΈΈΰΈΰΈ«ΰΈ ΰΈΉΰΈ‘ΰΈ΄ΰΈΰΈ΅ΰΉ San Francisco ΰΈ§ΰΈ±ΰΈΰΈΰΈ΅ΰΉΰΈ΅ΰΉΰΈ₯ΰΈ°ΰΈΰΈ£ΰΈΈΰΉΰΉΰΈΰΈΰΈ΅ΰΉΰΈΰΈ·ΰΈΰΉΰΈΰΉΰΈ²ΰΉΰΈ£ΰΉ?"}]
# Simulated response flow using OpenThaiGPT Tool Calling
response = openai.ChatCompletion.create(
model=".", messages=messages, tools=tools, temperature=0.7, max_tokens=512
)
print(response)
Full example: https://github.com/OpenThaiGPT/openthaigpt1.5_api_examples/blob/main/api_tool_calling_powered_by_siamai.py
GPU Memory Requirements
| Number of Parameters | FP 16 bits | 8 bits (Quantized) | 4 bits (Quantized) | Example Graphic Card for 4 bits |
|---|---|---|---|---|
| 7b | 24 GB | 12 GB | 6 GB | Nvidia RTX 4060 8GB |
| 13b | 48 GB | 24 GB | 12 GB | Nvidia RTX 4070 16GB |
| 72b | 192 GB | 96 GB | 48 GB | Nvidia RTX 4090 24GB x 2 cards |
OpenThaiGPT Team
- Sumeth Yuenyong (sumeth.yue@mahidol.edu)
- Kobkrit Viriyayudhakorn (kobkrit@aieat.or.th)
- Apivadee Piyatumrong (apivadee.piy@nectec.or.th)
- Jillaphat Jaroenkantasima (autsadang41@gmail.com)
- Thaweewat Rugsujarit (thaweewr@scg.com)
- Norapat Buppodom (new@norapat.com)
- Koravich Sangkaew (kwankoravich@gmail.com)
- Peerawat Rojratchadakorn (peerawat.roj@gmail.com)
- Surapon Nonesung (nonesungsurapon@gmail.com)
- Chanon Utupon (chanon.utupon@gmail.com)
- Sadhis Wongprayoon (sadhis.tae@gmail.com)
- Nucharee Thongthungwong (nuchhub@hotmail.com)
- Chawakorn Phiantham (mondcha1507@gmail.com)
- Patteera Triamamornwooth (patt.patteera@gmail.com)
- Nattarika Juntarapaoraya (natt.juntara@gmail.com)
- Kriangkrai Saetan (kraitan.ss21@gmail.com)
- Pitikorn Khlaisamniang (pitikorn32@gmail.com)
Citation
If OpenThaiGPT has been beneficial for your work, kindly consider citing it as follows:
Bibtex
@misc{yuenyong2024openthaigpt15thaicentricopen,
title={OpenThaiGPT 1.5: A Thai-Centric Open Source Large Language Model},
author={Sumeth Yuenyong and Kobkrit Viriyayudhakorn and Apivadee Piyatumrong and Jillaphat Jaroenkantasima},
year={2024},
eprint={2411.07238},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2411.07238},
}
APA Style (for TXT, MS Word)
Yuenyong, S., Viriyayudhakorn, K., Piyatumrong, A., & Jaroenkantasima, J. (2024). OpenThaiGPT 1.5: A Thai-Centric Open Source Large Language Model. arXiv [Cs.CL]. Retrieved from http://arxiv.org/abs/2411.07238
Disclaimer: Provided responses are not guaranteed.
- Downloads last month
- 123
Model tree for openthaigpt/openthaigpt1.5-72b-instruct
Collection including openthaigpt/openthaigpt1.5-72b-instruct
Papers for openthaigpt/openthaigpt1.5-72b-instruct
OpenThaiGPT 1.5: A Thai-Centric Open Source Large Language Model
YaRN: Efficient Context Window Extension of Large Language Models
Evaluation results
- Thai Exam(Acc) on ThaiExamπΉπ Thai LLM Leaderboard63.890
- M3Exam(Acc) on M3ExamπΉπ Thai LLM Leaderboard70.390

