Downloads · 30 days
109
5% of all-time downloads
iapp/openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b-NVFP4
openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b-NVFP4 is a text generation model from iapp. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as other.
openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b-NVFP4
Downloads · 30 days
109
5% of all-time downloads
All-time downloads
2.1K
Public
Parameters
31.6B
20.1 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors20.1 GB · 100%
How the weights are stored.
U830B · 95%
From the Hugging Face model README
openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b-NVFP4
Developed by iApp, launched with AIEAT. Part of OpenThai (formerly OpenThaiGPT).
NVFP4 4-bit build. Runs on a single 24 GB GPU (RTX 4090, RTX 5090). This is the quantized edition of openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b; the full-precision model card applies unless noted below.


An open-weight model exploring how far Thai legal knowledge and verifiable, section-level citation can be pushed on a self-hostable 30B base, with or without retrieval.

| Evaluation | OpenThai2.0-Legal | Qwen3.6-35B | Nemotron-3-30B base |
|---|---|---|---|
| Closed-book: knows the law from memory | |||
| Civil & Commercial: recall the Civil and Commercial Code (n=3,729) | 0.07 | 0.02 | 0.001 |
| Tax: recall the Revenue Code (n=50) | 0.40 | 0.36 | 0.31 |
| Open-book: uses provided law (the RAG setting) | |||
| Civil & Commercial: cite the applicable sections from context (n=3,729) | 0.99 | 0.99 | 0.98 |
| Tax echo: cite the sections provided (n=50) | 0.84 | 0.84 | 0.64 |
| Tax selection: cite only the applicable sections among distractors (n=50) | 0.69 | 0.64 | 0.45 |
| Legal essays (Thai Supreme Court cases): legal substance (holding, coverage and fluency judged by Gemini 3.1 Flash Lite) | |||
| Citations: correct citations inside the essay (n=72) | 0.25 | 0.09 | 0.02 |
| Holding: reaches the correct legal conclusion (n=72) | 0.57 | 0.50 | 0.31 |
| Coverage: covers the key legal points (n=72) | 0.60 | 0.55 | 0.27 |
| Fluency: writing quality (n=72) | 0.46 | 0.43 | 0.13 |
Three stages on the NVIDIA NeMo stack, each solving one problem:

