Manuscript Offprint
arXiv:2610.30944Attention-guided classification and tumor localization of combined hepatocellular-cholangiocarcinoma
ABSTRACT
Combined hepatocellular-cholangiocarcinomas (cHCC-CCA) are a type of cancer that share components of two other primary liver cancers: hepatocellular carcinoma (HCC) and cholangiocarcinoma (CCA). Accurate diagnosis of cHCC-CCA, of which the behavior may resemble that of either HCC or CCA, remains a challenge due to strong intratumoral heterogeneity. Since the prognoses differ between liver cancer types, it is necessary to improve their morphological characterization and recognition in order to accurately identify cHCC-CCA. In this work, we use whole slide images (WSIs) of the two main types of liver cancer (HCC and CCA) and cHCC-CCA, stained with Hematoxylin–Eosin–Safran (HES), to train a classification model that can distinguish between these subtypes and provides a potential solution for localizing different types of tumors in the combined liver cancer images.
Index Terms— Combined hepatocellular-cholangiocarcinoma, whole-slide imaging, multiple instance learning, attention supervision, tumor component localization
1. INTRODUCTION
Hepatocellular carcinoma (HCC) and cholangiocarcinoma (CCA) are the major primary liver carcinomas, whereas combined hepatocellular-cholangiocarcinoma (cHCC-CCA) exhibits both hepatocytic and cholangiocytic differentiation [1]. This morphological heterogeneity motivates computational approaches for both whole-slide image (WSI) classification and component localization. Calderaro et al. [2] used a classifier trained on pure HCC and intrahepatic CCA (iCCA) to characterize HCC-like and iCCA-like morphology in cHCC-CCA. Beaufrère et al. [3] combined supervised tumor detection with feature clustering to estimate HCC and iCCA component proportions in cHCC-CCA biopsies.
Since detailed WSI annotations are difficult to obtain, weakly supervised multiple instance learning (MIL) performs classification from slide-level labels only. ABMIL [4] introduced attention-based instance aggregation, which CLAM [5] and TransMIL [6] extended through instance-level clustering and inter-instance modeling, respectively. MS-CLAM [7] further incorporated limited patch-level annotations and attention supervision to improve tumor classification and localization. However, high classification accuracy does not guarantee pathologically plausible attention or faithful explanations of model predictions [8].
We propose an attention-supervised three-class MIL model for HCC, CCA, and cHCC-CCA classification, using attention references from a binary HCC–CCA model to encourage pathological plausibility. We also propose a jointly trained dual-branch model that learns complementary attention patterns within tumor regions, generating distinct heatmaps of the same cHCC-CCA slide to localize HCC-like and CCA-like components.
2.1. Attention-guided three-class classification
Attention-based MIL assigns weights to instances within a bag, enabling the visualization of potentially relevant tissue regions. In our experiments, introducing cHCC-CCA as a third class alongside HCC and CCA sometimes shifted attention toward regions inconsistent with pathological annotations, indicating a low pathological plausibility of the attention maps. We therefore use attention maps generated by a binary HCC-CCA model as fixed references to supervise the three-class model on HCC and CCA slides (Figure 1). We adopt TransMIL [6], which contains two self-attention blocks separated by a Pyramid Position Encoding Generator (PPEG). Patch features are projected into D-dimensional embeddings and augmented with a learnable class token (CLS). Each attention block uses H heads of dimension D/H. We extract the CLS-query attention vectors from both blocks:
where N is the number of tokens, including the class token. To obtain a class-specific attention map, the classifier weights are used to estimate the importance of each attention head. For class c, the score of head h is computed as
where denotes the d-th component of the representation of head h, and denotes the corresponding classifier weight for class c. Different heads are fused in an attention-weighted way in our study, the head scores are normalized with softmax and used as fusion weights:
For attention supervision, we use the fused student attention and a fixed, precomputed teacher reference normalized to unit sum. The teacher and student vectors correspond to the same tokens in the same order. Supervision is applied separately to the two attention blocks. Their agreement is encouraged through a combination of distribution, magnitude, and directional matching by KL divergence , L1 distance and cosine distance . A relative-attention loss enforces a minimum student-attention ratio between tokens above the teacher's -quantile and those below its -quantile:
where and denote the mean student attention over these two sets, respectively, and . This term is zero if either set is empty.
The overall objective is
(4)
where and indicate whether reference supervision is available and enabled for layer . CCA and HCC slides receive both classification and attention supervision. cHCC-CCA slides receive classification supervision only.
2.2. Dual-branch model for tumor component localization
Beyond attention supervision, we encourage complementary attention to HCC-like and CCA-like components in cHCC-CCA tumors. We introduce a dual-branch MIL model jointly

