A Vietnamese Legal SLM fine-tuned from
Qwen/Qwen3-4B on the
VLegal-Bench dataset using QLoRA.
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "datht/viet-legal-4B"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
6
7messages = [
8 {"role": "system", "content": "Bạn là một trợ lý pháp luật Việt Nam."},
9 {"role": "user", "content": "Hành vi trộm cắp tài sản trị giá 5 triệu đồng bị xử lý như thế nào?"},
10]
11
12text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
13inputs = tokenizer(text, return_tensors="pt").to(model.device)
14outputs = model.generate(**inputs, max_new_tokens=512)
15print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
VLegal-Bench — A cognitively grounded benchmark for Vietnamese legal reasoning, comprising 10,467 samples across 22 tasks organized into 5 categories:
Trained with
nlp-trainer using Unsloth + TRL SFTTrainer with QLoRA on Kaggle T4 GPU.
1@misc{dong2025vlegalbench,
2 title={VLegal-Bench: Cognitively Grounded Benchmark for Vietnamese Legal Reasoning of Large Language Models},
3 author={Nguyen Tien Dong and others},
4 year={2025},
5 eprint={2512.14554},
6 archivePrefix={arXiv},
7}