File size: 6,513 Bytes
fbd45c9
9a0d0fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fbd45c9
 
9a0d0fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fbd45c9
9a0d0fd
 
 
 
fbd45c9
9a0d0fd
 
 
013ffd5
9a0d0fd
013ffd5
fbd45c9
9a0d0fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
---
pretty_name: Medical-ROIs-K2.6
license: other
task_categories:
  - visual-question-answering
  - image-to-text
tags:
  - medical
  - radiology
  - pathology
  - roi
  - grounding
  - bounding-box
  - multimodal
  - sft
size_categories:
  - 10K<n<100K
language:
  - en
dataset_info:
  features:
    - name: id
      dtype: string
    - name: source
      dtype: string
    - name: teacher_model
      dtype: string
    - name: teacher_provenance
      dtype: string
    - name: images
      sequence: image
    - name: messages
      list:
        - name: role
          dtype: string
        - name: content
          dtype: string
    - name: messages_mm
      dtype: string
    - name: problem
      dtype: string
    - name: solution
      dtype: string
    - name: prompt
      dtype: string
    - name: response
      dtype: string
    - name: seeing_regions
      list:
        - name: title
          dtype: string
        - name: bbox
          sequence: int64
    - name: seeing_json
      dtype: string
    - name: reasoning
      dtype: string
    - name: n_images
      dtype: int64
    - name: index
      dtype: int64
  splits:
    - name: train
      num_examples: 25134
    - name: validation
      num_examples: 2000
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/train-*
      - split: validation
        path: data/validation-*
---

# Medical-ROIs-K2.6

Medical visual grounding SFT data: for each clinical VQA sample, a teacher model proposes **answer-supporting ROIs** (regions of interest) as 2D bounding boxes.

Teacher: **`moonshotai/Kimi-K2.6`**.  
Upstream images & QA: **`MBZUAI/medix-rl-data`**.

## How the data is generated

```
MBZUAI/medix-rl-data (train)

        │  problem / solution / image / source / id

  Teacher: moonshotai/Kimi-K2.6
  (vision + text; given question + gold answer)

        │  ROI XML: <region><title>…</title><bbox>[x1,y1,x2,y2]</bbox></region>

  JSONL (sft.jsonl)  →  stratified split
        │                 ├── sft_train.jsonl  (25,134)
        │                 └── sft_val.jsonl    (2,000)

  prepare_hf: join JSONL text with medix-rl-data images


  Hugging Face DatasetDict  (this repo)
```

### 1. Source VQA pool

Rows come from [`MBZUAI/medix-rl-data`](https://huggingface.co/datasets/MBZUAI/medix-rl-data) (`train`, 51,335 examples) with four upstream sources:

| source | role |
|--------|------|
| `RadGenome/PMC-VQA` | PubMed Central figure VQA |
| `flaviagiammarino/path-vqa` | Pathology VQA |
| `BoKelvin/SLAKE` | Radiology VQA (SLAKE) |
| `flaviagiammarino/vqa-rad` | VQA-RAD |

Each row provides `id`, `image`, `problem` (question), `solution` (gold answer), and `source`.

### 2. Teacher ROI annotation

A multimodal teacher (`moonshotai/Kimi-K2.6`) is prompted with the image, clinical question, and gold answer, and asked to box the visual evidence that supports the answer.

- **Output format** (one or more blocks):

```text
<region><title>caption</title><bbox>[x1,y1,x2,y2]</bbox></region>
```

- **BBox convention:** integers in **[0, 1000]**, top-left origin; require `x1 < x2`, `y1 < y2`.
- Successful annotations are written to JSONL (`sft.jsonl`); failures are logged for repair/retry.
- This release keeps the successfully annotated subset (**27,134** rows, ≈53% of the upstream train pool).

### 3. Train / validation split

From `sft.jsonl`, a **source-stratified** random split (`seed=42`) produces:

| split | file | count |
|-------|------|------:|
| train | `sft_train.jsonl` | 25,134 |
| validation | `sft_val.jsonl` | 2,000 |

### 4. Hugging Face packaging

`medix_seeing_sft.prepare_hf` joins each JSONL row with the matching image(s) from `MBZUAI/medix-rl-data` by `id`, and materializes a `DatasetDict` with multimodal chat fields suitable for SFT loaders.

## Splits in this repo

| split | #examples |
|-------|----------:|
| `train` | 25,134 |
| `validation` | 2,000 |

### Source mix (approx.)

| source | train | validation |
|--------|------:|-----------:|
| RadGenome/PMC-VQA | 12,315 | 980 |
| flaviagiammarino/path-vqa | 9,535 | 759 |
| BoKelvin/SLAKE | 2,391 | 190 |
| flaviagiammarino/vqa-rad | 893 | 71 |

## Schema

| field | description |
|-------|-------------|
| `id` | Sample id (matches `medix-rl-data`) |
| `source` | Upstream VQA dataset name |
| `images` | Image list (`datasets.Image`) |
| `messages` | Chat turns with string content (`<image>` placeholders) |
| `messages_mm` | JSON string of multimodal content-list messages |
| `problem` / `solution` | Clinical question and gold answer |
| `prompt` / `response` | User prompt and assistant ROI XML |
| `seeing_regions` | Structured `{title, bbox}` list |
| `seeing_json` | JSON serialization of regions |
| `reasoning` | Teacher reasoning text (when available) |
| `teacher_model` | `moonshotai/Kimi-K2.6` |
| `teacher_provenance` | `distilled_from:moonshotai/Kimi-K2.6` |
| `n_images` | Number of images |
| `index` | Annotation-run index |

### Example assistant target

```text
<region><title>Right kidney</title><bbox>[130,380,470,720]</bbox></region>
<region><title>Left kidney</title><bbox>[570,420,840,750]</bbox></region>
```

## Load

```python
from datasets import load_dataset

ds = load_dataset("erow/Medical-ROIs-K2.6")
print(ds["train"][0]["problem"])
print(ds["train"][0]["response"])
ds["train"][0]["images"][0]  # PIL.Image
```

Or from a local `save_to_disk` folder:

```python
from datasets import load_from_disk
ds = load_from_disk("/path/to/hf_seeing_sft")
```

## Intended use

Supervised fine-tuning / distillation of medical VLMs for **visual grounding**: predicting ROIs that evidence the answer to a clinical question (complementary to answer-only VQA).

## Limitations

- ROIs are **teacher-generated**, not human-verified for every sample; some boxes may be loose, panel-misaligned, or weakly linked to the QA.
- Coverage is a subset of `medix-rl-data` (annotation failures / rate limits excluded).
- Not a clinical decision-support product; for research use only.

## Citation / provenance

- Upstream pool: [MBZUAI/medix-rl-data](https://huggingface.co/datasets/MBZUAI/medix-rl-data) and its constituent VQA datasets (PMC-VQA, PathVQA, SLAKE, VQA-RAD).
- Teacher: [Moonshot AI Kimi K2.6](https://huggingface.co/moonshotai/Kimi-K2.6) (via OpenAI-compatible inference).
- Pipeline: MediX seeing-SFT (`medix_seeing_sft` generate → split → `prepare_hf`).