MedSLM-SFT-LoRA -- LoRA Adapters for Medical Instruction Tuning
Research Only -- Not for Clinical Use
This model is intended for research and educational purposes only.
It must not be used for medical diagnosis, treatment recommendations, or any clinical decision-making.
Overview
This repository contains the LoRA adapter weights (~17.8 MB) produced by supervised fine-tuning (SFT) of the Saminx22/MedSLM base model on medical question-answering data. The adapters can be loaded on top of the base model using the PEFT library.
If you prefer a ready-to-use model that does not require PEFT at inference time, see the merged version: Saminx22/MedSLM-SFT.
Splits: 46,166 train / 2,565 validation / 2,565 test
Sources: WikiDoc, medical Q&A corpora
Average length: ~180 tokens per example
Prompt Template
The model was trained with the following instruction template. You must use this exact format at inference time for best results:
### System:
You are a medical AI assistant. Provide accurate, evidence-based answers to medical questions.
### User:
{question}
### Assistant:
{answer}
1SYSTEM_PROMPT =(2"You are a medical AI assistant. "3"Provide accurate, evidence-based answers to medical questions."4)56defask(question:str, max_new_tokens:int=300)->str:7 prompt =(8f"### System:\n{SYSTEM_PROMPT}\n\n"9f"### User:\n{question}\n\n"10f"### Assistant:\n"11)12 inputs = tokenizer(prompt, return_tensors="pt").to(model.device)1314with torch.inference_mode():15 output_ids = model.generate(16**inputs,17 max_new_tokens=max_new_tokens,18 do_sample=True,19 temperature=0.7,20 top_p=0.9,21 top_k=50,22 repetition_penalty=1.1,23 pad_token_id=tokenizer.eos_token_id,24)2526 response = output_ids[0][inputs["input_ids"].shape[1]:]27return tokenizer.decode(response, skip_special_tokens=True).strip()2829print(ask("What are the warning signs of a stroke?"))
Merging Adapters into the Base Model
If you want a standalone model without the PEFT dependency at inference time, you can merge the adapters: