Views
No views yet
unsloth library for faster inference and lower memory usage.1pip install unsloth
2pip install --no-deps xformers trl peft accelerate bitsandbytes
31from unsloth import FastLanguageModel
2import torch
3
4model_id = "bqbbao6/llama-3.2-3b-legal-vn" # Your Model ID
5
6model, tokenizer = FastLanguageModel.from_pretrained(
7 model_name = model_id,
8 max_seq_length = 2048,
9 load_in_4bit = True, # Use 4-bit for faster inference
10)
11FastLanguageModel.for_inference(model) # Enable 2x faster inference
121# Prepare the conversation
2messages = [
3 {"role": "system", "content": "Bạn là một chuyên gia pháp luật Việt Nam."},
4 {"role": "user", "content": "Người dân có quyền tham gia quản lý nhà nước không?"},
5]
6
7# Apply Chat Template
8inputs = tokenizer.apply_chat_template(
9 messages,
10 tokenize = True,
11 add_generation_prompt = True,
12 return_tensors = "pt",
13).to("cuda")
14
15# Generate response
16outputs = model.generate(
17 input_ids = inputs,
18 max_new_tokens = 512,
19 use_cache = True
20)
21
22# Decode the output
23response = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
24print(response)
251"Cho tôi hỏi thủ tục làm căn cước công dân gắn chip hiện nay như thế nào?"
21legal
21Ngữ cảnh: Theo Nghị quyết số 98/2023/QH15, UBND thành phố Thủ Đức có thẩm quyền phê duyệt nhiệm vụ và đồ án quy hoạch phân khu, quy hoạch chi tiết các đồ án trên địa bàn.
2
3Câu hỏi: UBND thành phố Thủ Đức có quyền phê duyệt quy hoạch phân khu không?
41Có. Theo Nghị quyết số 98/2023/QH15, UBND thành phố Thủ Đức có thẩm quyền phê duyệt nhiệm vụ và đồ án quy hoạch phân khu trên địa bàn thành phố thuộc thẩm quyền của UBND Thành phố Hồ Chí Minh trước đây.
2