Image-Text-to-Text
Transformers
Safetensors
English
pathology
computational-pathology
digital-pathology
histopathology
whole-slide-image
vision-language-model
report-generation
synoptic-report
case-level
conch
qwen2.5
Eval Results (legacy)
Instructions to use AtlasAnalyticsLab/PathoSynVLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AtlasAnalyticsLab/PathoSynVLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="AtlasAnalyticsLab/PathoSynVLM")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AtlasAnalyticsLab/PathoSynVLM", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AtlasAnalyticsLab/PathoSynVLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AtlasAnalyticsLab/PathoSynVLM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AtlasAnalyticsLab/PathoSynVLM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/AtlasAnalyticsLab/PathoSynVLM
- SGLang
How to use AtlasAnalyticsLab/PathoSynVLM with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "AtlasAnalyticsLab/PathoSynVLM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AtlasAnalyticsLab/PathoSynVLM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "AtlasAnalyticsLab/PathoSynVLM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AtlasAnalyticsLab/PathoSynVLM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use AtlasAnalyticsLab/PathoSynVLM with Docker Model Runner:
docker model run hf.co/AtlasAnalyticsLab/PathoSynVLM
Jiahao Cheng commited on
Commit ·
aa50ff8
1
Parent(s): 5feef29
Release PathoSynVLM model weights
Browse files- .gitattributes +3 -32
- LICENSE +21 -0
- README.md +229 -0
- assets/paper_architecture.png +3 -0
- assets/reported_results.svg +121 -0
- best_checkpoint_summary.json +39 -0
- config.json +31 -0
- examples/case_input_example.json +9 -0
- labels.json +30 -0
- llm/config.json +69 -0
- llm/generation_config.json +14 -0
- llm/model.safetensors +3 -0
- model_index.json +52 -0
- tokenizer/chat_template.jinja +54 -0
- tokenizer/tokenizer.json +3 -0
- tokenizer/tokenizer_config.json +29 -0
- vlm_state.pt +3 -0
.gitattributes
CHANGED
|
@@ -1,35 +1,6 @@
|
|
| 1 |
-
*.
|
| 2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
-
*.
|
| 25 |
-
|
| 26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 1 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 2 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 4 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
tokenizer/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2026 PathoSynVLM authors
|
| 4 |
+
|
| 5 |
+
This repository is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike
|
| 6 |
+
4.0 International Public License (CC BY-NC-SA 4.0).
|
| 7 |
+
|
| 8 |
+
SPDX-License-Identifier: CC-BY-NC-SA-4.0
|
| 9 |
+
|
| 10 |
+
You are free to share and adapt the licensed material for non-commercial purposes,
|
| 11 |
+
provided that you give appropriate credit, indicate changes, and distribute adapted
|
| 12 |
+
material under the same license.
|
| 13 |
+
|
| 14 |
+
Full legal code:
|
| 15 |
+
https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
|
| 16 |
+
|
| 17 |
+
Human-readable summary:
|
| 18 |
+
https://creativecommons.org/licenses/by-nc-sa/4.0/
|
| 19 |
+
|
| 20 |
+
Dataset access, pretrained third-party models, and any externally hosted model
|
| 21 |
+
weights remain subject to their own licenses and terms of use.
|
README.md
CHANGED
|
@@ -1,3 +1,232 @@
|
|
| 1 |
---
|
| 2 |
license: cc-by-nc-sa-4.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: cc-by-nc-sa-4.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: image-text-to-text
|
| 7 |
+
base_model:
|
| 8 |
+
- Qwen/Qwen2.5-3B-Instruct
|
| 9 |
+
tags:
|
| 10 |
+
- pathology
|
| 11 |
+
- computational-pathology
|
| 12 |
+
- digital-pathology
|
| 13 |
+
- histopathology
|
| 14 |
+
- whole-slide-image
|
| 15 |
+
- vision-language-model
|
| 16 |
+
- report-generation
|
| 17 |
+
- synoptic-report
|
| 18 |
+
- case-level
|
| 19 |
+
- conch
|
| 20 |
+
- qwen2.5
|
| 21 |
+
datasets:
|
| 22 |
+
- david4real/HistGen
|
| 23 |
+
metrics:
|
| 24 |
+
- rouge
|
| 25 |
+
- meteor
|
| 26 |
+
- bleu
|
| 27 |
+
- bertscore
|
| 28 |
+
arxiv: 2605.30716
|
| 29 |
+
model-index:
|
| 30 |
+
- name: PathoSynVLM
|
| 31 |
+
results:
|
| 32 |
+
- task:
|
| 33 |
+
type: image-text-to-text
|
| 34 |
+
name: Case-level pathology synoptic report generation
|
| 35 |
+
dataset:
|
| 36 |
+
name: HISTAI case-report pairs
|
| 37 |
+
type: HISTAI
|
| 38 |
+
metrics:
|
| 39 |
+
- type: rouge
|
| 40 |
+
name: ROUGE-L
|
| 41 |
+
value: 0.2495
|
| 42 |
+
- type: meteor
|
| 43 |
+
name: METEOR
|
| 44 |
+
value: 0.1988
|
| 45 |
+
- type: bleu
|
| 46 |
+
name: BLEU-4
|
| 47 |
+
value: 0.0525
|
| 48 |
+
- type: bertscore
|
| 49 |
+
name: BERTScore F1
|
| 50 |
+
value: 0.3018
|
| 51 |
---
|
| 52 |
+
|
| 53 |
+
# PathoSynVLM: Case-Level Pathology Synoptic Report Generation
|
| 54 |
+
|
| 55 |
+
PathoSynVLM is a token-efficient vision-language model for generating
|
| 56 |
+
case-level pathology synoptic reports from one or more whole-slide
|
| 57 |
+
images represented as precomputed CONCHv1.5 patch embeddings.
|
| 58 |
+
|
| 59 |
+
Paper: [Simple Token-Efficient Vision-Language Model for Case-level
|
| 60 |
+
Pathology Synoptic Report Generation](https://arxiv.org/abs/2605.30716)
|
| 61 |
+
|
| 62 |
+
Code: [https://github.com/AtlasAnalyticsLab/PathoSynVLM](https://github.com/AtlasAnalyticsLab/PathoSynVLM)
|
| 63 |
+
|
| 64 |
+
Model: [https://huggingface.co/AtlasAnalyticsLab/PathoSynVLM](https://huggingface.co/AtlasAnalyticsLab/PathoSynVLM)
|
| 65 |
+
|
| 66 |
+

|
| 67 |
+
|
| 68 |
+
## What This Repository Contains
|
| 69 |
+
|
| 70 |
+
This Hugging Face repository contains the exported Stage 2 PathoSynVLM
|
| 71 |
+
model package:
|
| 72 |
+
|
| 73 |
+
```text
|
| 74 |
+
README.md
|
| 75 |
+
LICENSE
|
| 76 |
+
model_index.json
|
| 77 |
+
config.json
|
| 78 |
+
vlm_state.pt
|
| 79 |
+
labels.json
|
| 80 |
+
tokenizer/
|
| 81 |
+
llm/
|
| 82 |
+
best_checkpoint_summary.json
|
| 83 |
+
assets/
|
| 84 |
+
examples/
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
The paper run used `unfreeze_llm_base=true`, so the release package
|
| 88 |
+
includes the merged/full language-model weights under `llm/`, not only a
|
| 89 |
+
LoRA adapter.
|
| 90 |
+
|
| 91 |
+
## Quickstart
|
| 92 |
+
|
| 93 |
+
Install the code repository:
|
| 94 |
+
|
| 95 |
+
```bash
|
| 96 |
+
git clone https://github.com/AtlasAnalyticsLab/PathoSynVLM PathoSynVLM
|
| 97 |
+
cd PathoSynVLM
|
| 98 |
+
conda create -n pathosynvlm python=3.11 -y
|
| 99 |
+
conda activate pathosynvlm
|
| 100 |
+
export PYTHONNOUSERSITE=1
|
| 101 |
+
pip install -e .
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
Download this model repository:
|
| 105 |
+
|
| 106 |
+
```bash
|
| 107 |
+
source configs/paths.example.env
|
| 108 |
+
hf download AtlasAnalyticsLab/PathoSynVLM --local-dir "$PATHOSYNVLM_WEIGHTS_ROOT/pathosynvlm-stage2-main"
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
Generate a case-level report from one or more slide embedding files:
|
| 112 |
+
|
| 113 |
+
```bash
|
| 114 |
+
python scripts/generate_case_report.py \
|
| 115 |
+
--embeddings slide_1.h5 slide_2.h5 \
|
| 116 |
+
--output_json report.json
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
Relative `--embeddings` paths are resolved under
|
| 120 |
+
`PATHOSYNVLM_EMBEDDINGS_ROOT`. Absolute `.h5` paths also work.
|
| 121 |
+
|
| 122 |
+
The output follows:
|
| 123 |
+
|
| 124 |
+
```text
|
| 125 |
+
Diagnosis: ...
|
| 126 |
+
Certainty: ...
|
| 127 |
+
Conclusion: ...
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
## Input Format
|
| 131 |
+
|
| 132 |
+
PathoSynVLM runs on precomputed WSI patch embeddings, not raw WSIs. Each
|
| 133 |
+
`.h5` file should contain:
|
| 134 |
+
|
| 135 |
+
```text
|
| 136 |
+
/features/conch_v15 # shape: (num_patches, 768)
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
Use the code repository docs for dataset placement, metadata filtering,
|
| 140 |
+
and embedding generation details.
|
| 141 |
+
|
| 142 |
+
### From Precomputed H5 Feature Files
|
| 143 |
+
|
| 144 |
+
This is the fastest path. Put one or more WSI embedding files for a case
|
| 145 |
+
into the `--embeddings` argument:
|
| 146 |
+
|
| 147 |
+
```bash
|
| 148 |
+
python scripts/generate_case_report.py \
|
| 149 |
+
--embeddings case_slide_1.h5 case_slide_2.h5 \
|
| 150 |
+
--output_json report.json
|
| 151 |
+
```
|
| 152 |
+
|
| 153 |
+
### From Raw Whole-Slide Images
|
| 154 |
+
|
| 155 |
+
First extract tissue patches and CONCHv1.5 patch embeddings using a WSI
|
| 156 |
+
preprocessing pipeline that writes the H5 layout above. Then pass the
|
| 157 |
+
resulting H5 files to `scripts/generate_case_report.py`.
|
| 158 |
+
|
| 159 |
+
## Running The Paper Pipeline
|
| 160 |
+
|
| 161 |
+
To rerun training and evaluation, follow the code repository guide:
|
| 162 |
+
|
| 163 |
+
```bash
|
| 164 |
+
git clone https://github.com/AtlasAnalyticsLab/PathoSynVLM PathoSynVLM
|
| 165 |
+
cd PathoSynVLM
|
| 166 |
+
export PYTHONNOUSERSITE=1
|
| 167 |
+
pip install -e .
|
| 168 |
+
|
| 169 |
+
# 1. Download HistGen, REG2025, and HISTAI metadata/WSIs.
|
| 170 |
+
# 2. Extract CONCHv1.5 H5 patch embeddings.
|
| 171 |
+
# 3. Prepare Stage 1 and Stage 2 metadata.
|
| 172 |
+
# 4. Train Stage 1 alignment.
|
| 173 |
+
# 5. Train Stage 2 HISTAI report generation.
|
| 174 |
+
# 6. Evaluate with scripts/evaluate_checkpoint.py.
|
| 175 |
+
```
|
| 176 |
+
|
| 177 |
+
## Training Recipe
|
| 178 |
+
|
| 179 |
+
- Stage 1: train the two-layer MLP aligner on HistGen + REG2025 while
|
| 180 |
+
keeping the CONCHv1.5 patch encoder and LLM frozen.
|
| 181 |
+
- Stage 2: finetune on HISTAI case-report pairs with WSI marker tokens.
|
| 182 |
+
|
| 183 |
+
Checkpoint selected for release:
|
| 184 |
+
|
| 185 |
+
- checkpoint step: `30400`
|
| 186 |
+
- checkpoint epoch: `7`
|
| 187 |
+
- validation loss: `1.010892`
|
| 188 |
+
- prompt style: `double`
|
| 189 |
+
- patch level: `5x_512`
|
| 190 |
+
- max vision tokens: `4096`
|
| 191 |
+
|
| 192 |
+
## Reported Metrics
|
| 193 |
+
|
| 194 |
+
Stage 1 aligner-only training:
|
| 195 |
+
|
| 196 |
+
| ROUGE-L | METEOR | BLEU-4 | BERTScore F1 |
|
| 197 |
+
|---:|---:|---:|---:|
|
| 198 |
+
| 0.4743 | 0.4810 | 0.1247 | 0.4253 |
|
| 199 |
+
|
| 200 |
+
Stage 2 HISTAI main result:
|
| 201 |
+
|
| 202 |
+
| ROUGE-L | METEOR | BLEU-4 | BERTScore F1 | Diagnosis Exact | Diagnosis Relaxed | Certainty |
|
| 203 |
+
|---:|---:|---:|---:|---:|---:|---:|
|
| 204 |
+
| 0.2495 | 0.1988 | 0.0525 | 0.3018 | 0.1667 | 0.3333 | 0.9000 |
|
| 205 |
+
|
| 206 |
+
## Intended Use
|
| 207 |
+
|
| 208 |
+
This model is intended for research on pathology report generation from
|
| 209 |
+
precomputed WSI patch embeddings.
|
| 210 |
+
|
| 211 |
+
It is not a clinical diagnostic device and should not be used for patient
|
| 212 |
+
care without appropriate validation, regulatory review, and expert
|
| 213 |
+
oversight.
|
| 214 |
+
|
| 215 |
+
## License and Commercial Use
|
| 216 |
+
|
| 217 |
+
This repository uses CC BY-NC-SA 4.0. Research and non-commercial use only.
|
| 218 |
+
Dataset access, pretrained third-party models, and any externally hosted
|
| 219 |
+
model weights remain subject to their own terms.
|
| 220 |
+
|
| 221 |
+
## Citation
|
| 222 |
+
|
| 223 |
+
```bibtex
|
| 224 |
+
@inproceedings{yang2026simpletokenvlm,
|
| 225 |
+
title = {Simple Token-Efficient Vision-Language Model for Case-Level Pathology Synoptic Report Generation},
|
| 226 |
+
author = {Yang, Zhiyuan and Cheng, Jiahao and Trinh, Vincent Quoc-Huy and Hosseini, Mahdi S.},
|
| 227 |
+
booktitle = {Proceedings of the 7th International Conference on Deep Learning Theory and Applications},
|
| 228 |
+
pages = {514--537},
|
| 229 |
+
year = {2026},
|
| 230 |
+
issn = {2184-9277}
|
| 231 |
+
}
|
| 232 |
+
```
|
assets/paper_architecture.png
ADDED
|
Git LFS Details
|
assets/reported_results.svg
ADDED
|
|
best_checkpoint_summary.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_step": 30400,
|
| 3 |
+
"best_epoch": 7,
|
| 4 |
+
"best_source": "step_eval",
|
| 5 |
+
"best_val_loss": 1.0108920872211455,
|
| 6 |
+
"metrics": {
|
| 7 |
+
"val_loss": 1.0108920872211455,
|
| 8 |
+
"val_n_samples": 30,
|
| 9 |
+
"val/vision_tokens_total": 34833,
|
| 10 |
+
"val/text_tokens_total": 9942,
|
| 11 |
+
"val/target_tokens_total": 3305,
|
| 12 |
+
"val/wsi_count_total": 188,
|
| 13 |
+
"val/avg_vision_tokens_per_sample": 1161.1,
|
| 14 |
+
"val/avg_text_tokens_per_sample": 331.4,
|
| 15 |
+
"val/avg_target_tokens_per_sample": 110.16666666666667,
|
| 16 |
+
"val/avg_wsi_per_sample": 6.266666666666667,
|
| 17 |
+
"val_bertscore_f1": 0.3017574870338043,
|
| 18 |
+
"val/field_eval_n": 30,
|
| 19 |
+
"val_diagnosis_relaxed_match_rate": 0.3333333333333333,
|
| 20 |
+
"val_diagnosis_exact_match_rate": 0.16666666666666666,
|
| 21 |
+
"val_certainty_match_rate": 0.9,
|
| 22 |
+
"val_certainty_exact_match_rate": 0.9,
|
| 23 |
+
"val_conclusion_exact_match_rate": 0.0,
|
| 24 |
+
"val_conclusion_rougeL": 0.24946812913260996,
|
| 25 |
+
"val_conclusion_meteor": 0.1988453811627603,
|
| 26 |
+
"val_conclusion_bleu4": 5.251211118089842,
|
| 27 |
+
"val/pred_format_score_0_count": 0,
|
| 28 |
+
"val/ref_format_score_0_count": 0,
|
| 29 |
+
"val/pred_format_score_1_count": 0,
|
| 30 |
+
"val/ref_format_score_1_count": 0,
|
| 31 |
+
"val/pred_format_score_2_count": 0,
|
| 32 |
+
"val/ref_format_score_2_count": 0,
|
| 33 |
+
"val/pred_format_score_3_count": 30,
|
| 34 |
+
"val/ref_format_score_3_count": 30,
|
| 35 |
+
"val/pred_diagnosis_present_rate": 1.0,
|
| 36 |
+
"val/pred_certainty_present_rate": 1.0,
|
| 37 |
+
"val/pred_conclusion_present_rate": 1.0
|
| 38 |
+
}
|
| 39 |
+
}
|
config.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"format_version": 1,
|
| 3 |
+
"checkpoint_step": 30400,
|
| 4 |
+
"base_llm": "Qwen/Qwen2.5-3B-Instruct",
|
| 5 |
+
"llm_kind": "merged",
|
| 6 |
+
"llm_path": "llm",
|
| 7 |
+
"vision_dim": 768,
|
| 8 |
+
"feature_key": "conch_v15",
|
| 9 |
+
"patch_level": "5x_512",
|
| 10 |
+
"use_wsi_markers": true,
|
| 11 |
+
"use_wsi_index_emb": true,
|
| 12 |
+
"prompt_style": "double",
|
| 13 |
+
"report_target_field": "conclusion",
|
| 14 |
+
"report_target_label": "",
|
| 15 |
+
"training_config": {
|
| 16 |
+
"llm": "Qwen/Qwen2.5-3B-Instruct",
|
| 17 |
+
"vision_dim": 768,
|
| 18 |
+
"feature_key": "conch_v15",
|
| 19 |
+
"patch_level": "5x_512",
|
| 20 |
+
"use_wsi_markers": true,
|
| 21 |
+
"prompt_style": "double",
|
| 22 |
+
"max_text_length": 384,
|
| 23 |
+
"max_vision_tokens": 4096,
|
| 24 |
+
"vision_token_dropout": 0.0,
|
| 25 |
+
"lora_r": 16,
|
| 26 |
+
"lora_alpha": 32,
|
| 27 |
+
"lora_dropout": 0.05,
|
| 28 |
+
"lora_target": "q_proj,k_proj,v_proj,o_proj",
|
| 29 |
+
"unfreeze_llm_base": true
|
| 30 |
+
}
|
| 31 |
+
}
|
examples/case_input_example.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"case_id": "example_case",
|
| 3 |
+
"slide_embeddings": [
|
| 4 |
+
"HISTAI-example/conch_v15/5x_512/patches/slide_1.h5",
|
| 5 |
+
"HISTAI-example/conch_v15/5x_512/patches/slide_2.h5"
|
| 6 |
+
],
|
| 7 |
+
"feature_key": "conch_v15",
|
| 8 |
+
"command": "python scripts/generate_case_report.py --embeddings HISTAI-example/conch_v15/5x_512/patches/slide_1.h5 HISTAI-example/conch_v15/5x_512/patches/slide_2.h5 --output_json report.json"
|
| 9 |
+
}
|
labels.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task": "case_level_pathology_synoptic_report_generation",
|
| 3 |
+
"input": {
|
| 4 |
+
"type": "one_or_more_h5_wsi_embedding_files",
|
| 5 |
+
"feature_dataset": "/features/conch_v15",
|
| 6 |
+
"feature_dim": 768,
|
| 7 |
+
"patch_level": "5x_512"
|
| 8 |
+
},
|
| 9 |
+
"output_fields": [
|
| 10 |
+
{
|
| 11 |
+
"name": "diagnosis",
|
| 12 |
+
"label": "Diagnosis",
|
| 13 |
+
"type": "free_text",
|
| 14 |
+
"required": true
|
| 15 |
+
},
|
| 16 |
+
{
|
| 17 |
+
"name": "certainty",
|
| 18 |
+
"label": "Certainty",
|
| 19 |
+
"type": "free_text_or_percentage",
|
| 20 |
+
"required": true
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"name": "conclusion",
|
| 24 |
+
"label": "Conclusion",
|
| 25 |
+
"type": "free_text",
|
| 26 |
+
"required": true
|
| 27 |
+
}
|
| 28 |
+
],
|
| 29 |
+
"expected_text_format": "Diagnosis: ...\\nCertainty: ...\\nConclusion: ..."
|
| 30 |
+
}
|
llm/config.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Qwen2ForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_dropout": 0.0,
|
| 6 |
+
"bos_token_id": 151643,
|
| 7 |
+
"dtype": "bfloat16",
|
| 8 |
+
"eos_token_id": 151645,
|
| 9 |
+
"hidden_act": "silu",
|
| 10 |
+
"hidden_size": 2048,
|
| 11 |
+
"initializer_range": 0.02,
|
| 12 |
+
"intermediate_size": 11008,
|
| 13 |
+
"layer_types": [
|
| 14 |
+
"full_attention",
|
| 15 |
+
"full_attention",
|
| 16 |
+
"full_attention",
|
| 17 |
+
"full_attention",
|
| 18 |
+
"full_attention",
|
| 19 |
+
"full_attention",
|
| 20 |
+
"full_attention",
|
| 21 |
+
"full_attention",
|
| 22 |
+
"full_attention",
|
| 23 |
+
"full_attention",
|
| 24 |
+
"full_attention",
|
| 25 |
+
"full_attention",
|
| 26 |
+
"full_attention",
|
| 27 |
+
"full_attention",
|
| 28 |
+
"full_attention",
|
| 29 |
+
"full_attention",
|
| 30 |
+
"full_attention",
|
| 31 |
+
"full_attention",
|
| 32 |
+
"full_attention",
|
| 33 |
+
"full_attention",
|
| 34 |
+
"full_attention",
|
| 35 |
+
"full_attention",
|
| 36 |
+
"full_attention",
|
| 37 |
+
"full_attention",
|
| 38 |
+
"full_attention",
|
| 39 |
+
"full_attention",
|
| 40 |
+
"full_attention",
|
| 41 |
+
"full_attention",
|
| 42 |
+
"full_attention",
|
| 43 |
+
"full_attention",
|
| 44 |
+
"full_attention",
|
| 45 |
+
"full_attention",
|
| 46 |
+
"full_attention",
|
| 47 |
+
"full_attention",
|
| 48 |
+
"full_attention",
|
| 49 |
+
"full_attention"
|
| 50 |
+
],
|
| 51 |
+
"max_position_embeddings": 32768,
|
| 52 |
+
"max_window_layers": 70,
|
| 53 |
+
"model_type": "qwen2",
|
| 54 |
+
"num_attention_heads": 16,
|
| 55 |
+
"num_hidden_layers": 36,
|
| 56 |
+
"num_key_value_heads": 2,
|
| 57 |
+
"pad_token_id": null,
|
| 58 |
+
"rms_norm_eps": 1e-06,
|
| 59 |
+
"rope_parameters": {
|
| 60 |
+
"rope_theta": 1000000.0,
|
| 61 |
+
"rope_type": "default"
|
| 62 |
+
},
|
| 63 |
+
"sliding_window": null,
|
| 64 |
+
"tie_word_embeddings": true,
|
| 65 |
+
"transformers_version": "5.0.0",
|
| 66 |
+
"use_cache": true,
|
| 67 |
+
"use_sliding_window": false,
|
| 68 |
+
"vocab_size": 151936
|
| 69 |
+
}
|
llm/generation_config.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token_id": 151643,
|
| 3 |
+
"do_sample": true,
|
| 4 |
+
"eos_token_id": [
|
| 5 |
+
151645,
|
| 6 |
+
151643
|
| 7 |
+
],
|
| 8 |
+
"pad_token_id": 151643,
|
| 9 |
+
"repetition_penalty": 1.05,
|
| 10 |
+
"temperature": 0.7,
|
| 11 |
+
"top_k": 20,
|
| 12 |
+
"top_p": 0.8,
|
| 13 |
+
"transformers_version": "5.0.0"
|
| 14 |
+
}
|
llm/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fa8a241416b1b9fcc6c2a3557ea914148c76abbdee6b403e2232aaad90ac859c
|
| 3 |
+
size 6171927112
|
model_index.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "PathoSynVLM",
|
| 3 |
+
"results": [
|
| 4 |
+
{
|
| 5 |
+
"task": {
|
| 6 |
+
"type": "image-text-to-text",
|
| 7 |
+
"name": "Case-level pathology synoptic report generation"
|
| 8 |
+
},
|
| 9 |
+
"dataset": {
|
| 10 |
+
"name": "HISTAI case-report pairs",
|
| 11 |
+
"type": "HISTAI"
|
| 12 |
+
},
|
| 13 |
+
"metrics": [
|
| 14 |
+
{
|
| 15 |
+
"type": "rouge",
|
| 16 |
+
"name": "ROUGE-L",
|
| 17 |
+
"value": 0.2495
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"type": "meteor",
|
| 21 |
+
"name": "METEOR",
|
| 22 |
+
"value": 0.1988
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"type": "bleu",
|
| 26 |
+
"name": "BLEU-4",
|
| 27 |
+
"value": 0.0525
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"type": "bertscore",
|
| 31 |
+
"name": "BERTScore F1",
|
| 32 |
+
"value": 0.3018
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"type": "accuracy",
|
| 36 |
+
"name": "Diagnosis Exact",
|
| 37 |
+
"value": 0.1667
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"type": "accuracy",
|
| 41 |
+
"name": "Diagnosis Relaxed",
|
| 42 |
+
"value": 0.3333
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"type": "accuracy",
|
| 46 |
+
"name": "Certainty",
|
| 47 |
+
"value": 0.9
|
| 48 |
+
}
|
| 49 |
+
]
|
| 50 |
+
}
|
| 51 |
+
]
|
| 52 |
+
}
|
tokenizer/chat_template.jinja
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- if tools %}
|
| 2 |
+
{{- '<|im_start|>system\n' }}
|
| 3 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 4 |
+
{{- messages[0]['content'] }}
|
| 5 |
+
{%- else %}
|
| 6 |
+
{{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}
|
| 7 |
+
{%- endif %}
|
| 8 |
+
{{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
|
| 9 |
+
{%- for tool in tools %}
|
| 10 |
+
{{- "\n" }}
|
| 11 |
+
{{- tool | tojson }}
|
| 12 |
+
{%- endfor %}
|
| 13 |
+
{{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
|
| 14 |
+
{%- else %}
|
| 15 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 16 |
+
{{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
|
| 17 |
+
{%- else %}
|
| 18 |
+
{{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }}
|
| 19 |
+
{%- endif %}
|
| 20 |
+
{%- endif %}
|
| 21 |
+
{%- for message in messages %}
|
| 22 |
+
{%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
|
| 23 |
+
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
|
| 24 |
+
{%- elif message.role == "assistant" %}
|
| 25 |
+
{{- '<|im_start|>' + message.role }}
|
| 26 |
+
{%- if message.content %}
|
| 27 |
+
{{- '\n' + message.content }}
|
| 28 |
+
{%- endif %}
|
| 29 |
+
{%- for tool_call in message.tool_calls %}
|
| 30 |
+
{%- if tool_call.function is defined %}
|
| 31 |
+
{%- set tool_call = tool_call.function %}
|
| 32 |
+
{%- endif %}
|
| 33 |
+
{{- '\n<tool_call>\n{"name": "' }}
|
| 34 |
+
{{- tool_call.name }}
|
| 35 |
+
{{- '", "arguments": ' }}
|
| 36 |
+
{{- tool_call.arguments | tojson }}
|
| 37 |
+
{{- '}\n</tool_call>' }}
|
| 38 |
+
{%- endfor %}
|
| 39 |
+
{{- '<|im_end|>\n' }}
|
| 40 |
+
{%- elif message.role == "tool" %}
|
| 41 |
+
{%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
|
| 42 |
+
{{- '<|im_start|>user' }}
|
| 43 |
+
{%- endif %}
|
| 44 |
+
{{- '\n<tool_response>\n' }}
|
| 45 |
+
{{- message.content }}
|
| 46 |
+
{{- '\n</tool_response>' }}
|
| 47 |
+
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
|
| 48 |
+
{{- '<|im_end|>\n' }}
|
| 49 |
+
{%- endif %}
|
| 50 |
+
{%- endif %}
|
| 51 |
+
{%- endfor %}
|
| 52 |
+
{%- if add_generation_prompt %}
|
| 53 |
+
{{- '<|im_start|>assistant\n' }}
|
| 54 |
+
{%- endif %}
|
tokenizer/tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3fd169731d2cbde95e10bf356d66d5997fd885dd8dbb6fb4684da3f23b2585d8
|
| 3 |
+
size 11421892
|
tokenizer/tokenizer_config.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": null,
|
| 5 |
+
"clean_up_tokenization_spaces": false,
|
| 6 |
+
"eos_token": "<|im_end|>",
|
| 7 |
+
"errors": "replace",
|
| 8 |
+
"extra_special_tokens": [
|
| 9 |
+
"<|im_start|>",
|
| 10 |
+
"<|im_end|>",
|
| 11 |
+
"<|object_ref_start|>",
|
| 12 |
+
"<|object_ref_end|>",
|
| 13 |
+
"<|box_start|>",
|
| 14 |
+
"<|box_end|>",
|
| 15 |
+
"<|quad_start|>",
|
| 16 |
+
"<|quad_end|>",
|
| 17 |
+
"<|vision_start|>",
|
| 18 |
+
"<|vision_end|>",
|
| 19 |
+
"<|vision_pad|>",
|
| 20 |
+
"<|image_pad|>",
|
| 21 |
+
"<|video_pad|>"
|
| 22 |
+
],
|
| 23 |
+
"is_local": true,
|
| 24 |
+
"model_max_length": 131072,
|
| 25 |
+
"pad_token": "<|endoftext|>",
|
| 26 |
+
"split_special_tokens": false,
|
| 27 |
+
"tokenizer_class": "TokenizersBackend",
|
| 28 |
+
"unk_token": null
|
| 29 |
+
}
|
vlm_state.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3b66e6db4fefb9efb6308db3d5d189395b8ecd8f56f3179c36c0477f158b9dc3
|
| 3 |
+
size 46443749
|