Instructions to use suitch/scan2report-decoder-dpo with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use suitch/scan2report-decoder-dpo with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-4B") model = PeftModel.from_pretrained(base_model, "suitch/scan2report-decoder-dpo") - Notebooks
- Google Colab
- Kaggle
Upload thesis checkpoint
Browse files- README.md +39 -0
- adapter_config.json +48 -0
- adapter_model.safetensors +3 -0
- projector.pt +3 -0
README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-nc-sa-4.0
|
| 3 |
+
base_model: Qwen/Qwen3.5-4B
|
| 4 |
+
library_name: peft
|
| 5 |
+
pipeline_tag: image-text-to-text
|
| 6 |
+
tags:
|
| 7 |
+
- medical
|
| 8 |
+
- radiology
|
| 9 |
+
- ct
|
| 10 |
+
- report-generation
|
| 11 |
+
- ct-rate
|
| 12 |
+
- lora
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# DPO-tuned report decoder
|
| 16 |
+
|
| 17 |
+
Part of the master's thesis *From Scan to Report: Detecting, Segmenting and Reporting Findings in Chest CT* (code: https://github.com/Switchharsh/From_Scan_to_Report_Thesis).
|
| 18 |
+
|
| 19 |
+
The baseline decoder (`scan2report-decoder-baseline`) further tuned with DPO on 1,899 preference pairs (beta 0.1, lr 2e-5, 2 epochs).
|
| 20 |
+
|
| 21 |
+
| condition | CRG | macro-F1 |
|
| 22 |
+
|---|---|---|
|
| 23 |
+
| real scan | 0.3986 | 0.3162 |
|
| 24 |
+
| another patient's scan | 0.3726 | 0.1994 |
|
| 25 |
+
|
| 26 |
+
Three-seed mean (each DPO trained from its own baseline): CRG 0.3965 +- 0.0139, gap +0.0216 +- 0.0208; one of three seeds shows no CRG gap.
|
| 27 |
+
|
| 28 |
+
## How it fits together
|
| 29 |
+
- Input: the 8x8x8 FlexiCT token grid of a chest CT (`flexict/tokens8`, 864-dim per token) from CT-RATE.
|
| 30 |
+
- `projector.pt`: MLP (864 -> 2560 -> 2560, LayerNorm) that maps the visual tokens into the LLM embedding space.
|
| 31 |
+
- `adapter_model.safetensors` + `adapter_config.json`: LoRA (r=16, alpha=32) on [Qwen/Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B).
|
| 32 |
+
- Loading and generation code (model wrapper, data, evaluation): https://github.com/Switchharsh/From_Scan_to_Report_Thesis (`ctbench/rgen/model.py`, `evaluate.py`). The adapter is not a stand-alone chat model: the projector and the FlexiCT tokens are required.
|
| 33 |
+
- Task instruction used in every run: `Write the findings and impression for this chest CT.` Greedy decoding, at most 512 new tokens.
|
| 34 |
+
|
| 35 |
+
## Evaluation protocol
|
| 36 |
+
1,000 patient-sampled CT-RATE validation cases; CRG (micro) and macro-F1 with the RadBERT label reader (`suitch/radbert-english-ctrate-classifier`, threshold 0.5). Control = another patient's scan tokens (mismatched). Numbers are from the thesis *From Scan to Report: Detecting, Segmenting and Reporting Findings in Chest CT*.
|
| 37 |
+
|
| 38 |
+
## Limitations / licence
|
| 39 |
+
Research use only, not for clinical use. Trained on CT-RATE (CC BY-NC-SA 4.0), so the weights are released under the same non-commercial terms. Reports can contain false findings; see the thesis for the error analysis.
|
adapter_config.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": null,
|
| 6 |
+
"base_model_name_or_path": "Qwen/Qwen3.5-4B",
|
| 7 |
+
"bias": "none",
|
| 8 |
+
"corda_config": null,
|
| 9 |
+
"ensure_weight_tying": false,
|
| 10 |
+
"eva_config": null,
|
| 11 |
+
"exclude_modules": null,
|
| 12 |
+
"fan_in_fan_out": false,
|
| 13 |
+
"inference_mode": true,
|
| 14 |
+
"init_lora_weights": true,
|
| 15 |
+
"layer_replication": null,
|
| 16 |
+
"layers_pattern": null,
|
| 17 |
+
"layers_to_transform": null,
|
| 18 |
+
"loftq_config": {},
|
| 19 |
+
"lora_alpha": 32,
|
| 20 |
+
"lora_bias": false,
|
| 21 |
+
"lora_dropout": 0.05,
|
| 22 |
+
"lora_ga_config": null,
|
| 23 |
+
"megatron_config": null,
|
| 24 |
+
"megatron_core": "megatron.core",
|
| 25 |
+
"modules_to_save": null,
|
| 26 |
+
"peft_type": "LORA",
|
| 27 |
+
"peft_version": "0.19.1",
|
| 28 |
+
"qalora_group_size": 16,
|
| 29 |
+
"r": 16,
|
| 30 |
+
"rank_pattern": {},
|
| 31 |
+
"revision": null,
|
| 32 |
+
"target_modules": [
|
| 33 |
+
"v_proj",
|
| 34 |
+
"up_proj",
|
| 35 |
+
"q_proj",
|
| 36 |
+
"o_proj",
|
| 37 |
+
"k_proj",
|
| 38 |
+
"gate_proj",
|
| 39 |
+
"down_proj"
|
| 40 |
+
],
|
| 41 |
+
"target_parameters": null,
|
| 42 |
+
"task_type": "CAUSAL_LM",
|
| 43 |
+
"trainable_token_indices": null,
|
| 44 |
+
"use_bdlora": null,
|
| 45 |
+
"use_dora": false,
|
| 46 |
+
"use_qalora": false,
|
| 47 |
+
"use_rslora": false
|
| 48 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ac2d614e7461333d9b709082333247f6e75d3f767efbb7e2733633d46de98776
|
| 3 |
+
size 84968408
|
projector.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0ebbf422e89dbeb69c211e6bb6886e5c6b3be4143941906296a0db26de89cfff
|
| 3 |
+
size 17554477
|