- Nature communications
- Published online: 2025, 5, 27
Preliminary
1. Receiver resampler: Cross modal의 efficient cross modal fusion을 위한 모듈.입
주로 아래와 같은 형태로 사용되는데, 입력을 이미지쪽에서 사용됨.
- 입력: Vision encoder에서의 feature map이 사용. (B, N, D). B:배치, N:패치수, D:차원. 이를 576을 24x24로 나눠도 꽤 숫자가 되기에, 이를 그냥 LM모델에 붙이기엔 너무 길다는 한계가 존재.
- Resampler token 초기화: 학습가능한 token을 만듬 (M, D). M은 하이퍼파라미터.
- Cross-attention: Resampler0=CrossAttention(Query=R, key,value=I). (입력: (M,D), (N, D), (N, D) -> 출력(M, D))
- R: trainable resampler token. $R \in \mathbb{R}^{M \times D}$
- I: vision feature map. $I \in \mathbb{R}^{N \times D}$
- Stacked Self-Attention + FeedForward Layers (L times): 여러 Transformer block을 통과시켜서 Resampler token을 더 많이 요약시킴.
for i in range(L):
x = TransformerBlock(x)
요약하면 아래와 같음.
Image → Vision Encoder (e.g. frozen ViT)
→ Perceiver Resampler → Visual Tokens
Text → Frozen Language Model (e.g. Chinchilla)
→ Cross-Attend to Visual Tokens
Methods
- Preprocessing:
- image: 256x256 patchification + Resize(224) (# CLAM과 유사)
- text: pathology report을 GPT을 이용해서 6개정도 페러프레이징해서 보유
- Architecture:
- Visual encoder: CTransPath. 각 패치당 768-d vectors. (N, 768)
- Receiver Resampler: 고정수의 표현으로 변경. trainable vector (N, 768)->(640, 1536)
- Language model: BioGPT (L, 1536)
- XATTN: Cross attention: 언어모델과 비전인코더를 있는 블록만 새로 학습. (L, 1536), (640, 1536), (640, 1536) -> (L, 1536)
- Query: Language model (BioGPT) (L, 1536)
- Key: Receiver resampler로 부터온 벡터 (640, 1536)
- Value: Receiver resampler로 부터온 벡터 (640, 1536)
- Linear + Softamx + word probablity
- Obejctive: PLIP(Pathology Language–Image Pretraining)의 Image-text contrastive learning 방식 (ITC)
- Generation: BioGPT가 생성. 재귀적생성.
위 과정을 재귀적으로 진행. [BOS] -> [BOS] + word1 -> [BOS] + word1 + word2... -> [BOS] + word1 + word2...[EOS]종
학습방법
- Image only pre-training: Resampler을 포함하여 MIL로 최종진단을 낼 수 있도록 사용. CrossEntropy로 목적함수
- joint tuning: 텍스트 생성에 대한 토큰 예측을 하기위해서 아래와 같이 구성
- Stage 1에서 학습한 이미지 인코더 및 리샘플러를 프리징
- 입력토큰: [BOS] + 프롬프트("Final diagnosis":) 생성
- 모든 BioGPT내의 Transformer layer에 들어갈 때
- h = ffn(self_att(text_token)) 을 추림
- 이미지 인코더에서 얻은 요약정보을 (K,V)로 하여 h와 cross-attention
- 그 후에 vocabulary head을 이용해서 다음 단어에 대한 logit을 추
for layer in BioGPT_layers:
h = BioGPT_block(layer, txt_ids) # (L,1536)
z = XATTN_layer(h, latents) # (L,1536)
txt_ids = txt_ids + z # residual
loss = cross_entropy(next_token_logits, target_ids) # CLM
반응형
'Digital pathology' 카테고리의 다른 글
AI-Based Anomaly Detection for Clinical-Grade Histopathological Diagnostics (0) | 2025.06.23 |
---|---|
Do Multiple Instance Learning Models Transfer (0) | 2025.06.23 |
Stomach histology: H.pylori (0) | 2025.04.02 |
An Interpretable Multilabel Deep Learning Framework for theSimultaneous Assessment of Multiple Indicators (0) | 2025.03.04 |
[5분 컷 이해] Kappa score 란? (0) | 2025.02.24 |