Downloads · 30 days
16
9% of all-time downloads
thangvip/qwen3-1.7b-vietnamese-legal-grpo
qwen3-1.7b-vietnamese-legal-grpo is a text generation model from thangvip. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
This model is a Vietnamese legal reasoning specialist fine-tuned using Group Relative Policy Optimization (GRPO) on Vietnamese legal question-answering data. It's specifically designed to perform syllogistic reasoning…
Downloads · 30 days
16
9% of all-time downloads
All-time downloads
171
Public
Parameters
1.7B
3.5 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors3.4 GB · 100%
From the Hugging Face model README
This model is a Vietnamese legal reasoning specialist fine-tuned using Group Relative Policy Optimization (GRPO) on Vietnamese legal question-answering data. It's specifically designed to perform syllogistic reasoning for Vietnamese legal scenarios.
✅ Syllogistic Reasoning: Structured legal arguments (Major Premise → Minor Premise → Conclusion)
✅ Vietnamese Legal Domain: Trained on Vietnamese legal texts and Q&A
✅ GRPO Optimization: Advanced policy optimization for better reasoning
✅ Citation Support: Generates responses with legal citations
✅ Structured Output: Uses XML-like tags for organized responses
pip install transformers torch
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
# Load model and tokenizer
model_name = "thangvip/qwen3-1.7b-vietnamese-legal-grpo"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map="auto"
)
# Format your legal question
system_prompt = """Bạn là một chuyên gia pháp lý. Hãy trả lời câu hỏi bằng cách sử dụng phương pháp lập luận tam đoạn luận (syllogism).
Trước tiên, hãy suy nghĩ về vấn đề trong thẻ <think></think>.
Sau đó, trả lời theo định dạng sau:
<answer>
<major_premise>[Quy định pháp luật chung]</major_premise>
<minor_premise>[Sự kiện cụ thể trong câu hỏi]</minor_premise>
<conclusion>[Áp dụng quy định vào sự kiện để đưa ra kết luận]</conclusion>
</answer>
Hãy đảm bảo trích dẫn chính xác các điều luật liên quan."""
question = "Một công ty có nghĩa vụ gì khi sa thải nhân viên do tái cơ cấu?"
# Create conversation
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": question}
]
# Generate response
input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=1024,
temperature=0.7,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)
print(response)
from transformers import pipeline
# Create text generation pipeline
generator = pipeline(
"text-generation",
model="thangvip/qwen3-1.7b-vietnamese-legal-grpo",
tokenizer="thangvip/qwen3-1.7b-vietnamese-legal-grpo",
torch_dtype=torch.bfloat16,
device_map="auto"
)
# Generate legal reasoning
prompt = "Câu hỏi: Quyền và nghĩa vụ của người thuê nhà khi hợp đồng thuê hết hạn?"
result = generator(prompt, max_new_tokens=512, temperature=0.7)
print(result[0]['generated_text'])
The model was trained with a sophisticated reward system:
The model generates structured responses in this format:
<think>
[Internal reasoning about the legal question]
</think>
<answer>
<major_premise>
[General legal rule or principle applicable to the situation]
</major_premise>
<minor_premise>
[Specific facts from the question that relate to the legal rule]
</minor_premise>
<conclusion>
[Legal conclusion that follows logically from applying the rule to the facts]
</conclusion>
</answer>
If you use this model, please cite:
@misc{vietnamese-legal-grpo-2024,
title={Vietnamese Legal Reasoning Model with GRPO},
author={Your Name},
year={2024},
publisher={Hugging Face},
url={https://huggingface.co/thangvip/qwen3-1.7b-vietnamese-legal-grpo}
}
Contributions are welcome! Please see our contributing guidelines.
This model is released under the Apache 2.0 License.
Note: This model is for educational and research purposes. Always consult qualified legal professionals for actual legal advice.