SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Attention-based multiple instance learning
ABMIL [3] first introduced the attention mech
anism for MIL to an interpretation of importance for instances. Building on this, DSMIL [9] used contrastive learning for feature extraction and established global connections between instance attention. TransMIL [5] took this a step further and developed a correlated MIL, employing multi-head self-attention and spatial information encoding for thorough global correlation. CLAM [4] extends ABMIL to the case of multiple classes and builds an integrated toolbox for visualizing the uncertainty. DTFD-MIL [23] proposes a two-stage feature distillation MIL framework for enhancing the performance. Bayes-MIL [11] studies the fundamental interpretability problem in the attention based MIL framework and proposed to address it with a probabilistic method. In our RAM-MIL, the attention weight is utilized as a measure of the probability density, indicating the amount of "mass" being moved from the source bag to the target bag. Greater attention weights in RAM-MIL indicate more significant relationships between instances in the bags being compared.
Domain adaptation for medical imaging There have been a large volume of research studying the domain adaptation in medical imaging [24, 25, 26]. However, most of the preceding studies on whole slide images domain generalization have primarily focused on instance-level classification [27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39], rather than tackling the more complex challenge of weakly-supervised bag-level classification (MIL). In contrast, our approach seeks to address this more complex problem of unsupervised domain adaptation for MIL. We review these methods in details and make extensive comparisons in the supplemental.
Retrieval method for whole slide images Recent works also study how to efficiently retrieve relative WSI from database. Yottixel [40] builds a search engine for indexing WSI's at scale. SISH [41] uses a tree structure for fast search of WSI followed by an uncertainty-based ranking algorithm for retrieval. In experiment, we integrate the open-sourced SISH as a search engine into our RAM-MIL pipeline for comparisons (See supplemental). HHOT [42] proposes to use optimal transport (OT) as a distance measure to compare different WSI's, or different WSI datasets. Our paper, focusing on classification tasks, studies the principle why OT is suitable for WSI classification and propose a retrieval-based classification process. We compare RAM-MIL and HHOT in our experiments.
The proposed methodology is evaluated on whole slide image (WSI) datasets (Camelyon16 [43, 13], Camelyon17 [12], TCGA-NSCLC, CPTAC-UCEC and CPTAC-LSCC) and general MIL datasets (See results in supplemental). The evaluation is divided into in-domain and UDA settings. For the in-domain setting, the retrieval set  $\mathcal{H}_r$  is the union of training and validation set of  $\mathcal{H}_o$ . For the UDA setting, the retrieval set is a held-out dataset with no labels involved in training or inference.
Table 1: Results on CAMELYON16 and CAMELYON17 for in-domain classification and unsupervised domain adaptation, for comparisons with related methods.
In-Domain (CAM16)	Out-of-Domain (CAM17)
AUC	Accuracy	AUC	Accuracy
ABMIL	0.9010±0.026	0.8750±0.020	0.7287±0.035	0.7190±0.049
DSMIL	0.8944±0.051	0.8682±0.060	-	-
CLAM	0.9177±0.044	0.8650±0.060	0.7613±0.054	0.7214±0.044
TransMIL	0.9307±0.024	0.8837±0.041	0.5697±0.118	0.6451±0.100
Bayes-MIL	0.9432±0.049	0.8875±0.052	0.7839±0.044	0.7435±0.058
HHOT-kNN (k=1)	0.7007±0.035	0.7318±0.051	0.6939±0.076	0.7173±0.061
HHOT-kNN (k=3)	0.7618±0.026	0.7544±0.055	0.7263±0.048	0.7523±0.076
Mixup Retr1	0.9260±0.051	0.8825±0.051	-	-
Mixup RetrIO	0.9271±0.048	0.8850±0.046	0.7658±0.052	0.7594±0.044
Mixup Retro	0.9271±0.045	0.8825±0.048	0.7641±0.056	0.7593±0.058
l2 Retr1	0.9281±0.047	0.8800±0.055	-	-
l2 RetrIO	0.9241±0.048	0.8950±0.048	0.7627±0.055	0.7353±0.051
l2 Retro	0.9398±0.045	0.8950±0.055	0.7738±0.050	0.7493±0.050
RAM-MIL Retr1	0.9451±0.036	0.8925±0.050	-	-
RAM-MIL RetrIO	0.9365±0.052	0.9200±0.050	0.7974±0.054	0.7433±0.073
RAM-MIL Retro	0.9419±0.048	0.9175±0.051	0.7681±0.058	0.7795±0.021
We compare our OT-based retrieval with Euclidean distance retrieval, Hausdorff distance retrieval and Manifold MixUp as baselines. The Euclidean  $(l_{2}$  norm) distance  $d_{l_2}(\cdot ,\cdot)$  and Hausdorff distance based retrieval are implemented in the following ways:
- Direct bag representation retrieval. As a baseline method, we propose an approach to augment bag features by directly retrieving the nearest neighbor. The setup follows the initial steps of Algo. 1, from line 1 to line 3. Instead of computing the instance correlations, we directly compute the  $l_{2}$  distance between bag representations, formulated as  $d_{l_2}(\pmb{H}_n,\tilde{\pmb{H}}_m) = ||\pmb {z}_n - \tilde{\pmb{z}}_m||_2^2$ . For the  $n$ -th bag representation, we select the nearest neighbor from the retrieval set:  $\tilde{H}_{m^{*}} = \arg \min_{\tilde{H}_{m}\in \mathcal{H}_{r}}d_{l_{2}}(\pmb{H}_{n},\tilde{\pmb{H}}_{m})$ . The merged bag representation  $\hat{z}_n = \pi (\pmb {z}_n,\pmb {z}_{m^*})$  is subsequently employed for bag classification, where  $m^{*} = \mathrm{getIndex}(\tilde{H}_{m^{*}})$ .
- Approximate OT retrieval. Recall that prior to applying the Sinkhorn's algorithm to solve OT, it is necessary to compute the cost matrix  $C = [c(\pmb{h}_i, \tilde{\pmb{h}}_j)]_{ij} = \| \pmb{h}_i - \tilde{\pmb{h}}_j \|_2^2$ , where each element is the squared  $l_2$  distance between instance representations. To highlight the significance of solving the OT problem, we introduce three simple approximations of OT by directly employing the minimum, average and maximum values of the cost matrix. The  $d_{\mathrm{Cmin}}(\pmb{H}_n, \tilde{\pmb{H}}_m) = \min_{ij} [c(\pmb{h}_i, \tilde{\pmb{h}}_j)]_{ij}$  focuses on the closest and most similar instances between bags. The  $d_{\mathrm{Cavg}}(\pmb{H}_n, \tilde{\pmb{H}}_m) = \mathrm{average}_{ij} [c(\pmb{h}_i, \tilde{\pmb{h}}_j)]_{ij}$  offers a holistic measure of bag similarity but might lose some finer details. The  $d_{\mathrm{Cmax}}(\pmb{H}_n, \tilde{\pmb{H}}_m) = \max_{ij} [c(\pmb{h}_i, \tilde{\pmb{h}}_j)]_{ij}$  focuses on the most dissimilar instances between the two bags. These three measures can be considered as OT approximations that use information from the squared  $l_2$  cost matrix.
- Hausdorff distance retrieval. The symmetric Hausdorff distance is employed for retrieval, computed as  $d_{\mathrm{H}}(\pmb{H}_n,\tilde{\pmb{H}}_m) = \max \{d_{\mathrm{h}}(\pmb{H}_n,\tilde{\pmb{H}}_m),d_{\mathrm{h}}(\tilde{\pmb{H}}_m,\pmb{H}_n)\}$ . Here,  $d_{\mathrm{h}}(\pmb{H}_n,\tilde{\pmb{H}}_m) = \max_{\pmb{h}_i\in \pmb{H}_n}\min_{\tilde{\pmb{h}}_j\in \tilde{\pmb{H}}_m}\| \pmb{h}_i - \tilde{\pmb{h}}_j\| _2^2$  is the directed Hausdorff distance. The Hausdorff distance is an appropriate retrieval metric when assessing the maximum dissimilarity between two sets, emphasizing the instances that differ the most between the sets. In comparison, OT provides a more comprehensive and versatile choice for retrieval tasks, given its ability to consider all possible matchings between elements in the sets and finds an optimal one.
5.1 Classification of Whole Slide Image
**Experimental setup:** In this section, we validate the methodology within both in-domain and out-of-domain contexts. In both contexts, the training set is from Camelyon16. In the in-domain setting, we evaluate our models using the Camelyon16 dataset, where the combination of training and validation sets is treated as  $\mathcal{D}_r$ , which is denoted as  $\text{Retr}_l$ . For the out-of-domain context, we use Camelyon16 as  $\mathcal{D}_o$ . As for  $\mathcal{D}_r$ , we consider two configurations: 1) retrieval from the training and validation sets of both Camelyon16 and Camelyon17, and 2) retrieval solely from the training
Table 2: Results on CPTAC-UCEC in domain classification, domain adaptation from CPTAC-LSCC to CPTAC-UCEC.
In Domain	Out-of-Domain
AUC	Accuracy	AUC	Accuracy
CLAM	0.9500	0.9285	0.4986	0.6521
RAM-MIL	0.9667	0.9382	0.6056	0.6526
Table 3: Results on TCGA-NSCLC (subtyping).
Method	AUC	Accuracy
CLAM	0.9420	0.8640
Scaling ViT	0.9516	0.8821
TransMIL	0.9603	0.8835
Bayes-MIL	0.9451	0.8965
RAM-MIL	0.9457	0.8988
Table 4: Tumor stage classification results on CAMELYON17.
Method	AUC	Accuracy
CLAM	0.7803	0.60
Bayes-MIL	0.8070	0.64
RAM-MIL	0.8139	0.65
and validation sets of Camelyon17, referred to as  $\text{Retr}_{IO}$  and  $\text{Retr}_{O}$ , respectively. In the Camelyon17 challenge, each slide is labeled as either isolated tumour cells (ITC), micro-met, macro-met, or negative. ITC are strictly defined as single tumor cells or clusters smaller than  $0.2 \, \text{mm}$  or less than 200 cells [44]. Following the principles of MIL, we treated ITC as the positive class. More results about treating ITC as the negative class are shown in the supplemental. To ensure robustness and avoid the influence of outliers, each experiment is executed 10 times on randomly partitioned train/validation/test sets.
The baseline model we use for comparison is CLAM, an extension of attention-based Multiple Instance Learning (MIL) that incorporates an instance clustering loss. In our case, the pre-trained model is a CLAM model for binary classification. We also make comparisons with other models such as ABMIL, DSMIL, TransMIL, Bayes-MIL, HHOT, and Mixup. For the ablation study, we add our proposed  $l_{2}$  retrieval method with direct bag representation retrieval. For both the Mixup and  $l_{2}$  retrieval models, we ensure that the source of the augmented data aligns with our in-domain and out-of-domain settings. For the OT-based pathology work, HHOT focuses on comparing whole slide images using uniform weight-based OT and employs kNN as a discriminative method. Note that Mixup and our proposed methods use CLAM as the MIL method. Furthermore, Mixup shares the same merging function with our retrieval method, which is a simple addition or a convex combination, in the reported experiments. Our method does not need the ground-truth label information for retrieval set while Mixup uses that for the in-domain experiments. More results about the merging function is shown in the supplemental.
When we compute the RAM-MIL, we often deal with very large WSIs that can contain over 100,000 instances. This makes the calculation of OT time-consuming. To speed things up, we first perform pre-selection of potentially important instances. Instead of using all the instances in a bag  $\mathcal{H}_n$ , we pick the top  $20\%$  of instances based on their attention scores and normalized the attention scores. We provide more detailed comparisons in percentage of instances used, in the supplemental. In this way, we are focusing on the most important instances and making the whole process more efficient.
In-domain comparisons: Table 1 presents the in-domain results. Simply using a uniform weight-based Optimal Transport (OT) in HHOT-KNN fails to deliver satisfactory performance. Mixup,  $l_{2}$  retrieval, and RAM-MIL all enhance the classification performance for in-domain data beyond the CLAM baseline. The straightforward  $l_{2}$  retrieval-based MIL outpaces Mixup, demonstrating that selecting the nearest neighbor using a basic metric offers superior augmentation compared to random data selection. Using OT as a distance metric, the retrieval-based MIL method surpasses all the other compared methods for the in-domain dataset. Notably, the  $\mathrm{Retr}_{\mathrm{IO}}$  configuration, which employs the most extensive data set for retrieval (CAMELYON16 and CAMELYON17), offers the most significant boost in in-domain classification accuracy. Table 2 shows RAM-MIL consistently presents higher AUC and accuracy on CPTAC-UCEC. We also explore the performance of subtypes classification in Table 3, showing that RAM-MIL outperforms existing methods in accuracy, while providing AUC higher than the CLAM baseline. Compared with the results on tumor stage classification, our method enhances the model performance as shown in Table 4.
Out-of-domain comparisons: The right-hand side of Table 1 showcases the results for the out-of-domain setting. Notably, all retrieval methods, including ours, enhance the classification performance
Table 5: Ablation study evaluated on CAMELYON16 and CAMELYON17.
In-Domain (CAM16)	Out-of-Domain (CAM17)
AUC	Accuracy	AUC	Accuracy
Approx-OT-min Retri1	0.9301±0.033	0.8800±0.043	-	-
Approx-OT-min RetriIO	0.8601±0.080	0.8000±0.062	0.7640±0.058	0.7353±0.043
Approx-OT-min Retro	0.9196±0.063	0.8750±0.056	0.7680±0.065	0.7274±0.046
Approx-OT-avg Retri1	0.9227±0.038	0.8600±0.036	-	-
Approx-OT-avg RetriIO	0.8865±0.063	0.8425±0.061	0.7625±0.060	0.7174±0.041
Approx-OT-avg Retro	0.9195±0.063	0.8750±0.056	0.7641±0.054	0.7374±0.061
Approx-OT-max Retri1	0.9174±0.049	0.8625±0.044	-	-
Approx-OT-max RetriIO	0.9182±0.047	0.8650±0.048	0.7576±0.060	0.7214±0.062
Approx-OT-max Retro	0.9195±0.063	0.8750±0.056	0.7681±0.065	0.7414±0.038
l2 Retri1	0.9281±0.047	0.8800±0.055	-	-
l2 RetriIO	0.9241±0.048	0.8950±0.048	0.7627±0.055	0.7353±0.051
l2 RetriO	0.9398±0.045	0.8950±0.055	0.7738±0.050	0.7493±0.050
Hausdorff Retri1	0.9273±0.057	0.8850±0.049	-	-
Hausdorff RetriIO	0.9226±0.055	0.8725±0.060	0.7651±0.054	0.7434±0.051
Hausdorff Retro	0.9322±0.046	0.8950±0.048	0.7695±0.056	0.7513±0.051
RAM-MIL Retri1	0.9451±0.036	0.8925±0.050	-	-
RAM-MIL RetriIO	0.9365±0.052	0.9200±0.050	0.7974±0.054	0.7433±0.073
RAM-MIL RetriO	0.9419±0.048	0.9175±0.051	0.7681±0.058	0.7795±0.021
for out-of-domain data, without accessing its labels. This suggests that retrieval benefits from the transfer of representative information from the source to the target domain via the merging of bag features. The  $l_{2}$  retrieval, while trailing Mixup in terms of accuracy, surpasses it in terms of AUC. Our OT-based retrieval achieves the highest performance across both AUC and accuracy metrics. Table 2 presents the results on domain adaptation from CPTAC-UCEC to CPTAC-LSCC. RAM-MIL demonstrates a notable improvement of 0.1065 in AUC compared to CLAM. The underlying reason for the good performance might be it could consider all possible matchings between elements in the sets and finds an optimal one.
Ablation study Table 5 presents the ablation study using different retrieval methods, which shows that even  $l_{2}$  retrieval, which operates without considering instance-level distances, surpasses the performance of the three OT approximation methods in both in-domain and out-of-domain settings. Among these, only the Approx-OT-min, when used for in-domain data retrieval, achieves a performance comparable to that of  $l_{2}$  retrieval. This underscores the fact that relying on simple statistics of the cost matrix cannot provide a robust and consistent approximation of the optimal transport. This outcome reinforces the necessity of solving the complete optimal transport problem, using Sinkhorn's algorithm, to attain reliable results.
5.2 Dimensionality Reduction
We next show that retrieval-based methods can effectively reduce the intrinsic dimension. Figure 3 shows the intrinsic dimension for various methods. The proposed RAM-MIL based on optimal transport delivers the lowest intrinsic dimension, among all methods, both retrieval and vanilla models. Interestingly, Mixup seems to increase the intrinsic dimension, suggesting that random selection and merging of bag representations do not necessarily lead to a more compact representation. This could explain why Mixup only offers marginal improvements.
Figure 3 shows that while the CLAM model has an intrinsic dimension between 5-7, RAM-MIL achieves a dimension between 2-4. Based on these observations, we choose dimension 5 to guide manual dimensionality reduction. The objectives of this exercise are two-fold: firstly, to validate that intrinsic dimension can accurately explain performance, and secondly, to illustrate that simple methods like SVD are not necessarily beneficial for dimensionality reduction of bag representations.
In our experiment, we employ SVD to reduce each bag representation of CLAM and each merged bag representation of RAM-MIL to a 5-dimensional vector. Then, we use these vectors and the bag labels to train a single logistic regression classifier. The results indicate that RAM-MIL significantly outperforms CLAM in classification accuracy. This experiment shows that a simple dimensionality reduction method like SVD does not significantly improve the performance of the CLAM baseline.
Table 6: Classification on CAMELYON16 with bag representations of reduced dimensions (5-dim).
In-Domain (CAM16)	Out-of-Domain (CAM17)
AUC	Accuracy	AUC	Accuracy
CLAM	0.9216±0.057	0.6625±0.177	0.7486±0.040	0.4991±0.105
RAM-MIL	0.9273±0.072	0.8475±0.157	0.7509±0.074	0.7053±0.113
However, RAM-MIL, which organizes the latent space by merging nearest neighbor features and then applies SVD, can achieve a commendable performance.
5.3 Interpretability with OT for MIL
We show that by using optimal transport retrieval, a novel method for highlighting the important instances could be derived. For a pair of source bag  $H$  and target bag  $\tilde{H}$ , solving the optimal transport problem generates the transport matrix  $T = [T_{ij}]_{ij}$ . Suppose that we are interested in the instance labels of the source bag, and suppose that the instance labels of the target bag are known. The positive instances in the source bag are simply the instances transported to the positive instances in the target bag, i.e.,  $\hat{y}_i = \tilde{y}_{j^* = \arg \max_j T_{ij}}$ . Here,  $\hat{y}$  is the predicted instance label for the source bag, and  $\tilde{y}$  is the true instance label in the target bag. Figure 4 shows this method could provide a good coverage of the positive area, without model training or accessing the bag label. In contrast to OT, retrieval-based methods utilizing other distance metrics do not possess this specific property.
Precision: 0.7530  
FROC: 0.4964
Precision: 0.7222  
FROC: 0.7303
Figure 4: The visualization of predicted positive instances (red regions) in whole slide images for RAM-MIL. FROC is defined as the average sensitivity (recall) at 6 predefined false positive (FP) rates:  $1/4$ ,  $1/2$ ,  $1$ ,  $2$ ,  $4$  and  $8$  FPs. For reference, the averaged precision and FROC in Bayes-MIL [11] (one of the SOTA method designed for instance-level performance) are 0.8107 and 0.4919.
In this work, we investigate the out-of-domain performance of multiple instance learning model, which is crucial for the ML-assisted medical diagnosis with the whole slide images. An optimal transport based retrieval method is proposed based on the understanding that there exists a negative correlation between MIL performance and input data dimension. The proposed RAM-MIL framework works for both in-domain and out-of-domain, meanwhile outperforms state-of-the-art MIL methods. We hypothesize that OT-based retrieval could reduce the intrinsic dimension therefore improves the MIL performance and validate the hypothesis by computing the intrinsic dimension of bag representations. The transportation matrix of OT distance provides a tool to visualize the correspondence between original and retrieval instances and makes our retrieval method interpretable. A limitation is the efficiency of optimal transport solver is constrained by the number of instances within a bag. Although we have mitigated this problem by selecting partial instances based on high attention values, we anticipate that a more principled method will be sought in future works.
This work was supported by a grant from the Research Grants Council of the Hong Kong Special Administrative Region, China (Project No. CityU 11215820), and a grant from Guangzhou Bingli Technology Co., Ltd.
[47] Stuart Andrews, Ioannis Tsochantaridis, and Thomas Hofmann. Support vector machines for multiple-instance learning. Advances in neural information processing systems, 15, 2002.
[48] Yuchen Yang, Amir Akbarnejad, Nilanjan Ray, and Gilbert Bigras. Double adversarial domain adaptation for whole-slide-imageclassification. In Medical Imaging with Deep Learning, 2021.
Proof. Since the bag of instances  $\mathbf{X}$  is sampled from the probability distribution  $\mu(\mathbf{x})$ , we have the upper bound for Wasserstein distance between  $\mathbf{X}$  and  $\mu$  [45],
$$
\mathbb {E} \left[ \mathcal {W} _ {p} (\boldsymbol {X}, \mu) \right] \leq K ^ {- \frac {1}{d _ {\mu}}}, \tag {6}
$$
where  $K$  is the number of samples. Next we define the function  $\sigma(\pmb{x})$  as a small perturbation function  $\sigma(\pmb{x}) = \pmb{x} + \pmb{\delta}$  and let  $\tilde{\pmb{X}} = \{\sigma(\pmb{x}) : \pmb{x} \in \pmb{X}\}$ . Using the triangle inequality, we have
$$
\mathbb {E} \left[ \mathcal {W} _ {p} (\boldsymbol {X}, \tilde {\boldsymbol {X}}) \right] \leq \mathbb {E} \left[ \mathcal {W} _ {p} (\boldsymbol {X}, \mu) \right] + \mathbb {E} \left[ \mathcal {W} _ {p} (\tilde {\boldsymbol {X}}, \mu) \right] \leq 2 K ^ {- \frac {1}{d _ {\mu}}} + C, \tag {7}
$$
where  $C$  is a constant as a result of the perturbation. As the function  $S(\cdot)$  is Lipschitz continuous, we have
$$
\left| S (\boldsymbol {X}) - S \left(\tilde {\boldsymbol {X}}\right) \right| \leq L \cdot \mathbb {E} \left[ \mathcal {W} _ {p} \left(\boldsymbol {X}, \tilde {\boldsymbol {X}}\right) \right] \leq O \left(L \cdot K ^ {- \frac {1}{d _ {\mu}}}\right). \tag {8}
$$
Similar to TransMIL [5], let  $\Phi : \mathcal{X} \to \mathbb{R}^n$  be any invertible map, where its inverse mapping is expressed as  $\Phi^{-1} : \mathbb{R}^d \to \mathcal{X}$ . Then we have:
$$
S \left(\Phi^ {- 1} \left(\Phi_ {\boldsymbol {X} \in \mathcal {X}} \left(\{\sigma (\boldsymbol {x}): \boldsymbol {x} \in \boldsymbol {X} \}\right)\right)\right) = S \left(\Phi^ {- 1} \left(\Phi_ {\tilde {\boldsymbol {X}} \in \mathcal {X}} (\tilde {\boldsymbol {X}})\right)\right) = S (\tilde {\boldsymbol {X}}). \tag {9}
$$
Let  $\gamma = S\circ \Phi^{-1}$ . As  $|S(\pmb {X}) - S(\tilde{\pmb{X}})|\leq O(L\cdot K^{-\frac{1}{d_{\mu}}})$ , we have
$$
\left| S (\boldsymbol {X}) - \gamma \left(\Phi_ {\boldsymbol {X} \in \mathcal {X}} \left\{\sigma (\boldsymbol {x}): \boldsymbol {x} \in \boldsymbol {X} \right\}\right) \right| \leq O \left(L \cdot K ^ {- \frac {1}{d _ {\mu}}}\right). \tag {10}
$$
In this proof, the transformation  $\Phi(\cdot) = \mathcal{A}(\cdot)$ . This proof could be easily extended to the representations  $\pmb{H}$  by assuming a probability measure over the instance representations  $\pmb{h}$  and replacing  $\pmb{X}$  with  $\pmb{H}$ . In this case, the transformation  $\Phi(\pmb{H}) = \sum_{k=1}^{K} a_k \pmb{h}_k$ .
Table 7: Results on general MIL datasets. Experiments were run 5 times and the average classification accuracy (± a standard error of a mean) is reported.
Method	MUSK1	MUSK2	FOX	TIGER	ELEPHANT
Attention	0.892±0.090	0.858±0.106	0.615±0.096	0.839±0.054	0.868±0.054
Attention-Gated	0.900±0.088	0.863±0.094	0.603±0.068	0.845±0.046	0.857±0.064
CLAM	0.900±0.136	0.860±0.128	0.610±0.128	0.805±0.052	0.860±0.080
RAM-MIL	0.911±0.130	0.870±0.142	0.645±0.117	0.820±0.040	0.879±0.096
B General MIL dataset
Table 7 presents the performance of RAM-MIL on general MIL datasets [46, 47], offering a comparison with baseline methods. The results indicate that OT-based retrieval generally enhances the classification performance. The sole exception is observed with the TIGER dataset, where both CLAM and RAM-MIL are outperformed. This discrepancy might be attributed to CLAM, as RAM-MIL uses CLAM as a pretrained model for attention weights and bag representation extraction. Nonetheless, RAM-MIL still improves over its CLAM baseline on TIGER. Note that our primary focus lies on the more challenging WSI datasets, hence our models are not extensively optimized for general datasets. The data in these general datasets are typically of lower dimensionality and present less challenging conditions. Therefore, any potential underperformance in these contexts should not detract from the strength of our models in handling the WSI data.
C Experiment Details of WSI Classification
We present the experimental details, ablation studies and analysis step-by-step.