Mohamed AjabSoftware / security / dataLet’s talk
Back to the project mapVQ / 23 / CASE STUDY
Completed pilot · September 20265 min read

Medical VQA Calibration

Does a medical-image AI know when its answer is likely to be wrong?

This pilot asks a small vision-language model yes/no questions about medical images. It checks whether the model’s confidence scores are useful and whether its answers actually depend on the image.

Read the case study
01 / CONTEXT

What this project is about

This pilot asks whether confidence scores can identify wrong answers to questions about medical images. Three properties need separate checks: how often an answer is correct, whether its confidence matches observed correctness, and whether confidence identifies the cases most likely to fail. Improving the second property, called calibration, does not necessarily improve the third.

The experiment uses Salesforce's general-domain BLIP VQA base model on yes/no questions from VQA-RAD. It reserves 100 training-split questions to adjust confidence scores and 150 held-out questions for testing. The project supplies the inference, image-alteration and evaluation code around existing model and dataset resources. It does not train a new medical foundation model.

02 / IMPLEMENTATION

How it works

The workflow, at a glance
  1. Medical image + question
  2. Answer + confidence score
  3. Calibrate and test image dependence

Make sampling and scoring reproducible

The pipeline keeps questions whose normalised answer begins with yes or no and selects calibration and test samples with seed 42. The fixed BLIP model runs on CPU without additional training. Its generated answers are checked against the reference yes/no answer. Saved metadata identifies the model, dataset, device, seed and sample sizes.

Adjust confidence on separate questions

Raw confidence combines the probabilities assigned to the generated answer's tokens, or text pieces, using their geometric mean. A logistic mapping then learns how these scores relate to correctness on the separate calibration sample; this adjustment is called Platt calibration. The same fitted mapping is applied to untouched test questions. Answers and scores are retained so the evaluation can be inspected.

Test whether visual evidence affects answers

Each test question is repeated with a strongly blurred image and a blank image. An image-aware scoring rule rewards stability under blur and penalises agreement with the blank-image answer. Brier score and expected calibration error measure probability error; correctness AUROC measures whether confidence ranks correct answers above wrong ones. The risk–coverage curve shows remaining error as lower-confidence answers are withheld; its area, AURC, summarises that trade-off.

03 / REASONING

The important design choices

Use an accessible general-domain model

Evaluate a fixed BLIP model rather than train a specialised radiology model.

The trade-offCPU execution makes the experiment practical to reproduce. The result cannot represent medical vision-language models as a class.

Keep the initial scoring rule unambiguous

Restrict the pilot to yes/no answers scored with a fixed rule.

The trade-offThis makes automatic evaluation easier to audit, but excludes clinically meaningful free-text responses and limits what accuracy describes.

Check whether image dependence helps confidence

Treat answer changes under image removal as a possible signal of reliability, then test it against correctness.

The trade-offMatching the blank-image answer can reflect patterns in the question rather than visual evidence. It does not by itself show that the original answer was wrong.

04 / WALKTHROUGH

Better probabilities need not identify the wrong cases

ILLUSTRATIVE EXAMPLE

Imagine answers with confidence scores that are too high but put correct and incorrect cases in much the same order.

  1. Learn a confidence adjustment on separate calibration questions.
  2. Check whether the adjusted probabilities better match observed correctness on the test questions.
  3. Separately check whether the lowest-confidence answers now contain a larger share of the errors.

What this showsThe first check can improve while the second stays weak. Both are necessary before treating confidence as a useful reason to accept or withhold an answer.

Illustrative example, not an additional measured result.

05 / EVIDENCE

How it was tested—and what it shows

The checks

All three confidence methods are compared on the same 150 test questions. Saved predictions include answers, image-alteration comparisons and confidence scores; metadata records the separate 100-question calibration sample. Plots show whether predicted confidence matches observed correctness and whether declining lower-confidence answers actually reduces the remaining error.

The pilot uses one model, one sampling seed and a small binary-answer subset. It does not provide uncertainty estimates across repeated runs or validation on an external set of independent patients. The saved outputs support a reproducible comparison within this setup, not clinical safety, diagnostic competence or readiness to decide which patients need further review.

Confidence methods on the same 150 questions
Confidence methodBrier ↓ECE ↓Correctness AUROC ↑
Raw token probability0.2940.2050.497
Platt calibrated0.2550.0910.503
Image-aware heuristic0.2970.1880.435
Same fixed BLIP model and 150-question held-out binary sample; all methods have 54.7% answer accuracy. Brier and ECE measure probability error; AUROC measures error discrimination. One pilot split without uncertainty intervals does not establish clinical validity.

What to take from the results

Original-image accuracy was 54.7%. Platt calibration reduced expected calibration error from 0.205 to 0.091 and Brier score from 0.294 to 0.255; lower is better for both. Yet correctness AUROC stayed near random ranking, moving from 0.497 to 0.503. Confidence better matched average correctness without becoming a dependable way to identify individual mistakes.

The image-aware rule performed worse, with correctness AUROC 0.435 and AURC 0.502, versus 0.457 AURC after Platt calibration; lower AURC is better. Blank-image accuracy was 56.0%, and original and blank answers agreed in 48.7% of cases. This raises concerns about reliance on visual evidence in this setup. It does not establish that images are unnecessary or that these differences are statistically significant.

06 / BOUNDARIES

What to keep in mind

  • This is a small pilot using a compact general-purpose model, not a clinically validated medical system.
  • Improved calibration does not establish safe triage or dependable detection of individual mistakes.
  • The project includes a local draft write-up, not a peer-reviewed publication. Source data and manuscript files are not publicly downloaded from this site.

Where the work could go next

Possible next steps—not features or experiments already completed.

  1. Repeat the full eligible yes/no test set with a medical-domain model and sampling specified in advance, adding uncertainty intervals.
  2. Test a larger external medical image-question dataset and compare image removal with stronger measures of visual evidence use or answer consistency.
07 / REFERENCE

Technical notes & source

Built with

Python · BLIP · VQA-RAD · probability calibration

Terms used in this project

VQA
Visual question answering: answering a question about an image.
Calibration error
A measure of how closely confidence estimates match observed correctness; lower is better.
AUROC
A ranking measure; about 0.5 means little ability to separate correct answers from wrong ones.
Request project access

Local research · available on request. This page shares a summary, not private source code or raw research files.