Text Generation
Transformers
Safetensors
Thai
llama
legal
thai
rag
llama-3.1
typhoon
curriculum-learning
question-answering
lora
conversational
text-generation-inference
Instructions to use monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag") model = AutoModelForCausalLM.from_pretrained("monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag", device_map="auto") 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag
- SGLang
How to use monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag 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 "monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag" \ --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": "monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag", "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 "monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag" \ --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": "monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag with Docker Model Runner:
docker model run hf.co/monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag
Llama3.1-Typhoon2-8B Thai Land Tax Legal RAG
Fine-tuned from scb10x/llama-3.1-typhoon2-8b-instruct for Thai statutory question answering on Land and Buildings Tax law using curriculum-based training (C4: Explicit→Implicit) with LoRA adapters (r=128, α=128).
Base Model: scb10x/llama-3.1-typhoon2-8b-instruct
Quick Start
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
"monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag",
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(
"monoboard/llama3.1-typhoon2-8b-thai-land-tax-legal-rag"
)
# Inference example
question = "พระราชบัญญัติที่กล่าวถึงในข้อความนี้มีชื่อว่าอะไร?"
contexts = [
"[ชื่อกฎหมาย:] พระราชบัญญัติภาษีที่ดินและสิ่งปลูกสร้าง พ.ศ. 2562 มาตรา 1\n[ข้อความกฎหมาย:] พระราชบัญญัตินี้เรียกว่า \"พระราชบัญญัติภาษีที่ดินและสิ่งปลูกสร้าง พ.ศ. 2562\""
]
prompt = f"""คำถาม: {question}
บริบทที่เกี่ยวข้อง:
{chr(10).join(contexts)}
กรุณาตอบคำถามโดยอ้างอิงจากบริบทที่ให้มา ตอบตามรูปแบบ 4 ส่วน:
1. Reference Law Section
2. Reasoning
3. Step-by-Step Application
4. Answer
คำตอบ:"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.7,
do_sample=True
)
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
# Extract only the answer part (after the prompt)
answer = answer[len(tokenizer.decode(inputs.input_ids[0], skip_special_tokens=True)):]
print(answer)
Expected Output
**Reference Law Section:**
- พระราชบัญญัติภาษีที่ดินและสิ่งปลูกสร้าง พ.ศ. 2562 มาตรา 1
**Reasoning:**
มาตรา 1 ระบุชื่อเรียกของพระราชบัญญัติอย่างชัดเจนว่า "พระราชบัญญัตินี้เรียกว่า 'พระราชบัญญัติภาษีที่ดินและสิ่งปลูกสร้าง พ.ศ. 2562'"
**Step-by-Step Application:**
1. คำถามถามเกี่ยวกับชื่อของพระราชบัญญัติ
2. มาตรา 1 เป็นมาตราที่กำหนดชื่อของกฎหมาย
3. สามารถตอบได้โดยตรงจากข้อความในมาตรา 1
**Answer:**
พระราชบัญญัติที่กล่าวถึงในข้อความนี้มีชื่อว่า **"พระราชบัญญัติภาษีที่ดินและสิ่งปลูกสร้าง พ.ศ. 2562"**
- Downloads last month
- 11