File size: 6,714 Bytes
b7211a9
83ee74f
3324c9a
83ee74f
 
3324c9a
83ee74f
 
3324c9a
83ee74f
 
 
 
 
 
 
3324c9a
83ee74f
 
 
 
 
 
b7211a9
3324c9a
83ee74f
3324c9a
83ee74f
 
 
 
 
3324c9a
83ee74f
 
 
 
 
 
3324c9a
83ee74f
 
 
3324c9a
83ee74f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
---
pretty_name: MedOptm Surgical VQA (polished)
license: apache-2.0
language:
  - en
task_categories:
  - visual-question-answering
  - image-to-text
tags:
  - medical
  - biomedical
  - surgical
  - vqa
  - visual-question-answering
  - multimodal
  - biomedica
size_categories:
  - 100K<n<1M
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/train-*.parquet
---

# MedOptm Surgical VQA (polished)

A biomedical **visual-question-answering (VQA)** dataset: each example is a
medical/surgical figure paired with a natural-language **question** and a short
**answer**. It was used to train
[**MedOptm**](https://github.com/Devpatel1012/MedOptm-VLM), a compact medical
vision-language model (CvT / CLIP-ViT + Llama-3.2-1B).

> **This VQA dataset is derived from the **BIOMEDICA** vision–caption data.**
> The questions and answers were **generated from BIOMEDICA figure captions** —
> the images and their captions come from BIOMEDICA (itself built from PubMed
> Central Open Access), and each `(question, answer)` pair was derived from the
> figure's caption. The original caption is kept in every row (`original_caption`)
> so the derivation stays auditable.

> ⚠️ **Research use only — not for clinical use.** Answers are derived from figure
> captions, not written or reviewed by clinicians, and can be incomplete or
> wrong. Do not use this dataset to make or support medical decisions.

---

## Where the code lives

Everything that loads, cleans, inspects and consumes this dataset is open-source
in the MedOptm repository:

- **GitHub repo:** <https://github.com/Devpatel1012/MedOptm-VLM>
- **Data pipeline code:** [`src/medoptm/data/`](https://github.com/Devpatel1012/MedOptm-VLM/tree/main/src/medoptm/data)
  - [`dataset.py`](https://github.com/Devpatel1012/MedOptm-VLM/blob/main/src/medoptm/data/dataset.py) — loads these parquet files, decodes the images, and builds the train/val/test DataLoaders.
  - [`preprocessing.py`](https://github.com/Devpatel1012/MedOptm-VLM/blob/main/src/medoptm/data/preprocessing.py) — the `light_scrub()` text cleaner that removed demographics/measurements from the answer text.
  - [`sampling.py`](https://github.com/Devpatel1012/MedOptm-VLM/blob/main/src/medoptm/data/sampling.py) — pulls small random samples out for inspection.
- **BIOMEDICA → VQA inspection notebooks:**
  [`01_biomedica_data_inspection.ipynb`](https://github.com/Devpatel1012/MedOptm-VLM/blob/main/notebooks/01_biomedica_data_inspection.ipynb)
  and [`02_biomedica_vqa_inspection.ipynb`](https://github.com/Devpatel1012/MedOptm-VLM/blob/main/notebooks/02_biomedica_vqa_inspection.ipynb)
  show the BIOMEDICA caption data and the derived VQA side by side.

---

## Dataset structure

A single `train` split, stored as parquet shards under `data/`. Each row:

| Column | Type | Description |
|---|---|---|
| `image` | image (bytes) | The biomedical/surgical figure from BIOMEDICA. With 🤗 `datasets` this is cast to a PIL image automatically. |
| `question` | string | A question about the image. ~56 characters on average. |
| `answer` | string | The answer, derived from the figure caption. ~77 characters on average. |
| `original_caption` | string | The BIOMEDICA figure caption the Q&A was derived from. ~219 characters on average. Kept for provenance and for caption-style training. |
| `original_filename` | string | The BIOMEDICA parquet shard this row came from. |
| `original_row_index` | int64 | The row index within that shard (`-1` where unknown). |

The dataset is **not pre-split** — MedOptm splits it at load time (80/10/10
train/val/test, `seed=42`).

### Example

```text
question:         "Where in the spine were pedicle screws placed?"
answer:           "The pedicle screws were placed in the lumbar spine."
original_caption: "The pedicle screws were placed percutaneously (A). The positions of
                   the screws are shown in the X-ray lateral view (B), and the
                   intervertebral ..."
```

---

## Usage

```python
from datasets import load_dataset

ds = load_dataset("devpatel1012/polished-vlm-dataset", split="train")

row = ds[0]
print(row["question"], "->", row["answer"])
row["image"]          # a PIL image
```

Reproduce MedOptm's exact split:

```python
split    = ds.shuffle(seed=42).train_test_split(test_size=0.2)
train    = split["train"]
val_test = split["test"].train_test_split(test_size=0.5)
val, test = val_test["train"], val_test["test"]
```

---

## How it was built

1. **Source.** Figures and their captions from **BIOMEDICA** (derived from
   PubMed Central Open Access).
2. **Q&A generation.** For each figure, a `(question, answer)` pair was generated
   from its BIOMEDICA caption. The caption is retained as `original_caption` so
   each answer can be traced back to its source text.
3. **Light scrubbing.** Answer text was passed through `light_scrub()`
   ([`preprocessing.py`](https://github.com/Devpatel1012/MedOptm-VLM/blob/main/src/medoptm/data/preprocessing.py))
   to remove demographic details and measurements.

---

## Provenance & licensing

This is a **derived** dataset. Its images and captions come from **BIOMEDICA**,
which is built from **PubMed Central Open Access (PMC-OA)**. PMC-OA is a *mixture*
of Creative Commons licences — some articles allow redistribution with
attribution, others carry non-commercial or no-derivatives terms. **A derived
dataset cannot be more permissive than its source.**

Before making this public:

- Read BIOMEDICA's dataset terms and licence, and PMC-OA's reuse terms.
- Set the `license:` field in the metadata block above to match.
- Keep the attribution to BIOMEDICA and PMC-OA intact.

## Limitations

- Answers are **caption-derived**, not clinician-authored or clinically validated.
- Figures come from published literature, so they skew toward notable/illustrative
  cases rather than a representative clinical distribution.
- Multi-panel figures (A/B/C …) are kept whole, so a question may refer to only
  one panel.
- De-identification of the image **pixels** has not been exhaustively verified —
  published figures are normally de-identified, but spot-check before relying on it.

## Citation

Please cite **BIOMEDICA** (the upstream source) and this derived release.

```bibtex
@misc{medoptm_surgical_vqa,
  title  = {MedOptm Surgical VQA (polished)},
  author = {Dev Patel},
  year   = {2026},
  url    = {https://huggingface.co/datasets/devpatel1012/polished-vlm-dataset},
  note   = {Derived from the BIOMEDICA vision--caption dataset (PubMed Central Open Access).}
}
```

## Links

- 🧠 **Model & code:** <https://github.com/Devpatel1012/MedOptm-VLM>
- 🗂️ **Upstream data:** BIOMEDICA