Views
No views yet
KBTG-Labs/THaLLE-0.2-ThaiLLM-8B-fa is a fine-tuned of Qwen3-8B you will need to install transformers>=4.51.0.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4MODEL_ID: str = "KBTG-Labs/THaLLE-0.2-ThaiLLM-8B-fa"
5
6def inference(messages: list[dict[str, str]], model, tokenizer) -> str:
7 text = tokenizer.apply_chat_template(
8 messages,
9 tokenize=False,
10 add_generation_prompt=True,
11 enable_thinking=False, # Switches thinking modes.
12 )
13 model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
14
15 generated_ids = model.generate(
16 model_inputs.input_ids,
17 max_new_tokens=768,
18 do_sample=False,
19 temperature=None,
20 top_p=None,
21 top_k=None,
22 pad_token_id=tokenizer.eos_token_id,
23 )
24 generated_ids = [
25 output_ids[len(input_ids) :]
26 for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
27 ]
28
29 response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
30 return response
31
32if __name__ == "__main__":
33 tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
34 model = AutoModelForCausalLM.from_pretrained(
35 MODEL_ID,
36 torch_dtype=torch.bfloat16,
37 device_map="auto",
38 )
39
40 messages = [{"role": "user", "content": "สวัสดี!"}]
41 inference(messages, model, tokenizer)
42| Model | M3 Exam | M6 Exam | Flare CFA* | IC |
|---|---|---|---|---|
| Non-Thinking | ||||
Qwen3-8B | 0.660 | 0.545 | 0.753 | 0.640 |
ThaiLLM-8B-Instruct** | 0.707 | 0.623 | 0.762 | 0.720 |
THaLLE-0.2-ThaiLLM-8B-fa | 0.725 | 0.572 | 0.771 | 0.720 |
| Thinking | ||||
Qwen3-8B | 0.706 | 0.590 | 0.806 | 0.600 |
ThaiLLM-8B-Instruct** | 0.720 | 0.661 | 0.820 | 0.720 |
THaLLE-0.2-ThaiLLM-8B-fa | 0.779 | 0.678 | 0.852 | 0.840 |
"TheFinAI/flare-cfa""ThaiLLM-8B-Instruct" is KBTG-Labs/ThaiLLM-8B-Instruct@misc{labs2026thallethaillmdomainspecializedsmallllms,
title={THaLLE-ThaiLLM: Domain-Specialized Small LLMs for Finance and Thai -- Technical Report},
author={KBTG Labs and : and Anuruth Lertpiya and Danupat Khamnuansin and Kantapong Sucharitpongpan and Pornchanan Balee and Tawunrat Chalothorn and Thadpong Pongthawornkamol and Monchai Lertsutthiwong},
year={2026},
eprint={2601.04597},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2601.04597},
}