Downloads · 30 days
9
17% of all-time downloads
kanha98/medquery-india-v1
medquery-india-v1 is a text generation model from kanha98. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as mit.
A QLoRA fine-tuned version of Llama-3.2-1B-Instruct for Indian medical question answering — covering AIIMS/NEET clinical protocols, Indian drug brands (Crocin, Dolo, Combiflam), regional diseases (dengue, typhoid, TB/…
Downloads · 30 days
9
17% of all-time downloads
All-time downloads
54
Public
Repo size
834 MB
Likes
1
Public
Click a slice to open those files.
.safetensors722 MB · 68%
From the Hugging Face model README
A QLoRA fine-tuned version of Llama-3.2-1B-Instruct for Indian medical question answering — covering AIIMS/NEET clinical protocols, Indian drug brands (Crocin, Dolo, Combiflam), regional diseases (dengue, typhoid, TB/DOTS, chikungunya), national health programs (NTEP, NVBDCP, RSSDI, IAP), and mental health support with cultural sensitivity.
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.
Open in Google Colab (Runtime → Change runtime type → T4 GPU) or any Kaggle notebook and paste this single cell. Change QUESTION to anything you want to ask.
# ============================================================
# MedQuery-India-v1 — One-Cell Inference
# Works on Google Colab / Kaggle / any notebook with a T4 GPU
# Just change QUESTION on the last block and run!
# ============================================================
# --- Step 1: Install dependencies (run once) ---
import subprocess
subprocess.run(
["pip", "install", "-q", "transformers", "peft", "bitsandbytes", "accelerate"],
check=True
)
# --- Step 2: Load the model ---
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
import torch
BASE_MODEL = "meta-llama/Llama-3.2-1B-Instruct"
ADAPTER = "kanha98/medquery-india-v1"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
)
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
base = AutoModelForCausalLM.from_pretrained(
BASE_MODEL,
quantization_config=bnb_config,
device_map="auto"
)
model = PeftModel.from_pretrained(base, ADAPTER)
model.eval()
print("✅ Model loaded successfully!")
# --- Step 3: Ask your question — change this line ↓ ---
QUESTION = "What are the warning signs of severe dengue?"
# -------------------------------------------------------
SYSTEM = (
"You are MedQuery-India, a medical AI assistant trained on Indian healthcare context "
"including AIIMS/NEET clinical protocols, Indian drug brands, regional diseases, "
"Indian procedural guidelines (NTEP, NVBDCP, RSSDI, IAP), and mental health support. "
"Answer accurately, safely, and with cultural sensitivity."
)
prompt = (
f"<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n{SYSTEM}<|eot_id|>"
f"<|start_header_id|>user<|end_header_id|>\n{QUESTION}<|eot_id|>"
f"<|start_header_id|>assistant<|end_header_id|>\n"
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=250,
temperature=0.3,
do_sample=True,
repetition_penalty=1.1,
pad_token_id=tokenizer.eos_token_id,
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True).split("assistant")[-1].strip())
Note: This cell uses
transformers+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 |
Three concrete reasons, not vibes:
Tokenizer efficiency on medical vocabulary. Llama-3's 128k BPE vocabulary encodes medical terms like "acetaminophen", "thrombocytopenia", and "leptospirosis" as 1–2 tokens. GPT-2's 50k vocabulary splits the same terms into 4–6 tokens. Fewer tokens per medical term means the model sees more semantic context within the 512-token window — directly relevant for QA where both the question and answer need to fit.
Grouped Query Attention (GQA). Llama-3.2 uses GQA with an 8:1 ratio — 8 query heads share 1 KV head. This reduces KV cache memory significantly compared to standard multi-head attention, enabling longer context at the same VRAM cost.
The 1B sweet spot. Larger than SmolLM2-360M (better reasoning, longer coherent answers), smaller than 3B+ (fits T4 with 4-bit quant, trains in ~4 hours). Every architectural decision in this model is explainable — important for research paper writing and for anyone who wants to reproduce this.
QLoRA (Dettmers et al., 2023) freezes the base model in 4-bit NF4 quantization and trains only low-rank adapter matrices. This model trains 45M parameters out of 1.28B total — 3.52%.
Why r=64 and not r=16? The standard starting point is r=16. r=64 was chosen here because the task requires cross-domain adaptation — the model needs to simultaneously handle clinical MCQ reasoning (MedMCQA), conversational patient QA (ChatDoctor), structured NIH-style QA (MedQuAD), and Indian-specific synthetic cases. Higher rank gives the adapter more capacity to represent these different response styles without catastrophic interference.
Most QLoRA implementations target only attention layers (q, k, v, o — 4 modules). This training also targets the MLP layers (gate_proj, up_proj, down_proj) because medical factual recall is stored in the FFN layers, not just attention. Targeting all 7 modules increases trainable parameters from ~11M to ~45M with no inference overhead.
NF4 (Normal Float 4) is not the same as INT4. NF4 uses a non-uniform quantization grid that matches the normal distribution of neural network weights — meaning it preserves the most information at the center of the weight distribution where most values cluster. INT4 uses a uniform grid and loses more information at those central values. For a medical QA model where precise factual recall matters, NF4 is the correct quantization choice.
Total training samples: 6,569 | Val: 780 | Test: 780
| 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 |
Why MedMCQA at 55%? It is the only large-scale dataset sourced directly from AIIMS and NEET PG entrance exams — real Indian clinical questions with expert explanations. No other public dataset captures this.
Why synthetic data? Public medical datasets have near-zero coverage of Indian drug brands, DOTS protocol specifics, or mental health in the Indian exam context. 329 hand-crafted synthetic samples fill this gap directly.
# Hardware
GPU: Tesla T4, 14.5GB VRAM, Kaggle
Framework: Unsloth 2026.6.1 + TRL SFTTrainer
# LoRA
r = 64
lora_alpha = 128 # alpha = 2r — standard scaling
lora_dropout = 0 # dropout off: small dataset, stable training
target_modules = 7 # attention + MLP layers
# Training
num_train_epochs = 5
per_device_train_batch_size = 4
gradient_accumulation_steps = 8
effective_batch_size = 32
warmup_steps = 150
learning_rate = 1e-4
lr_scheduler_type = "cosine"
optim = "adamw_8bit"
weight_decay = 0.01
max_seq_length = 512
If you have Unsloth installed, you can use the faster inference path:
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "kanha98/medquery-india-v1",
max_seq_length = 512,
dtype = None,
load_in_4bit = True,
)
FastLanguageModel.for_inference(model)
SYSTEM_PROMPT = (
"You are MedQuery-India, a medical AI assistant trained on Indian "
"healthcare context including AIIMS/NEET clinical protocols, Indian "
"drug brands, regional diseases, Indian procedural guidelines (NTEP, "
"NVBDCP, RSSDI, IAP), and mental health support. Answer accurately, "
"safely, and with cultural sensitivity."
)
question = "What are the warning signs of severe dengue?"
inputs = tokenizer(
f"<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n"
f"{SYSTEM_PROMPT}<|eot_id|>"
f"<|start_header_id|>user<|end_header_id|>\n{question}<|eot_id|>"
f"<|start_header_id|>assistant<|end_header_id|>\n",
return_tensors="pt"
).to("cuda")
outputs = model.generate(
**inputs,
max_new_tokens = 250,
temperature = 0.3,
do_sample = True,
repetition_penalty = 1.1,
pad_token_id = tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response.split("assistant")[-1].strip())
Q: What are the warning signs of severe dengue?
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.
Q: Patient took Combiflam for dengue fever. Is this dangerous?
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.
Q: What is the DOTS program for tuberculosis in India?
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.
If you use this model in research, please cite:
@misc{gupta2025medqueryindia,
author = {Kanha98},
title = {MedQuery-India-v1: QLoRA Fine-Tuning of Llama-3.2-1B for Indian Medical QA},
year = {2025},
url = {https://huggingface.co/kanha98/medquery-india-v1}
}
Kanha98
Built with Unsloth · Base model: meta-llama/Llama-3.2-1B-Instruct