Views
No views yet
| Property | Value |
|---|---|
| Base Model | Mistral-7B-v0.3 |
| Fine-tuning | QLoRA merged into full weights |
| Parameters | 7B |
| Context Length | 2048 tokens |
| License | Apache 2.0 |
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model_id = "sri2000us/swasthai-medical-7b-merged"
5
6tokenizer = AutoTokenizer.from_pretrained(model_id)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 torch_dtype=torch.float16,
10 device_map="auto",
11)
12
13def ask_swasthai(question):
14 prompt = f"""### Instruction:
15You are SwasthAI, an expert Indian healthcare assistant. Answer the medical question accurately.
16
17### Input:
18{question}
19
20### Response:
21"""
22 inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
23 outputs = model.generate(**inputs, max_new_tokens=256, do_sample=True, temperature=0.7)
24 return tokenizer.decode(outputs[0], skip_special_tokens=True).split("### Response:")[-1].strip()
25
26print(ask_swasthai("What are symptoms of diabetes?"))### Instruction:
You are SwasthAI, an expert Indian healthcare assistant. Answer the medical question accurately.
### Input:
{user_question}
### Response:
{model_response}