MedSLM-SFT -- Instruction-Tuned Medical Language Model
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
MedSLM-SFT is a ~330M-parameter medical language model fine-tuned for instruction following and question answering. It was created by applying Supervised Fine-Tuning (SFT) with QLoRA (4-bit quantized LoRA) to the pre-trained base model Saminx22/MedSLM, then merging the LoRA adapters back into the base weights at full fp16 precision.
This repository contains the merged model. It can be loaded directly with AutoModelForCausalLM from the Hugging Face transformers library -- no PEFT dependency is required at inference time.
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?"))
Recommended Generation Parameters
Parameter
Value
Notes
temperature
0.7
Controls randomness; lower values produce more deterministic output
top_p
0.9
Nucleus sampling threshold
top_k
50
Limits sampling to top-k tokens
repetition_penalty
1.1
Reduces repetitive text
max_new_tokens
300
Maximum response length
Repository Contents
File
Description
config.json
Model architecture configuration
model.safetensors
Model weights in safetensors format (~1.32 GB)
tokenizer.json
Tokenizer vocabulary and merges
tokenizer_config.json
Tokenizer configuration
Limitations and Risks
Research only -- not validated for clinical use or patient care.
Small model size (~330M parameters); more prone to hallucinations and factual errors than larger models.
No RLHF, DPO, or other safety alignment has been applied.
Trained for single-turn question answering only; not designed for multi-turn dialogue.
Context length limited to 1,024 tokens.
Training data is English-only; performance on other languages is not expected.
Citation
bibtex
1@misc{medslm-sft-2025,
2 title = {MedSLM-SFT: Instruction-Tuned Medical Small Language Model},
3 author = {Saminx22},
4 year = {2025},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/Saminx22/MedSLM-SFT}
7}