Views
No views yet
qwen3-1.7b-vivu-travel-vn is a 1.7 Billion parameter Small Language Model (SLM) domain-specifically fine-tuned for the Vietnamese Tourism Industry. Built upon the advanced architecture of Qwen3-1.7B, this model serves as ViVu, an intelligent virtual assistant specifically designed for seamless integration into Retrieval-Augmented Generation (RAG) pipelines.<context>...</context>).unsloth/Qwen3-1.7Btrain_on_responses_only).1# pip install transformers accelerate
2
3import torch
4from transformers import AutoModelForCausalLM, AutoTokenizer
5
6model_name = "thanhdo881/qwen3-1.7b-vivu-travel-vn"
7
8# 1. Load Model & Tokenizer
9model = AutoModelForCausalLM.from_pretrained(
10 model_name,
11 torch_dtype=torch.bfloat16, # Or float16 depending on your hardware
12 device_map="auto"
13)
14tokenizer = AutoTokenizer.from_pretrained(model_name)
15
16# 2. Strict System Prompt (Mandatory to trigger the ViVu persona)
17# NOTE: Keep this in Vietnamese as the model was fine-tuned on this exact string.
18SYSTEM_PROMPT = "Bạn là trợ lý du lịch AI chuyên nghiệp. Hãy trả lời chính xác dựa trên ngữ cảnh được cung cấp. Yêu cầu bắt buộc: Chỉ sử dụng 100% TIẾNG VIỆT, tuyệt đối không sử dụng tiếng Trung, tiếng Anh hay bất kỳ ngôn ngữ nào khác."
19
20# 3. Prepare Input (Using the standard XML tag structure)
21context = "Đà Lạt nằm trên cao nguyên Lâm Viên, nổi tiếng với khí hậu ôn đới và Hồ Xuân Hương."
22question = "Đà Lạt có những đặc điểm gì nổi bật?"
23
24user_content = f"<context>\n{context}\n</context>\n\nCÂU HỎI:\n{question}"
25
26messages = [
27 {"role": "system", "content": SYSTEM_PROMPT},
28 {"role": "user", "content": user_content}
29]
30
31# 4. Generate Text (CRITICAL: Disable Thinking Mode)
32text = tokenizer.apply_chat_template(
33 messages,
34 tokenize=False,
35 add_generation_prompt=True,
36 enable_thinking=False # Must be False for this fine-tune
37)
38inputs = tokenizer([text], return_tensors="pt").to(model.device)
39
40# Recommended parameters for Non-Thinking Qwen3
41outputs = model.generate(
42 **inputs,
43 max_new_tokens=256,
44 temperature=0.7,
45 top_p=0.8,
46 do_sample=True
47)
48response = tokenizer.batch_decode(outputs[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)[0]
49
50print(response)