Text Generation
Transformers
Safetensors
English
Vietnamese
llama
text-generation-inference
retrieval-augmented-generation
unsloth
trl
sft
Instructions to use NaverHustQA/LawVinaLlama with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NaverHustQA/LawVinaLlama with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NaverHustQA/LawVinaLlama")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("NaverHustQA/LawVinaLlama") model = AutoModelForCausalLM.from_pretrained("NaverHustQA/LawVinaLlama", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NaverHustQA/LawVinaLlama with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NaverHustQA/LawVinaLlama" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NaverHustQA/LawVinaLlama", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/NaverHustQA/LawVinaLlama
- SGLang
How to use NaverHustQA/LawVinaLlama 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 "NaverHustQA/LawVinaLlama" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NaverHustQA/LawVinaLlama", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "NaverHustQA/LawVinaLlama" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NaverHustQA/LawVinaLlama", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Unsloth Desktop
- Docker Model Runner
How to use NaverHustQA/LawVinaLlama with Docker Model Runner:
docker model run hf.co/NaverHustQA/LawVinaLlama
Model Card: LawVinaLlama
Model Description:
LawVinaLlama is a large language model (LLM) specialized in Vietnamese law, fine-tuned from the Llama architecture. The model has been trained on real legal documents to improve its ability to reason, retrieve legal information, and summarize legal content.
Main Data Sources:
- 150,000 Q&A crawled and processed from Thư Viện Pháp Luật (Vietnamese Legal Library)
- 40,000 Q&A translated and summarized from international law
- 10,000 Q&A translated and summarized from international law (duplicate, possibly an error)
- 50,000 Reasoning Q&A generated by GPT-4.0/Gemini
Intended Use Cases:
LawVinaLlama is suitable for the following tasks:
- Answering legal questions / Providing legal answers based on a given context
- Summarizing legal content
Limitations:
LawVinaLlama may still encounter some limitations:
- It may generate misleading or inaccurate information.
- Its performance depends on the quality of the input data.
How to Use:
Load model
from unsloth import FastLanguageModel
import torch
max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!
dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = 'NaverHustQA/LawVinaLlama',
max_seq_length = max_seq_length,
dtype = dtype,
load_in_4bit = load_in_4bit,
)
Generate
PROMPT = """
### Hướng dẫn: Bạn là một trợ lí Tiếng Việt. Hãy luôn trả lời một cách trung thực và an toàn
Câu trả lời của bạn không nên chứa bất kỳ nội dung gây hại, nguy hiểm hoặc bất hợp pháp nào
Nếu một câu hỏi không có ý nghĩa hoặc không hợp lý về mặt thông tin, hãy giải thích tại sao thay vì trả lời một điều gì đó không chính xác
Nếu bạn không biết câu trả lời cho một câu hỏi, hãy trẳ lời là bạn không biết và vui lòng không chia sẻ thông tin sai lệch.
### Câu hỏi: {input}
"""
question = """Trình bày về thủ tục li hôn ?"""
text = PROMPT.format_map({
'input': question,
})
input_ids = tokenizer(text, return_tensors='pt', add_special_tokens=False).to('cuda')
generated_ids = model.generate(
input_ids=input_ids['input_ids'],
max_new_tokens=1024,
do_sample=True,
top_p=0.95,
top_k=40,
temperature=0.3,
repetition_penalty=1.1,
no_repeat_ngram_size=7,
num_beams=5,
)
a = tokenizer.batch_decode(generated_ids)[0]
# print(a.split('### Trả lời:')[1])
print(a)
Citation:
Please cite our paper if you find our work helpful:
@article{10.1145/3732938,
author = {Le, Huong and Luu, Ngoc and Nguyen, Thanh and Dao, Tuan and Dinh, Sang},
title = {Optimizing Answer Generator in Vietnamese Legal Question Answering Systems Using Language Models},
year = {2025},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
issn = {2375-4699},
url = {https://doi.org/10.1145/3732938},
doi = {10.1145/3732938},
journal = {ACM Trans. Asian Low-Resour. Lang. Inf. Process.},
}
- Downloads last month
- 79
Model tree for NaverHustQA/LawVinaLlama
Base model
vilm/vinallama-7b