Downloads · 30 days
22
10% of all-time downloads
LeeKayn/Vistral-7B-Medical-Chat-v2
Vistral-7B-Medical-Chat-v2 is a text generation model from LeeKayn. Use it when you need the model to write or continue text. The card lists the license as apache-2.0.
Đây là phiên bản đã merge của Vistral-7B-Chat với adapter LeeKayn/Vistralmedical2205v1.3, được tối ưu cho tư vấn y tế bằng tiếng Việt.
Downloads · 30 days
22
10% of all-time downloads
All-time downloads
226
Public
Parameters
7.3B
14.6 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors14.6 GB · 100%
From the Hugging Face model README
Đây là phiên bản đã merge của Vistral-7B-Chat với adapter LeeKayn/Vistral_medical_2205_v1.3, được tối ưu cho tư vấn y tế bằng tiếng Việt.
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
import torch
# Quantization config
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
)
# Load model
model = AutoModelForCausalLM.from_pretrained(
"LeeKayn/Vistral-7B-Medical-Chat-v2",
quantization_config=bnb_config,
torch_dtype=torch.float16,
device_map="auto",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("LeeKayn/Vistral-7B-Medical-Chat-v2", trust_remote_code=True)
# Generate
def ask_medical_question(question):
prompt = f"<s>[INST] Bạn là bác sĩ chuyên khoa. Hãy trả lời câu hỏi y tế sau một cách chính xác: {question} [/INST]"
inputs = tokenizer(prompt, return_tensors="pt")
with torch.inference_mode():
outputs = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.1,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True)
return response.strip()
# Ví dụ
answer = ask_medical_question("Triệu chứng của bệnh tiểu đường là gì?")
print(answer)