This build is the full-precision model compressed to NVFP4 (NVIDIA's 4-bit floating-point format) with NVIDIA's open quantization tooling.
Use this build for citation and RAG on one GPU. Use the full-precision model for essay drafting and the best all-round quality.
| Quantized from | iapp/openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b (full precision) |
| Base model | nvidia/Nemotron-3-Nano-Omni-30B-A3B-Reasoning (text core extracted; Mamba2-Transformer hybrid MoE) |
| Parameters | 30B total, ~3B active per token |
| Context length | 32,768 served window, prompt plus completion (architecture supports up to 256k) |
| Languages | Thai (primary), English (reasoning) |
| Precision | NVFP4 4-bit weights (experts + attention); Mamba layers and output head in bfloat16. ~20 GB, 5 shards |
| Training stack | NVIDIA NeMo (Megatron-Bridge for CPT/SFT, NeMo-RL for GRPO) |
| Serving | vLLM on a single GPU (verified); OpenAI-compatible |
| Status | Open-weight release |
RAG mode means you put candidate law sections in the prompt and the model cites only the ones that apply. It works with any retriever you already have and needs no particular embedding or rerank model. Because it is also strong closed-book, many questions need no retrieval at all.
Four modes, covering how a legal model is actually used:
| Mode | What it tests | Setup |
|---|---|---|
| Open-book "echo" | RAG best case: uses exactly the right documents | Only the relevant sections are provided; cite them all |
| Open-book "selection" | RAG realistic case: rejects near-miss documents | Relevant sections mixed with inapplicable ones; cite only the right subset |
| Closed-book | Pure memory, no retrieval | The question alone; recall law name and section from weights |
| Legal essays | Long-form legal writing | 72 held-out Thai Supreme Court cases reformatted as essay questions, graded on citations, holding, coverage and fluency |
All examples are verbatim model output on held-out benchmark questions.
Open-book selection, the hardest mode. Five sections supplied, three applicable.
TH (question): บริษัทจัดตั้งขึ้นตามกฎหมายประเทศไทย ... ได้แต่งตั้งให้ผู้บริหารหรือพนักงานไปดำรงตำแหน่งกรรมการในบริษัทลูกในต่างประเทศ โดยจะได้รับค่าตอบแทนเงินเดือน สวัสดิการต่าง ๆ
TH (answer): 1. บริษัทมีหน้าที่ต้องนำเงินได้ที่จ่ายจากหน้าที่งานที่ทำให้นายจ้างในประเทศไทยมารวมคำนวณเป็นรายได้เพื่อนำส่งภาษีหัก ณ ที่จ่าย ตามมาตรา 50 (1) แห่งประมวลรัษฎากร ... 2. ... หากไม่ได้นำเงินค่าตอบแทนที่ได้รับเข้ามาในประเทศไทยในปีภาษีเดียวกัน ผู้บริหารหรือพนักงานดังกล่าวไม่มีหน้าที่ต้องเสียภาษีเงินได้บุคคลธรรมดา
EN (question): A Thai company posts executives to serve as directors of its overseas subsidiaries, where they receive salary and benefits. What are the withholding and personal income tax consequences?
EN (answer): The company must include income paid for duties performed for the Thai employer when computing withholding tax under Revenue Code section 50(1). An executive paid for the overseas directorship is not liable to Thai personal income tax if the money is not brought into Thailand in the same tax year.
Cited 41, 50 and 56; left out 40 and 48. Citation F1 1.00.
Closed-book, no statute text in the prompt at all.
TH (question): บริษัทฯ ได้นำเข้าสินค้าชื่อว่า "C." เพื่อใช้ทดแทน Choline Chloride ในอาหารสัตว์ โดยมีสรรพคุณใช้เพื่อช่วยในการทำงานของตับ ... ได้รับยกเว้นภาษีมูลค่าเพิ่มหรือไม่
TH (answer): การนำเข้าสินค้าชื่อ "C." ... โดยบริษัทฯ เป็นผู้รับใบอนุญาตนำเข้าอาหารสัตว์ควบคุมเฉพาะ ถือเป็นการนำเข้าอาหารสัตว์ที่ได้รับยกเว้นภาษีมูลค่าเพิ่มตามมาตรา 81 (1) (ง) และมาตรา 81 (2) (ก) แห่งประมวลรัษฎากร
EN (question): A company imports a product "C." used in place of Choline Chloride in animal feed, to support liver function. Is the import VAT-exempt?
EN (answer): The import qualifies as an import of animal feed exempt from VAT under Revenue Code section 81(1)(d) and section 81(2)(a), the company holding the controlled animal-feed import licence.
Section and both sub-paragraphs recalled from weights, with no statute provided. Citation F1 1.00.
Legal essay, graded on four axes.
TH (question): จำเลยเป็นหนี้เงินกู้ยืมและเงินเล่นแชร์จำนวน 95,600 บาทแก่โจทก์ร่วม ซึ่งได้จดทะเบียนไว้ในสมุดบันทึกของโจทก์ร่วม โดยมีข้อความและตัวเลขเป็นหลักฐานแห่งหนี้ และจำเลยได้ลงลายมือชื่อรับรองข้อความและตัวเลขในเอกสารนั้นไว้ ต่อมาจำเลยได้ใช้ปากกาขีดฆ่าเป็นเครื่องหมายกากบาทและเครื่องหมายวงกลมลงบนข้อความและตัวเลข
TH (answer, excerpt): ศาลฎีกาพิพากษายืนตามศาลอุทธรณ์ โดยวินิจฉัยว่า การกระทำของจำเลยเป็นความผิดฐานทำให้เสียหายหรือทำลายเอกสารในประการที่น่าจะเกิดความเสียหายแก่ผู้อื่น ตามประมวลกฎหมายอาญา มาตรา 188 ... การที่จำเลยใช้ปากกาขีดฆ่าเป็นเครื่องหมายกากบาทและเครื่องหมายวงกลมลงบนข้อความและตัวเลขในเอกสารดังกล่าว แล้วฉีกเอกสารจนขาดออกจากกัน แม้เอกสารที่ยังเหลืออยู่จะสามารถอ่านเข้าใจข้อความและตัวเลขเดิมได้ ก็ถือเป็นการทำให้เสียหายหรือทำลายเอกสารในประการที่น่าจะเกิดความเสียหายแก่ผู้อื่นแล้ว
EN (question): The defendant owed the co-plaintiff 95,600 baht in loan and chit-fund debt, recorded in the co-plaintiff's ledger with text and figures evidencing the debt, which the defendant had signed to acknowledge. The defendant later struck through the text and figures with pen marks and tore the document apart.
EN (answer, excerpt): The Supreme Court affirmed the Court of Appeal, holding the defendant guilty of damaging or destroying a document in a manner likely to cause injury to another, under Criminal Code section 188 ... Striking out the text and figures and then tearing the document apart constitutes damage or destruction likely to cause injury, even though the remaining fragments can still be read.
Serve on a single GPU. The model exposes an OpenAI-compatible API, so the Python examples that follow work unchanged.
RTX 5090 (32 GB), or any single 24 GB+ GPU:
vllm serve iapp/openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b-NVFP4 \
--served-model-name openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b-NVFP4 \
--tensor-parallel-size 1 --trust-remote-code \
--max-model-len 32768 --gpu-memory-utilization 0.90
RTX 4090 (24 GB) - the weights take ~19 GiB, so make room for the KV cache with an 8-bit cache and, if needed, a smaller window:
vllm serve iapp/openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b-NVFP4 \
--served-model-name openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b-NVFP4 \
--tensor-parallel-size 1 --trust-remote-code \
--max-model-len 32768 --gpu-memory-utilization 0.95 \
--kv-cache-dtype fp8
Notes for this build:
Tested configuration: vLLM 0.19.1, tensor-parallel 1 on one H100 (80 GB), --max-model-len 32768, --gpu-memory-utilization 0.90, --trust-remote-code, MoE backend Marlin. Loads in ~18.7 GiB. Thinking on and off, and temperatures 0.0 and 0.7, all verified.
Grounded citation answering (RAG mode). This exact example was run against the released weights; the output shown is the model's real response:
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="none")
SYSTEM = ("You are OpenThaiGPT-Legal, an expert assistant on Thai law. You are given a legal "
"question and the exact statutory sections needed to answer it. Reason step by step in "
"English, then give the final answer in Thai. Cite ONLY sections present in the provided "
"context, using each section's exact law_name and bare section number (e.g. 132, 77/1). "
'Output the final answer as JSON: {"answer": "<Thai answer>", '
'"citations": [{"law": "<law_name>", "section": "<bare id>"}]}.')
USER = """Provided context:
<law law_name="ประมวลกฎหมายแพ่งและพาณิชย์" section="420">
ผู้ใดจงใจหรือประมาทเลินเล่อ ทำต่อบุคคลอื่นโดยผิดกฎหมายให้เขาเสียหาย ... จำต้องใช้ค่าสินไหมทดแทนเพื่อการนั้น
</law>
Question (ตอบเป็นภาษาไทย):
นาย ก. ขับรถโดยประมาทชนรถของนาย ข. เสียหาย นาย ก. ต้องรับผิดตามกฎหมายใด"""
r = client.chat.completions.create(
model="openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b-NVFP4",
messages=[{"role": "system", "content": SYSTEM}, {"role": "user", "content": USER}],
temperature=0.0, max_tokens=2048,
extra_body={"chat_template_kwargs": {"enable_thinking": False}})
print(r.choices[0].message.content)
Actual model output:
{"answer": "นาย ก. ต้องรับผิดตามประมวลกฎหมายแพ่งและพาณิชย์ มาตรา 420",
"citations": [{"law": "ประมวลกฎหมายแพ่งและพาณิชย์", "section": "420"}]}
Closed-book mode. No context at all. The model recalls the section from its weights.
SYSTEM = ("You are an expert on Thai law. You are given ONLY a legal question, with NO reference "
"material provided. Using your OWN knowledge of Thai statutes, answer in Thai and cite the "
"specific sections that apply (law name + bare section number, มาตรา). "
'Output ONLY a JSON object: {"answer":"<Thai answer>","citations":[{"law":"<law name>",'
'"section":"<bare section number e.g. 40 or 77/1>"}]}.')
USER = """บริษัท ก. (บริษัทฯ) ได้หารือเกี่ยวกับภาษีมูลค่าเพิ่ม กรณีการนำเข้าสินค้าที่ใช้ชื่อ C. มีข้อเท็จจริงสรุปได้ว่า บริษัทฯ ได้นำเข้าสินค้าชื่อว่า “C.” เพื่อใช้ทดแทน Choline Chloride ในอาหารสัตว์ โดยมีสรรพคุณใช้เพื่อช่วยในการทำงานของตับ และป้องกันการรั่วไหลของเอนไซม์ transaminases ในอาหารสัตว์ที่ขาด Choline แต่เนื่องจาก ข. ไม่เป็นอาหารสัตว์ ที่จะต้องขึ้นทะเบียนอาหารสัตว์ตามพระราชบัญญัติควบคุมคุณภาพอาหารสัตว์ แต่ต้องขออนุญาตนำเข้าจากกรมปศุสัตว์ ซึ่งบริษัทฯ เป็นผู้รับใบอนุญาตนำเข้าอาหารสัตว์ ตามใบอนุญาตนำเข้าอาหารสัตว์ควบคุมเฉพาะ จึงขอหารือว่า การนำเข้าสินค้าดังกล่าว เป็นการนำเข้าอาหารสัตว์ซึ่งได้รับยกเว้นภาษีมูลค่าเพิ่ม ตามมาตรา 81 (1) (ง) และมาตรา 81 (2) (ก) แห่งประมวลรัษฎากร หรือไม่"""
r = client.chat.completions.create(
model="openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b-NVFP4",
messages=[{"role": "system", "content": SYSTEM}, {"role": "user", "content": USER}],
temperature=0.0, max_tokens=2048,
extra_body={"chat_template_kwargs": {"enable_thinking": False}})
print(r.choices[0].message.content)
Essay mode. A short system prompt and the exam question. The model writes a full legal essay, citing มาตรา in prose rather than JSON, so raise max_tokens.
SYSTEM = "You are a Thai legal expert. Answer the question with legal analysis and cite the relevant มาตรา."
USER = """จำเลยเป็นหนี้เงินกู้ยืมและเงินเล่นแชร์จำนวน 95,600 บาทแก่โจทก์ร่วม ซึ่งได้จดทะเบียนไว้ในสมุดบันทึกของโจทก์ร่วม โดยมีข้อความและตัวเลขเป็นหลักฐานแห่งหนี้ และจำเลยได้ลงลายมือชื่อรับรองข้อความและตัวเลขในเอกสารนั้นไว้ ต่อมาจำเลยได้ใช้ปากกาขีดฆ่าเป็นเครื่องหมายกากบาทและเครื่องหมายวงกลมลงบนข้อความและตัวเลขในเอกสารดังกล่าว จากนั้นได้ฉีกเอกสารจนขาดออกจากกัน แม้เอกสารที่ยังเหลืออยู่จะสามารถอ่านเข้าใจข้อความและตัวเลขเดิมได้ โจทก์ร่วมจึงฟ้องว่าจำเลยมีความผิดฐานทำให้เสียหายหรือทำลายเอกสารในประการที่น่าจะเกิดความเสียหายแก่ผู้อื่น ขอให้ลงโทษ และคืนของกลางแก่เจ้าของ จำเลยให้การปฏิเสธว่าไม่ได้กระทำหรือหากกระทำก็ไม่มีความผิดสมบูรณ์เพราะเอกสารยังอ่านได้ โจทก์ร่วมจึงยื่นคำร้องขอเข้าร่วมเป็นโจทก์ ศาลชั้นต้นและศาลอุทธรณ์พิพากษาว่าจำเลยมีความผิด ให้จำคุกจำเลย 6 เดือน จำเลยอุทธรณ์และฎีกา ขอให้ยกฟ้องหรือพิจารณาใหม่โดยอ้างว่าการกระทำของตนยังไม่สมบูรณ์เพราะเอกสารยังอ่านได้ จึงเป็นเพียงการพยายามกระทำความผิดหรือไม่"""
r = client.chat.completions.create(
model="openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b-NVFP4",
messages=[{"role": "system", "content": SYSTEM}, {"role": "user", "content": USER}],
temperature=0.0, max_tokens=4096,
extra_body={"chat_template_kwargs": {"enable_thinking": False}})
print(r.choices[0].message.content)
These are the exact prompts used to evaluate the model.
| Use case | temperature | top_p | max_tokens (suggested) | thinking |
|---|---|---|---|---|
| Citation answering (RAG or closed-book) | 0.0 | 1.0 | 2048 | off |
| Legal essay drafting | 0.7 | 0.9 | 4096 (6144 with thinking) | on or off |
| General chat | 0.7 | 0.9 | 2048 | off |
Notes:
max_tokens to about twice what the same task would need in English.max_tokens is a per-request setting, not a model limit. The limit is the served context window, 32,768 tokens for prompt plus completion. At temperature 0 answers terminate naturally (citation answers have a median of 121 tokens), so a larger budget costs nothing.citations array, so the item scores zero rather than partially: measured on our own runs, a 1,024 cap truncated 5.3% of held-out tax-selection answers and cost about 0.03 macro-F1 on that split.chat_template_kwargs: {"enable_thinking": true}) is fully supported: the model reasons in English inside a think block, then answers in Thai. It helps on essays and complex analysis. The benchmark numbers above use thinking off, which is the tuned path for citation tasks; allow roughly 2x the token budget when thinking is on.--max-model-len 32768: real Revenue Code contexts overflow smaller windows.language_model tower).