Qwen3-4B-Vietnamese-Legal-Chat
Model Description
Qwen3-4B-Vietnamese-Legal-Chat is a specialized model fine-tuned from Qwen3-4B-Base for Vietnamese legal reasoning tasks. Optimized for the VLSP 2025 LegalSML Challenge, particularly Task 3: Syllogism Questions - complex legal scenarios requiring structured reasoning and logical analysis.
Key Capabilities:
- Vietnamese legal text comprehension and reasoning
- This model is NOT INCLUDE THINKING MODE
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "luanngo/Qwen3-4B-Vietnamese-Legal-Chat"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
question = "Ông A là người lao động tham gia bảo hiểm y tế bắt buộc theo quy định. Trong năm 2025, ông A bị ốm nặng và phải điều trị dài ngày. Ông A thắc mắc về mức hưởng bảo hiểm y tế và trách nhiệm chi trả chi phí khám chữa bệnh. Theo quy định hiện hành, hậu quả pháp lý nào sẽ xảy ra đối với ông A trong việc hưởng bảo hiểm y tế và chi trả chi phí khám chữa bệnh?"
# Prompt for VLSP 2025 LegalSML Task 3 - Syllogism Questions
base_prompt = f"""Bạn là một chuyên gia pháp lý. Hãy trả lời câu hỏi pháp luật dựa trên kiến thức chuyên môn của mình. Khi trả lời:
- Phân tích pháp lý một cách tự nhiên, như đang nhớ lại và vận dụng kiến thức chuyên môn.
- Sử dụng các cách diễn đạt như: "Theo quy định tại...", "Căn cứ vào...", "Trong trường hợp này...".
- Kết thúc bằng một kết luận rõ ràng, trực tiếp trả lời câu hỏi.
Định dạng đầu ra:
Phân tích pháp lý: [nội dung phân tích]
Kết luận: [câu trả lời cụ thể]
Câu hỏi: {question}"""
messages = [{"role": "user", "content": base_prompt}]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
# Generate response
generated_ids = model.generate(**model_inputs, max_new_tokens=16384, eos_token_id=tokenizer.eos_token_id)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
content = tokenizer.decode(output_ids, skip_special_tokens=True)
# Extract final conclusion for VLSP 2025 Syllogism Questions Task
if "Kết luận:" in content:
final_answer = content.split("Kết luận:")[1].strip()
print("Final answer:", final_answer)
else:
print("Final answer:", content)
Citation
@misc{qwen3-vietnamese-legal-2025,
title={Qwen3-4B-Vietnamese-Legal-Chat},
author={Luan Ngo},
year={2025},
publisher={Hugging Face}
}
License
Please refer to the original Qwen3 model license for usage terms.
- Downloads last month
- 27
Model tree for luanngo/Qwen3-4B-VietNamese-Legal-Chat
Base model
Qwen/Qwen3-4B-Base