File size: 7,849 Bytes
af770e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bf8c948
af770e8
 
 
0b78735
af770e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b78735
 
af770e8
 
0b78735
af770e8
 
 
 
 
 
 
 
 
 
 
0b78735
af770e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bf8c948
af770e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: cc-by-nc-sa-4.0
language:
  - en
base_model: Qwen/Qwen3-VL-2B-Instruct
base_model_relation: adapter
pipeline_tag: image-text-to-text
tags:
  - medical-imaging
  - radiology
  - computed-tomography
  - 3d
  - report-generation
  - nnfoundation
  - arxiv:2609.26924
  - arxiv:2608.08713
---

## nnFoundationViT-ReportGen-Merlin
<sub>Copyright German Cancer Research Center (DKFZ) and contributors. Please make sure that your usage of these models is in compliance with their license.</sub>

[![nnFoundation paper](https://img.shields.io/badge/nnFoundation-arXiv-b31b1b?logo=arxiv)](https://arxiv.org/abs/2609.26924)
[![RMR paper](https://img.shields.io/badge/RMR-arXiv-b31b1b?logo=arxiv)](https://arxiv.org/abs/2608.08713)
[![Code](https://img.shields.io/badge/GitHub-code-181717?logo=github)](https://github.com/MIC-DKFZ/3d_report_generation)

`nnFoundationViT-ReportGen-Merlin` generates radiology reports (findings and impression) for
**abdominal CT** volumes. Frozen [nnFoundationViT](https://huggingface.co/MIC-DKFZ/nnFoundationViT)
features are passed through a trainable adapter to
[Qwen3-VL-2B-Instruct](https://huggingface.co/Qwen/Qwen3-VL-2B-Instruct), adapted with LoRA, and
trained on the [Merlin dataset](https://stanford.redivis.com/datasets/exfv-e8h3kvfhs). The training
recipe builds on the findings of [Resolution Meets Reduction (RMR)](https://arxiv.org/abs/2608.08713)
and improves on the report-generation models of the
[nnFoundation paper](https://arxiv.org/abs/2609.26924); we recommend it for generating reports on
new abdominal CT.

For chest CT, use [nnFoundationViT-ReportGen-CT-RATE](https://huggingface.co/MIC-DKFZ/nnFoundationViT-ReportGen-CT-RATE).

## Model

| Component | Details | Trained |
|---|---|---|
| Vision encoder | [nnFoundationViT](https://huggingface.co/MIC-DKFZ/nnFoundationViT), 192³ input, 24³ = 13,824 patch tokens | Frozen |
| Adapter | Normalization and MLP applied to each patch token, no token reduction | Fully |
| Language model | [Qwen3-VL-2B-Instruct](https://huggingface.co/Qwen/Qwen3-VL-2B-Instruct) | LoRA (r 32, α 64) on attention, MLP, and `lm_head` |

This repository holds only the trained weights (adapter and LoRA, 46M parameters); the encoder
and the language model are downloaded from their own repositories.

## Usage

Reports are generated with
[`inference_nifti.py`](https://github.com/MIC-DKFZ/3d_report_generation/blob/main/inference_nifti.py) from the
[code repository](https://github.com/MIC-DKFZ/3d_report_generation), for a folder of NIfTI volumes:

```bash
git clone https://github.com/MIC-DKFZ/3d_report_generation.git && cd 3d_report_generation
uv sync --locked --python 3.12 --extra totalsegmentator
uv run hf download MIC-DKFZ/nnFoundationViT-ReportGen-Merlin --local-dir models/merlin

uv run torchrun --standalone --nproc_per_node=<number of GPUs> inference_nifti.py \
  --checkpoint_dir models/merlin \
  --input_dir /path/to/abdominal_ct_volumes \
  --mask_dir /path/to/masks \
  --output_dir /path/to/reports
```

The reports are saved in `inference_results.json`. See
[report generation for NIfTI volumes](https://github.com/MIC-DKFZ/3d_report_generation/blob/main/documentation/nifti_inference.md)
for masks, offline use, and batching.

## Expected input

Abdominal CT volumes as NIfTI files (`.nii.gz` or `.nii`). The script prepares each volume as in
training, so no settings have to be passed: it reorients the volume, crops it to the foreground of
its [TotalSegmentator](https://github.com/wasserth/TotalSegmentator) `total` mask (made if
missing), resizes the crop to 192³, and applies z-score normalization.

## Training

| Setting | Value |
|---|---|
| Data | Merlin training split and the source validation studies outside the 1,000 held for validation, with the report cleaning and study exclusions of RMR (v2 dataset JSONs) |
| Epochs | 32 |
| Effective batch size | 24 |
| Optimizer | AdamW, no weight decay |
| Learning rate | Adapter `3e-4`, LoRA `3e-4`; the adapter first trains alone with a warmup, then all trained parameters warm up again, followed by a cosine decay |

The released weights are the checkpoint with the best validation F1, from epoch 24.

## Evaluation

Results on the 5,125 reports of the official Merlin test split, with greedy decoding. The
clinical scores compare the findings that
[ModernBERT-Merlin](https://huggingface.co/MIC-DKFZ/ModernBERT-Merlin) extracts from the generated
reports with the reference labels, as macro averages over its 30 findings.

| Metric | Value |
|---|---|
| F1 (macro) | **0.503** |
| Precision (macro) | 0.556 |
| Recall (macro) | 0.468 |
| CRG | 0.498 |
| BLEU-1 / BLEU-4 | 0.301 / 0.115 |
| METEOR | 0.184 |
| ROUGE-L | 0.268 |
| CIDEr | 0.023 |

The generated reports are in `test_predictions/inference_results.json`; join them with the
dataset's reports by `image_id` to compute other metrics.

## Intended use and limitations

- Intended for research on radiology report generation, not for clinical decision-making or
  diagnosis. Generated reports can contain findings that are not present and miss findings that
  are.
- Trained only on abdominal CT from Merlin, with English reports; other body regions, scanners, and
  report styles have not been evaluated.
- Volumes are expected to be cropped to their TotalSegmentator mask. Reports for whole volumes
  (`--allow_missing_masks`) are less reliable, since the model saw almost none in training.

## Repository contents

| File | Purpose |
|---|---|
| `model.safetensors` | the trained adapter and LoRA weights |
| `final_config.yml` | the training config, including the preprocessing and the encoder revision that `inference_nifti.py` reads |
| `checkpoint_manifest.json` | checkpoint metadata |
| `test_predictions/` | the generated test-set reports and their metrics |
| `LICENSE` | CC BY-NC-SA 4.0 |

## Citation

If you use this model, please cite the nnFoundation paper for the vision encoder and RMR for the
report-generation recipe:

<details>
<summary>nnFoundation BibTeX</summary>

```bibtex
@misc{harsy2026nnfoundation3dfoundationmodels,
  title         = {nnFoundation: 3D Foundation Models for Radiology},
  author        = {Ulrich Harsy, Constantin and Wald, Tassilo and Gotkowski, Karol and others},
  year          = {2026},
  eprint        = {2609.26924},
  archivePrefix = {arXiv},
  primaryClass  = {cs.CV},
  url           = {https://arxiv.org/abs/2609.26924}
}
```

</details>

<details>
<summary>RMR BibTeX</summary>

```bibtex
@misc{suprijadi2026resolutionmeetsreduction,
  title         = {Resolution Meets Reduction: Efficient Visual Context for 3D Radiology Report Generation},
  author        = {Suprijadi, Jonathan and Stock, Raphael and Langenberg, Moritz
                   and Zimmerer, David and Kahl, Kim-Celine and Denner, Stefan
                   and Kirchhoff, Yannick and Gotkowski, Karol and Rokuss, Maximilian
                   and Traub, Jeremias and Wald, Tassilo and Ulrich, Constantin
                   and Maier-Hein, Klaus},
  year          = {2026},
  eprint        = {2608.08713},
  archivePrefix = {arXiv},
  primaryClass  = {cs.CV},
  url           = {https://arxiv.org/abs/2608.08713}
}
```

</details>

Please also acknowledge Merlin ([paper](https://arxiv.org/abs/2406.06512),
[dataset](https://stanford.redivis.com/datasets/exfv-e8h3kvfhs)) and
[Qwen3-VL](https://huggingface.co/Qwen/Qwen3-VL-2B-Instruct).

## License

The weights and this model card are licensed under
[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/), matching the
non-commercial terms of the Merlin training data. The vision encoder ([nnFoundationViT](https://huggingface.co/MIC-DKFZ/nnFoundationViT),
CC BY-SA 4.0) and the language model ([Qwen3-VL-2B-Instruct](https://huggingface.co/Qwen/Qwen3-VL-2B-Instruct),
Apache 2.0) are not included and keep their own licenses.