Fig. 1: Attention-guided three-class MIL training.
trained with the three-class model to generate complementary attention maps for each cHCC-CCA slide. Figure 2 provides an overview of the joint training framework. The three-class model retains the classification and attention supervision described in Section 2.1. The dual model consists of two binary MIL branches. Branches 1 and 2 distinguish CCA/cHCC-CCA from HCC and HCC/cHCC-CCA from CCA, respectively. Both receive classification supervision for all slides and reference-based attention supervision for HCC and CCA slides only. These complementary label groupings are intended to promote CCA-like and HCC-like attention in branches 1 and 2, respectively. To prevent complementarity from shifting attention toward non-tumor regions, we restrict the complementary loss to a candidate foreground. This mask is obtained by combining, normalizing, and thresholding the three-class attention maps from both transformer blocks and is detached from the computation graph. Background suppression penalizes excessive attention outside the mask, while union alignment encourages the probabilistic union of the dual-branch maps to match the three-class attention distribution.
For cHCC-CCA slides, let denote the head-fused attention map of branch at block . The foreground mask , with token set , is obtained using normalization and threshold as described above. We compute the Pearson correlation between the normalized branch maps within . The complementary loss encourages negative correlation of a target:
The union and the corresponding three-class cHCC-CCA attention map are normalized into distributions, and their discrepancy is measured using KL divergence. The background suppression loss penalizes attention exceeding outside the candidate foreground, averaged across both

