arXiv:2610.10335cs.CVOct 2026

Manuscript Offprint

arXiv:2610.10335

When to Unpair: Regulating Pairing Dependence in Medical Visual In-Context Learning

Cheng Wan, Chenjun Li, Qingyu Zhao

ABSTRACT

Visual in-context learning (ICL), well suited to label-scarce medical imaging, uses support image–label pairs to demonstrate input–output mappings, while the labels collectively indicate the requested task. We diagnose dependence on individual pairings with a test-time derangement that reassigns every support label to another support image while preserving the query, support images, and label multiset. The resulting pairing gap, defined as shuffled-minus-matched performance, shows that all four released models depend on the pairing, to widely varying degrees. Further analysis of a paired-trained model reveals support-associated spurious regions and lesion-size biases even with real, unaltered supports, alongside sensitivity to mis-registered support labels. To regulate this dependence, we introduce a late unpairing curriculum (LUC), which starts with matched training and then applies random unpairing, replacing each support label with that of another support in the same episode. LUC nearly closes the pairing gap on two backbones while maintaining or improving matched-support performance across all evaluated task types, with gains extending to held-out tasks and cross-dataset episodes. It also mitigates these failure modes. On BraTS whole-tumor segmentation, matched-support DSC rises from 0.733 to 0.857 while the gap shrinks from -0.184 to -0.008. In a released model, brief fine-tuning with random unpairing reduces the gap. A reversed curriculum that places the same number of unpairing epochs at the start of training leaves a large gap. This shows that pairing dependence is shaped by the order of training and not only by the amount of unpaired training.

1 INTRODUCTION

(a) the support set

Figure

(b) the same query under four support sets

(c) BraTS whole tumor

pairing gap (DSC)

matched-support DSC (higher is better)

Figure 1: Which label sits on which support image changes the prediction. (a) Grey: every support image keeps its own label; red: a derangement, which moves each label onto another image and leaves the label multiset unchanged. (b) One BraTS validation case at K=4 with matched supports and three derangements; beside each row are the support set that model trains on and its schedule p(e)p(e). Green outlines the ground truth; numbers are DSC. (c) Pairing gap and matched-support DSC over the BraTS whole-tumor evaluation.

In-context learning (ICL) lets a single model solve a new task from a few examples, with no task-specific retraining (Brown et al., 2020). In its visual form the model receives a query image and a few support (image, label) pairs and returns a dense prediction, such as a segmentation or an image in another modality (Bar et al., 2022; Wang et al., 2023a;b; Kim et al., 2023). This suits medical imaging, where dense labels are scarce and expensive, and medical ICL models now cover 2D and 3D segmentation and image-to-image tasks (Butoi et al., 2023; Czolbe & Dalca, 2023; Rakic et al., 2024; Hu et al., 2025; 2026).

An underexplored question in ICL is how models use the supports to infer the task. Support pairs provide task-relevant information in complementary ways. A model can use the image–label correspondence within individual support pairs to infer how inputs map to outputs, while the collection of support labels can indicate what output is requested. For example, support masks can collectively distinguish whole-tumor from edema segmentation, while their pairing with individual images provides example-specific mappings between image appearance and label. Both sources can be informative, but how current visual ICL models balance them, and how strongly their predictions depend on individual image–label pairings, remains poorly understood.

We study this behavior through a test-time derangement that selectively disrupts individual image–label correspondence. Specifically, we preserve the query image, all support images, and the same set of support labels, but reassign each label to a different support image, which gives shuffled supports (Figure 1). Comparing performance under matched and shuffled supports yields a pairing gap, which quantifies a model's dependence on individual support pairings while holding the contents of the support set fixed. In doing so, we find substantial variation in pairing dependence across existing visual ICL models (Table 1) and show that strong dependence can have undesirable consequences. In medical image segmentation, for example, the predicted lesion extent and location can be influenced by the size and spatial position of lesions in the support labels (Section 4).

Building on this diagnostic, we find that training-time random unpairing can regulate how models use support pairing. Replacing support labels during training with those of other supports in the same episode weakens the reliability of individual image–label correspondence, while the labels, taken together, still indicate which output is requested. The timing of this intervention matters: a late unpairing curriculum (LUC), which unpairs only after an initial period of conventional paired training, substantially reduces test-time pairing dependence. This robustness comes without a trade-off in standard predictive performance: LUC maintains or improves performance under correctly matched supports across all evaluated task types. It also mitigates several failure modes associated with excessive dependence on individual support pairs. Together, the test-time derangement and training-time unpairing form a strategy for diagnosing and controlling pairing dependence in visual ICL: the former reveals how a trained model uses support correspondence, and the latter reshapes that behavior without changing the model architecture or giving up matched-support performance.

Our contributions are:

• A test-time derangement of the support labels as a black-box diagnostic of pairing dependence, and the finding that this dependence varies widely across four released visual in-context learners (Section 4).

  • The failure modes of strong dependence in paired training: the prediction follows the support labels rather than the query, with real support sets and under controlled perturbations of the labels, and loses accuracy when the support labels are mis-registered (Section 4).

• LUC, a schedule for random unpairing that substantially reduces pairing dependence while maintaining or improving matched-support performance on five task types and two backbones, and that also reduces these failure modes (Section 5). The timing matters: with the same number of unpairing epochs, the schedule that ends on matched supports keeps a large gap. On a released model, 1000 fine-tuning steps of random unpairing shrink the edema gap from -0.353 to -0.036.

References (78)