Views
No views yet
Why this exists: Most open-source medical AI models are trained on PubMed and USMLE data — optimized for Western clinical contexts. Indian patients ask about Dolo 650, not acetaminophen. They ask about DOTS, not generic TB regimens. This model is trained to understand that gap.
QUESTION to anything you want to ask.1# ============================================================
2# MedQuery-India-v1 — One-Cell Inference
3# Works on Google Colab / Kaggle / any notebook with a T4 GPU
4# Just change QUESTION on the last block and run!
5# ============================================================
6
7# --- Step 1: Install dependencies (run once) ---
8import subprocess
9subprocess.run(
10 ["pip", "install", "-q", "transformers", "peft", "bitsandbytes", "accelerate"],
11 check=True
12)
13
14# --- Step 2: Load the model ---
15from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
16from peft import PeftModel
17import torch
18
19BASE_MODEL = "meta-llama/Llama-3.2-1B-Instruct"
20ADAPTER = "kanha98/medquery-india-v1"
21
22bnb_config = BitsAndBytesConfig(
23 load_in_4bit=True,
24 bnb_4bit_quant_type="nf4",
25 bnb_4bit_compute_dtype=torch.float16,
26)
27
28tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
29base = AutoModelForCausalLM.from_pretrained(
30 BASE_MODEL,
31 quantization_config=bnb_config,
32 device_map="auto"
33 )
34model = PeftModel.from_pretrained(base, ADAPTER)
35model.eval()
36print("✅ Model loaded successfully!")
37
38# --- Step 3: Ask your question — change this line ↓ ---
39QUESTION = "What are the warning signs of severe dengue?"
40# -------------------------------------------------------
41
42SYSTEM = (
43 "You are MedQuery-India, a medical AI assistant trained on Indian healthcare context "
44 "including AIIMS/NEET clinical protocols, Indian drug brands, regional diseases, "
45 "Indian procedural guidelines (NTEP, NVBDCP, RSSDI, IAP), and mental health support. "
46 "Answer accurately, safely, and with cultural sensitivity."
47)
48
49prompt = (
50 f"<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n{SYSTEM}<|eot_id|>"
51 f"<|start_header_id|>user<|end_header_id|>\n{QUESTION}<|eot_id|>"
52 f"<|start_header_id|>assistant<|end_header_id|>\n"
53)
54
55inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
56outputs = model.generate(
57 **inputs,
58 max_new_tokens=250,
59 temperature=0.3,
60 do_sample=True,
61 repetition_penalty=1.1,
62 pad_token_id=tokenizer.eos_token_id,
63)
64print(tokenizer.decode(outputs[0], skip_special_tokens=True).split("assistant")[-1].strip())Note: This cell usestransformers+peft+bitsandbytes— no Unsloth required. Works on any free-tier Colab/Kaggle T4 instance (~14.5 GB VRAM).
| Property | Value |
|---|---|
| Base model | meta-llama/Llama-3.2-1B-Instruct |
| Parameters | 1,235,814,400 (1.24B) |
| Fine-tuning technique | QLoRA (4-bit NF4 quantization) |
| LoRA rank | r = 64 |
| LoRA alpha | 128 |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj (7 modules) |
| Trainable parameters | 45,088,768 (5.502% of total) |
| Training hardware | Tesla T4 (Kaggle, 14.5GB VRAM) |
| Final training loss | 1.5468 |
| Training steps | 1,030 |
| Source | Samples | % | Why included |
|---|---|---|---|
| MedMCQA (Indian) | 3,613 | 55.0% | AIIMS/NEET exam questions — directly Indian clinical context |
| ChatDoctor | 1,588 | 24.2% | Real patient-doctor conversations — teaches conversational tone |
| MedQuAD | 802 | 12.2% | NIH structured QA — adds reliable factual grounding |
| PubMedQA | 237 | 3.6% | Expert-annotated research QA — adds clinical reasoning |
| Synthetic Indian (general) | 144 | 2.2% | Indian drug names, regional disease context |
| Synthetic Indian (edge cases) | 135 | 2.1% | Drug safety edge cases specific to India |
| Synthetic Mental Health | 50 | 0.8% | NEET stress, exam pressure, Indian mental health context |
1# Hardware
2GPU: Tesla T4, 14.5GB VRAM, Kaggle
3Framework: Unsloth 2026.6.1 + TRL SFTTrainer
4
5# LoRA
6r = 64
7lora_alpha = 128 # alpha = 2r — standard scaling
8lora_dropout = 0 # dropout off: small dataset, stable training
9target_modules = 7 # attention + MLP layers
10
11# Training
12num_train_epochs = 5
13per_device_train_batch_size = 4
14gradient_accumulation_steps = 8
15effective_batch_size = 32
16warmup_steps = 150
17learning_rate = 1e-4
18lr_scheduler_type = "cosine"
19optim = "adamw_8bit"
20weight_decay = 0.01
21max_seq_length = 5121from unsloth import FastLanguageModel
2
3model, tokenizer = FastLanguageModel.from_pretrained(
4 model_name = "kanha98/medquery-india-v1",
5 max_seq_length = 512,
6 dtype = None,
7 load_in_4bit = True,
8)
9FastLanguageModel.for_inference(model)
10
11SYSTEM_PROMPT = (
12 "You are MedQuery-India, a medical AI assistant trained on Indian "
13 "healthcare context including AIIMS/NEET clinical protocols, Indian "
14 "drug brands, regional diseases, Indian procedural guidelines (NTEP, "
15 "NVBDCP, RSSDI, IAP), and mental health support. Answer accurately, "
16 "safely, and with cultural sensitivity."
17)
18
19question = "What are the warning signs of severe dengue?"
20
21inputs = tokenizer(
22 f"<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n"
23 f"{SYSTEM_PROMPT}<|eot_id|>"
24 f"<|start_header_id|>user<|end_header_id|>\n{question}<|eot_id|>"
25 f"<|start_header_id|>assistant<|end_header_id|>\n",
26 return_tensors="pt"
27).to("cuda")
28
29outputs = model.generate(
30 **inputs,
31 max_new_tokens = 250,
32 temperature = 0.3,
33 do_sample = True,
34 repetition_penalty = 1.1,
35 pad_token_id = tokenizer.eos_token_id
36)
37response = tokenizer.decode(outputs[0], skip_special_tokens=True)
38print(response.split("assistant")[-1].strip())Warning signs of severe dengue require immediate hospitalization. These include: extreme lethargy or inability to talk; persistent vomiting; severe abdominal pain; bleeding from the nose, gums, or mouth; very high fever above 40°C; black spots on the skin (petechiae); swelling in the face, neck, or groin; extremely low blood pressure. If you have any one of these symptoms, call your local hospital immediately.
Combiflam contains ibuprofen (an NSAID) and paracetamol. Taking NSAIDs during dengue is dangerous because they increase the risk of bleeding by inhibiting platelet function — already compromised in dengue. For dengue fever, only paracetamol (like Crocin or Dolo 650) is safe. NSAIDs including Combiflam, Brufen, and Aspirin must be strictly avoided.
DOTS (Directly Observed Treatment Short-course) is India's national TB control program under the National Tuberculosis Elimination Programme (NTEP), launched in 1992. Core components: sputum microscopy for diagnosis, a standardized short-course drug regimen, direct supervision of treatment, case detection at facility and community levels, and free treatment under the PM-JAY scheme. DOTS is implemented by state and district health departments under the Central TB Division, Ministry of Health and Family Welfare.
1@misc{gupta2025medqueryindia,
2 author = {Kanha98},
3 title = {MedQuery-India-v1: QLoRA Fine-Tuning of Llama-3.2-1B for Indian Medical QA},
4 year = {2025},
5 url = {https://huggingface.co/kanha98/medquery-india-v1}
6}