Fig. 2: Joint learning of the three-class model and the dual model. The 3-class MIL block is the same as described in Figure 1. Red dotted lines indicate the generation of cHCC-CCA attention heatmaps used to compute the auxiliary loss , comprising union alignment loss , background suppression loss , and foreground-guided complementary loss . The three-class model and both branches of the dual model are trained with classification and attention supervision as described previously.
branches and all blocks:
For cHCC-CCA slides, the dual-branch attention loss combines union alignment, foreground complementarity, and background suppression. The loss and overall joint training objective are defined as:
3. EXPERIMENTS
3.1. Dataset and experimental setup
We used Hematoxylin–Eosin–Safran (HES)-stained WSIs of HCC, CCA, and cHCC-CCA for model training and validation. The dataset comprised 338 HCC slides, 353 CCA slides, and 222 cHCC-CCA slides. Slides were tiled at magnification, and patch-level features were extracted using the UNI2-h foundation model [9], yielding 1536-dimensional embeddings as inputs to the MIL models. The binary CCA–HCC MIL model used to generate reference attention maps was trained for 100 epochs. The three-class MIL model and the jointly trained three-class and dual models were trained for a maximum of 50 epochs, with early stopping triggered when the validation classification loss did not improve for 20 consecutive epochs. For the complementary loss, gradient scaling factors were set to 1.0 and 0.5 for the CCA-like and HCC-like branches, respectively. All models were trained and evaluated using patient-level 10-fold cross-validation, ensuring that slides from the same patient were assigned to the same fold. Only slide-level class labels were used for training and validation. The independent evaluation set comprised 183 WSIs: 72 HCC, 62 CCA, and 49 cHCC-CCA slides. It includes 66 slides from the external TCGA dataset, consisting of 36 HCC and 30 CCA slides.
3.2. Attention-guided three-class model
Table 1 shows the classification performance of the three-class model and the 3-class part of the joint training. The results are the average of 10 folds, generated by the epochs that have the best total loss on the three-class model ( ). The recalls of the dual model are given by the intersection of the predictions of its two branches.
The 3-class model without attention supervision achieved the highest macro F1-score (0.880). Attention supervision slightly reduced this score to 0.872 while improving heatmap plausibility (Table 2), suggesting a trade-off between classification and localization. Joint training partially recovered the macro F1 to 0.876. Although the dual-branch model achieved a lower score (0.834), its main contribution lies in component localization through complementary attention maps.
Table 1: Classification performance of the three-class models (rows 1–3) and the dual-branch model (row 4).
| Model | CCA Recall | HCC Recall | TM Recall | Macro F1 |
|---|---|---|---|---|
| w/o attn. sup. | 0.915 | 0.868 | 0.867 | 0.880 |
| w/ attn. sup. | 0.884 | 0.871 | 0.871 | 0.872 |
| Joint | 0.903 | 0.863 | 0.871 | 0.876 |
| Dual | 0.918 | 0.768 | 0.816 | 0.834 |
Table 2: Attention plausibility on 30 slides per class, without (w/o AS) and with attention supervision (w/ AS). TAC denotes per-slide TAC averaged across the ten fold models.
| Class | TAC | Slides with TAC < 1 | ||
|---|---|---|---|---|
| w/o AS | w/ AS | w/o AS | w/ AS | |
| CCA | 0 | 0 | ||
| HCC | 6 | 0 | ||
Heatmap plausibility is assessed using tumor attention contrast (TAC), the ratio of mean normalized attention inside to outside annotated tumor regions. TAC > 1 indicates preferential tumor attention. Attention supervision increased TAC on 30 CCA and 30 HCC slides (Table 2). Six HCC slides had without supervision, all of which exceeded 1 with supervision. Figure 3 illustrates one such case.
3.3. HCC-like and CCA-like component localization
The dual-branch model is designed to localize and distinguish HCC-like and CCA-like components in cHCC-CCA tumors. We evaluate component selectivity using the CCA/HCC attention ratio for each dual branch and the three-class model:
where denotes the mean normalized attention of the model or branch b within regions annotated as component c. Ratios greater than 1 indicate preferential attention to CCA regions, whereas ratios below 1 indicate preferential attention to HCC regions. Branch 1 is intended to highlight CCA-like

(a) Tumor annotation
(b) w/o supervision
(c) w/ supervision
Fig. 3: HCC slide with annotated tumor regions and attention heatmaps without and with attention supervision.
Table 3: Component selectivity on 15 annotated cHCC-CCA slides, measured by the CCA/HCC attention ratio and averaged across ten fold models.
| Model | CCA/HCC attention ratio |
|---|---|
| Three-class model | 0.677 ± 0.090 |
| CCA-like branch | 2.483 ± 0.873 |
| HCC-like branch | 0.480 ± 0.102 |
components, and branch 2 HCC-like components; the three-class model serves as a reference. For dual model heatmap evaluation, we chose the models with the best total loss from the joint training.
As shown in Table 3, the CCA-like branch assigns higher mean attention to annotated CCA regions, whereas the HCC-like branch shows the opposite preference. The three-class model also favors HCC regions, with a mean CCA/HCC ratio between those of the two branches. These results support distinct, pathologically aligned component preferences in the dual-branch model. Figure 4 shows a comparison of different heatmaps of a cHCC-CCA slide generated by the three-class model, branch 1, and branch 2 in the dual model. Different high attention regions correspond to the annotations.

