← All work

MedProQA

Fine-tuned Phi-3 for medical question answering

Role
Solo Developer
Timeline
Jul 2025
Context
Personal project

The outcome

  1. 82.6% accuracy on MedMCQA.
  2. Hallucination rate down 28% on out-of-distribution queries.
  3. 38% less GPU memory and 24% lower training cost vs full fine-tuning.

The challenge

A fine-tuned LLM for medical question answering, built to learn the full training loop end to end — data curation, quantised fine-tuning, and honest evaluation including out-of-distribution behaviour.

Medical QA punishes hallucination more than most domains, and full fine-tuning of a capable base model was out of reach on available hardware.

The system

250K+ QA pairs curated from MedQA, MedMCQA and PubMedQA through schema normalisation and dedup pipelines, then used to fine-tune Phi-3 with QLoRA 4-bit quantisation. Evaluation covered both in-distribution accuracy and out-of-distribution hallucination rate.

4-bit basetrainablesplittrainevery 500 stepsOOD queriesPhi-3Mini Instruct · frozenMedQA · MedMCQA · PubMedQAthree source schemasbitsandbytes NF44-bit · double quantSchema Normalisationone MCQ formatLoRA adaptersQLoRA · r=16Dedupcross-corpus overlap250K+ QA Pairstraining mixHeld-out querieskept out of trainingHF Trainerfp16 · grad checkpointingLoRA checkpointadapter weights onlyIn-distribution evalMedMCQA accuracyOut-of-distribution evalhallucination rate
MedProQA — three corpora into one training mix, a 4-bit base with LoRA adapters, two kinds of evaluation

The hard parts

  1. Training within a memory budget

    QLoRA 4-bit quantisation cut GPU memory by 38% and training cost by 24% against full fine-tuning — the difference between the project being possible and not.

  2. Curating three inconsistent corpora

    MedQA, MedMCQA and PubMedQA don't share a schema. Normalisation and dedup pipelines were needed before any of it could be trained on.

What I took from it

  • Deduplicate before you benchmark. MedQA, MedMCQA and PubMedQA overlap, and any leakage between the training mix and the eval set would have inflated the 82.6% into a number that meant nothing.
  • One accuracy figure on a benchmark that resembles your training data doesn't describe the model. Tracking hallucination rate on out-of-distribution queries as a separate metric is what showed whether anything had actually generalised.
  • Quantisation decided whether the project existed. 38% less memory and 24% lower cost wasn't an optimisation pass — it was the difference between training this and not.

Stack

Model
Phi-3, QLoRA, PyTorch
Data
MedQA, MedMCQA, PubMedQA, Dedup pipelines

Timeline

  1. Jul 2025

    Built and evaluated.

Download resume