Qwen2.5-7B-ViLegalQA

This model is a fine-tuned version of Qwen/Qwen2.5-7B-Instruct optimized for Vietnamese Legal Consulting (Tư vấn pháp luật).

It is designed to assist with answering legal questions, analyzing situations based on logic, and citing relevant legal contexts where possible.

Model Details

  • Developed by: PeterPaker123
  • Language: Vietnamese
  • Base Model: Qwen/Qwen2.5-7B-Instruct
  • Task: Legal Question Answering & Consulting
  • Domain: Vietnamese Law

Intended Use

This model is designed to act as a legal assistant for Vietnamese speakers. It is particularly effective at:

  • Answering questions regarding Vietnamese Civil, Criminal, and Labor laws.
  • Explaining legal concepts in simple terms.
  • Logical reasoning based on provided legal contexts.

System Prompt

To achieve the intended performance, you must use the following system prompt (as defined in the training/inference script):

Bạn là một chuyên gia tư vấn pháp lý. Hãy sử dụng tư duy logic và kiến thức luật pháp để hoàn thành nhiệm vụ, đảm bảo mọi thông tin đưa ra đều có căn cứ từ văn bản được cung cấp

Usage Example

Below is a Python script to run the model with the correct configuration and streaming generation.

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer

# 1. Configuration
MODEL_PATH = "PeterPaker123/Qwen2.5-7B-ViLegalQA"
SYSTEM_PROMPT = "Bạn là một chuyên gia tư vấn pháp lý. Hãy sử dụng tư duy logic và kiến thức luật pháp để hoàn thành nhiệm vụ, đảm bảo mọi thông tin đưa ra đều có căn cứ từ văn bản được cung cấp"

# 2. Load Model & Tokenizer
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
model = AutoModelForCausalLM.from_pretrained(
    MODEL_PATH,
    torch_dtype=torch.bfloat16,
    device_map="auto"
)
model.eval()

# 3. Prepare Input
# Example: asking about labor contract termination
user_query = "Người lao động có quyền đơn phương chấm dứt hợp đồng lao động không?"

conversation = [
    {"role": "system", "content": SYSTEM_PROMPT},
    {"role": "user", "content": user_query}
]

text = tokenizer.apply_chat_template(
    conversation, 
    tokenize=False, 
    add_generation_prompt=True
)

inputs = tokenizer(text, return_tensors="pt").to("cuda")

# 4. Generate
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)

print("Bot is typing...")
with torch.no_grad():
    _ = model.generate(
        **inputs, 
        max_new_tokens=1024,
        pad_token_id=tokenizer.eos_token_id,
        streamer=streamer,
        temperature=0.6,
        top_p=0.9,
        do_sample=True
    )

Limitations & Disclaimer

  • Not a Real Lawyer: This model is an AI assistant, not a licensed attorney. The information provided should not be considered official legal advice.
  • Verification Required: Users should always consult with a qualified legal professional and verify citations against current official legal documents (Van ban phap luat).
  • Hallucinations: Like all Large Language Models (LLMs), this model may occasionally generate plausible-sounding but incorrect legal article numbers or interpretations.
  • Temporal Cutoff: Laws change frequently. The model's knowledge is limited to the dataset it was trained on and may not reflect the absolute latest decrees or circulars.

Ethical Considerations

  • Bias: The model may reflect biases present in the legal text or training data.
  • Misuse: This tool should not be used to generate fraudulent legal documents or to bypass professional legal counsel in critical court cases.

Credits

  • The Qwen Team: For the Qwen 2.5 base model architecture.
  • Community Datasets: Acknowledgments to the Vietnamese open-source community for legal datasets (e.g., ViLegalQA) that contribute to the development of models in this domain.
Downloads last month
9
Safetensors
Model size
8B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for PeterPaker123/Qwen2.5-7B-ViLegalQA-Mini

Base model

Qwen/Qwen2.5-7B
Finetuned
(2626)
this model