Downloads · 30 days
14
16% of all-time downloads
ShahzebKhoso/phi2-pubmedqa-lora
phi2-pubmedqa-lora is a text generation model from ShahzebKhoso. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
This model is a LoRA-adapted version of microsoft/phi-2, fine-tuned using Unsloth on the pqalabeled subset of the PubMedQA dataset.
Downloads · 30 days
14
16% of all-time downloads
All-time downloads
90
Public
Repo size
21 MB
Likes
0
Public
Click a slice to open those files.
.safetensors21 MB · 81%
From the Hugging Face model README
This model is a LoRA-adapted version of microsoft/phi-2, fine-tuned using Unsloth on the pqa_labeled subset of the PubMedQA dataset.
Given a biomedical research question and an abstract, the model answers:
This is framed as a 3-class classification problem for biomedical question answering.
This work demonstrates the feasibility of using a general-purpose text generation model (Phi-2), augmented with lightweight LoRA adapters, to perform medical question classification on the PubMedQA dataset.
Instead of using specialized biomedical models or classification heads, we reframe the task as text generation — prompting the model to generate "yes", "no", or "maybe" answers. Despite its small size and lack of biomedical pretraining, the Phi-2 model, fine-tuned via LoRA on just ~1,000 examples, achieves a competitive 62.2% test accuracy.
This approach bridges the gap between generative language modeling and medical classification, offering a reproducible, efficient, and surprisingly strong baseline — particularly valuable for low-resource, edge, or clinical applications.
Key Highlights:
Validation set was used for best checkpoint selection. Results below are on the unseen test set.
Final model performance:
| Label | Precision | Recall | F1 Score | Support |
|---|---|---|---|---|
| yes | 0.70 | 0.95 | 0.81 | 59 |
| no | 1.00 | 0.07 | 0.13 | 29 |
| maybe | 0.19 | 0.30 | 0.23 | 10 |
✅ Notably strong at "yes" predictions. Future work will target improvements on "no" and "maybe".
microsoft/phi-2r: 16alpha: 16target_modules: ["q_proj", "v_proj"]With Transformers
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
# Load base + LoRA adapter
model = AutoModelForCausalLM.from_pretrained("microsoft/phi-2")
model = PeftModel.from_pretrained(model, "ShahzebKhoso/phi2-pubmedqa-lora")
tokenizer = AutoTokenizer.from_pretrained("ShahzebKhoso/phi2-pubmedqa-lora")
With Unsloth
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "ShahzebKhoso/phi2-pubmedqa-lora",
max_seq_length = 2048,
dtype = None,
load_in_4bit = True,
)
FastLanguageModel.for_inference(model)
@misc{shahzebkhoso2025phi2pubmedqa,
title={Fine-tuning Phi-2 on PubMedQA with LoRA},
author={Shahzeb Khoso},
year={2025},
howpublished={\url{https://huggingface.co/shahzebkhoso/phi2-pubmedqa-lora}},
}