开放权重
OpenThai 2.0 Legal
一个记得住泰国法条、并会标明所引条文的法律模型。
- 参数量30B激活 3B
- 自建最低24GB 显存
- 给定法条时的引用 F10.99
- 上下文256Ktoken
2026 年 7 月 24 日开放权重;托管 API 按每 1K 输入 / 输出 token 0.01 / 0.02 IC 计费。
能做什么
- 标明所引条文用泰语作答,并以 JSON 给出所依据的法律名称与条文(มาตรา),便于程序核验。
- 记得住法条提示词中不提供法条时,在《民商法典》上的召回率约为 Qwen3.6-35B 的 4 倍。
- 撰写法律分析在泰国最高法院判例上,引用、裁判结论、要点覆盖与行文质量均领先 Qwen3.6-35B。
- 在你的硬件上运行4-bit 权重只需一张 24 GB GPU,案件数据不出你的网络。
在线试用
用泰语提问。回答依据 39 部泰国法律、约 6,300 条,并列出所用条文。
成篇的法律分析,行文中引用条文——以自动检索的现行法条原文为依据。
开发者视图——本演示背后的 API 调用
下面的 curl 命令会随你在上方修改问题、模式与选项而实时更新。复制到终端、换上你的 API 密钥即可运行——与本页面发送的请求完全一致。
curl -s https://api.iapp.co.th/v3/llm/openthai2p0-legal/chat/completions \
-H "Content-Type: application/json" \
-H "apikey: YOUR_IAPP_API_KEY" \
-d '{
"model": "openthai2.0-legal",
"rag": true,
"rag_inject": "system",
"messages": [
{
"role": "system",
"content": "You are a Thai legal expert. Answer with legal analysis and cite the relevant มาตรา."
},
{
"role": "user",
"content": "จำเลยขีดฆ่าและฉีกเอกสารหลักฐานแห่งหนี้ แม้ยังอ่านได้ ถือเป็นความผิดสำเร็จหรือเพียงพยายามกระทำผิด"
}
],
"temperature": 0,
"top_p": 1,
"max_tokens": 4096,
"chat_template_kwargs": {
"enable_thinking": true
},
"stream": true,
"stream_options": {
"include_usage": true
}
}'输出仅为决策辅助,并非法律意见;请对照现行法律核验每处引用。
实测
- 记分板
- 表格

| 测试(0 到 1 分) | OpenThai 2.0 Legal | Qwen3.6-35B | 基座模型 |
|---|---|---|---|
| 《民商法典》,提示词中给出法条(n=3,729) | 0.99 | 0.99 | 0.98 |
| 《民商法典》,凭记忆作答(n=3,729) | 0.07 | 0.02 | 0.001 |
| 《税法典》,在干扰项中选出适用条文(n=50) | 0.69 | 0.64 | 0.45 |
| 最高法院判例论述,引用正确(n=72) | 0.25 | 0.09 | 0.02 |
| 最高法院判例论述,裁判结论正确(n=72) | 0.57 | 0.50 | 0.31 |
引用类指标采用 NitiBench 的 citation-F1 评分器(单次推理,temperature 0,关闭思考模式);论述的裁判结论、要点覆盖与行文质量由 LLM 评判。所有模型均在同一套协议下重新评测,记分板列出全部维度。
运行
- 托管 API
- curl
- vLLM
- NVIDIA NIM
使用 iApp API 密钥调用(注册后进入 API Keys),按每 1K 输入 / 输出 token 0.01 / 0.02 IC 计费,限 30 次请求/分钟。检索默认开启,所用条文在 retrieved_documents 中返回。全部参数见 API 参考。
from openai import OpenAI
client = OpenAI(base_url="https://api.iapp.co.th/v3/llm/openthai2p0-legal", api_key="YOUR_IAPP_API_KEY")
r = client.chat.completions.create(
model="openthai2.0-legal",
messages=[{"role": "user", "content": "ลักทรัพย์ในเวลากลางคืน ผิดมาตราใด"}],
max_tokens=1024,
# extra_body={"rag": False} # 调用裸模型(闭卷)
)
print(r.choices[0].message.content)
print(r.model_extra.get("retrieved_documents")) # 回答依据的法条
curl -s https://api.iapp.co.th/v3/llm/openthai2p0-legal/chat/completions \
-H "Content-Type: application/json" -H "apikey: YOUR_IAPP_API_KEY" \
-d '{"model":"openthai2.0-legal","messages":[{"role":"user","content":"ลักทรัพย์ในเวลากลางคืน ผิดมาตราใด"}],"max_tokens":1024}'
已在 vLLM 0.19.1、两张 H100(80 GB)上验证。单卡部署时,请在显存不低于 24 GB 的显卡上加载 NVFP4(4-bit)权重。
vllm serve iapp/openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b \
--tensor-parallel-size 2 --trust-remote-code \
--max-model-len 32768 --enforce-eager
容器标签请以 NVIDIA NIM for LLMs catalog 上的最新版本为准。NIM 与 vLLM 提供相同的兼容 OpenAI 接口。
docker run --rm --gpus all --shm-size=16g \
-v <path-to-model>:/model \
-e NIM_MODEL_NAME=/model \
-e NIM_SERVED_MODEL_NAME=openthai2.0-legal \
-p 8000:8000 \
nvcr.io/nim/nvidia/llm-nim:latest
需要注意的设置
| 作答类型 | 采样 | 最大 token |
|---|---|---|
| 带引用,JSON 输出 | temperature 0.0,关闭思考 | 1,024 |
| 法律论述 | temperature 0.7,top_p 0.9 | 2,048 至 4,096 |
加上 "chat_template_kwargs": {"enable_thinking": true} 可在 <think>...</think> 中查看推理过程。--max-model-len 请设为 32768 或以上:真实的《税法典》上下文会超出更小的窗口。
JSON 引用作答与论述的提示词
提示词中给出法条(RAG 场景),调用自建服务:
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",
messages=[{"role": "system", "content": SYSTEM}, {"role": "user", "content": USER}],
temperature=0.0, max_tokens=1024,
extra_body={"chat_template_kwargs": {"enable_thinking": False}})
print(r.choices[0].message.content)
模型实际输出:
{"answer": "นาย ก. ต้องรับผิดตามประมวลกฎหมายแพ่งและพาณิชย์ มาตรา 420",
"citations": [{"law": "ประมวลกฎหมายแพ่งและพาณิชย์", "section": "420"}]}
凭记忆作答、不提供法条时,改用以下 system prompt,只发送问题:
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>"}]}.')
论述场景只需把这段简短的 system prompt 与问题一起发送,模型会在行文中引用条文(มาตรา),而非输出 JSON:
SYSTEM = "You are a Thai legal expert. Answer the question with legal analysis and cite the relevant มาตรา."
如需接入自己的检索,请参照 Open WebUI 与 OpenThaiRAG 教程,按条文(มาตรา)切分,每条一个 chunk,并附 law_name 与 section 元数据。如需在贵机构部署或针对自有语料微调,请联系 sale@iapp.co.th 或致电 02-124-4041。