Skip to main content

Benchmark toolkit for DrVD

Project description

DrVD-Bench: Do Vision-Language Models Reason Like Human Doctors in Medical Image Diagnosis?

paperkagglehuggingfacegithubjupyter notebook example

This repository is the official implementation of the paper: DrVD-Bench: Do Vision-Language Models Reason Like Human Doctors in Medical Image Diagnosis?

Introduction

Vision–language models (VLMs) exhibit strong zero-shot generalization on natural images and show early promise in interpretable medical image analysis. However, existing benchmarks do not systematically evaluate whether these models truly reason like human clinicians or merely imitate superficial patterns.
To address this gap, we propose DrVD-Bench, the first multimodal benchmark for clinical visual reasoning. DrVD-Bench consists of three modules: Visual Evidence Comprehension, Reasoning Trajectory Assessment, and Report Generation Evaluation, comprising 7 789 image–question pairs.
Our benchmark covers 20 task types, 17 diagnostic categories, and five imaging modalities—CT, MRI, ultrasound, X-ray, and pathology. DrVD-Bench mirrors the clinical workflow from modality recognition to lesion identification and diagnosis.
We benchmark 19 VLMs (general-purpose & medical-specific, open-source & proprietary) and observe that performance drops sharply as reasoning complexity increases. While some models begin to exhibit traces of human-like reasoning, they often rely on shortcut correlations rather than grounded visual understanding. DrVD-Bench therefore provides a rigorous framework for developing clinically trustworthy VLMs.

DrVD-Bench Usage Instructions

0. Installation

pip install drvd-bench

1. Function get_drvd_data

Functionality

Reads JSONL, generates the final prompt, and returns an iterator of (img_path, prompt, origin_data).

Note

This code only returns an iterator for retrieving data and does not include model inference.

Parameters

  • jsonl_path (str | Path): Path to the dataset JSONL file
  • image_root (str | Path): Root directory of the dataset
  • data_type ({“single”, “joint”}): Question type, default “single”. Use “joint” only for joint_qa.jsonl; all other JSONL files should use “single”
  • verbose (bool): Whether to show a progress bar; default is True

Returns

Iterator[(img_path:str, prompt:str, record:dict)]

Example

from drvd_bench import get_drvd_data
for img, prompt, original_data in get_drvd_data(
    "test_drvd_pypi/data/visual_evidence_qa.jsonl",
    "test_drvd_pypi/data",
    data_type="single"
):
    print(img, prompt[:80] + "…")

2. Function map_result

Functionality

Calls the DeepSeek Chat API to map open-ended responses to options and writes back to JSONL.

Note

Use only when the model instruction-following capability is insufficient and for non-report generation tasks. Not needed if the model instruction-following is strong.

Parameters

  • api_key (str): DeepSeek API Key; refer to the DeepSeek official website for details
  • input_path (str | Path): Path to the original prediction JSONL file
  • output_path (str | Path): Path to save the mapped JSONL file
  • base_url (str): Private deployment URL; typically does not need modification
  • show_preview (int): Preview the first N results; default is 5

Example

from drvd_bench import map_result
map_result(
    api_key="sk-…",
    input_path="pred.jsonl",
    output_path="mapped.jsonl"
)

3. Function compute_choice_metric

Functionality

Calculates accuracy for multiple-choice questions.

Note

Your JSONL file must contain an answer key for the original data’s answer. The model’s result must be stored in the key model_response and should be a single option, such as A, B, C, D, etc.

Parameters

  • jsonl_path (str | Path): Path to the prediction result JSONL file
  • mode ({“single”, “joint”}): Question type, default “single”. Use “joint” only for joint_qa.jsonl; all other multiple-choice JSONL result files should use “single”

Example

from drvd_bench import compute_choice_metric
compute_choice_metric(
    "visual_evidence_qa_pred.jsonl",
    mode="single"
)

4. Function compute_report_generation_metric

Functionality

Computes BLEU and BERTScore F1 for report generation tasks.

Note

Your JSONL file must contain an answer key for the original data’s answer. The model’s result must be stored in the key model_response.

Parameters

  • api_key (str): DeepSeek API Key
  • json_path (str | Path): Path to the JSONL result file containing answer / model_response fields for report generation
  • base_url (str): Private deployment URL; typically does not need modification

Example

from drvd_bench import compute_report_generation_metric
compute_report_generation_metric(
    api_key="sk-…",
    json_path="report_generation_preds.jsonl"
)

Contact

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drvd_bench-0.2.2.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drvd_bench-0.2.2-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file drvd_bench-0.2.2.tar.gz.

File metadata

  • Download URL: drvd_bench-0.2.2.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for drvd_bench-0.2.2.tar.gz
Algorithm Hash digest
SHA256 6a9c64934c18895270b7f86d18e40d9ac9607da828621a57f079f3acf0031e83
MD5 61ac640909a10fe3d738c9160312e99b
BLAKE2b-256 b325692b90e69141620293bbd235cb6ff1699210083492accf5b548f1b80925f

See more details on using hashes here.

File details

Details for the file drvd_bench-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: drvd_bench-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for drvd_bench-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6f338bb0bec9192bf3e166e3d57979ed4fdebc296683f167754d1f31f5c6a1aa
MD5 0e5306091ea25f03a9e0fe5a1b76b2cd
BLAKE2b-256 2f5d5c15fbf3a6e713950d63e980771a47d5aafe4bdea0dac7571e532ac45fee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page