(a) Annot.
(b) 3-class
(c) CCA-like
(d) HCC-like
Fig. 4: cHCC-CCA slide with (a) annotated tumor regions (CCA in green, HCC in red) and attention heatmaps of (b) 3-class model, (c) branch 1 and (d) branch 2.
4. CONCLUSION
We developed an attention-supervised MIL model for HCC, CCA and cHCC-CCA classification, improving the pathological plausibility of attention heatmaps while maintaining comparable classification performance. The jointly trained dual-branch model generated complementary attention maps with distinct preferences for HCC and CCA-like regions. These maps provide spatial information about tumor composition beyond a slide-level diagnosis, supporting the characterization of intratumoral heterogeneity.
Nevertheless, cHCC-CCA may exhibit distinctive morphology, and individual slides may contain only one recognizable component or regions with ambiguous differentiation. Future work will account for these characteristics and investigate whether component-specific evidence from the dual-branch model can improve three-class classification, linking component localization with slide-level diagnosis.
5. COMPLIANCE WITH ETHICAL STANDARDS
This study was performed in line with the principles of the Declaration of Helsinki. All patients provided written informed consent. Ethical approval was granted by the Institutional Review Board “Comité d’Ethique de la Recherche (CER) Paris Nord” (IRB 00006477 of HUPNVS, Paris 7 University, AP-HP), under approval number CER-2022-169.
6. REFERENCES
[1] Elizabeth Brunt, Shinichi Aishima, Pierre-Alain Clavien, Kathryn Fowler, Zachary Goodman, Gregory Gores, Annette Gouw, Alex Kagen, David Klimstra, Mina Komuta, et al., “chcc-cca: Consensus terminology for primary liver carcinomas with both hepatocytic and cholangiocytic differentiation,” Hepatology, vol. 68, no. 1, pp. 113–126, 2018.
[2] Julien Calderaro, Narmin Ghaffari Laleh, Qinghe Zeng, Pascale Maille, Loetitia Favre, Anaïs Pujals, Christophe Klein, Céline Bazille, Lara R Heij, Arnaud Uguen, et al., “Deep learning-based phenotyping reclassifies combined hepatocellular-cholangiocarcinoma,” Nature communications, vol. 14, no. 1, pp. 8290, 2023.
[3] Aurélie Beaufrère, Nora Ouzir, Paul Emile Zafar, Astrid Laurent-Bellue, Miguel Albuquerque, Gwladys Lubuela, Jules Grégory, Catherine Guettier, Kévin Mondet, Jean-Christophe Pesquet, et al., “Primary liver cancer classification from routine tumour biopsy using weakly supervised deep learning,” JHEP Reports, vol. 6, no. 3, pp. 101008, 2024.
[4] Maximilian Ilse, Jakub Tomczak, and Max Welling, “Attention-based deep multiple instance learning,” in International conference on machine learning. PMLR, 2018, pp. 2127–2136.
[5] Ming Y Lu, Drew FK Williamson, Tiffany Y Chen, Richard J Chen, Matteo Barbieri, and Faisal Mahmood, “Data-efficient and weakly supervised computational pathology on whole-slide images,” Nature biomedical engineering, vol. 5, no. 6, pp. 555–570, 2021.
[6] Zhuchen Shao, Hao Bian, Yang Chen, Yifeng Wang, Jian Zhang, Xiangyang Ji, et al., “Transmil: Transformer based correlated multiple instance learning for whole slide image classification,” Advances in neural information processing systems, vol. 34, pp. 2136–2147, 2021.
[7] Paul Tourniaire, Marius Ilie, Paul Hofman, Nicholas Ayache, and Hervé Delingette, “Ms-clam: Mixed supervision for the classification and localization of tumors in whole slide images,” Medical Image Analysis, vol. 85, pp. 102763, 2023.
[8] Mina Jamshidi Idaji, Julius Hense, Tom Neuhäuser, Augustin Krause, Yanqing Luo, Oliver Eberle, Thomas Schnake, Laure Ciernik, Farnoush Rezaei Jafari, Reza Vahidimajd, et al., “Beyond attention heatmaps: How to get better explanations for multiple instance learning models in histopathology,” Medical Image Analysis, p. 104148, 2026.
[9] Richard J Chen, Tong Ding, Ming Y Lu, Drew FK Williamson, Guillaume Jaume, Bowen Chen, Andrew Zhang, Daniel Shao, Andrew H Song, Muhammad Shaban, et al., “Towards a general-purpose foundation model for computational pathology,” Nature Medicine, 2024.