Introduction
Modern computer vision models, particularly Vision Transformers (ViTs), typically operate as "single-view" specialists, processing images in isolation. However, in complex domains like medical imaging, human experts often resolve ambiguity by consulting reference examples. While Retrieval-Augmented Generation (RAG) has transformed natural language processing, its application to vision has been limited by a reliance on simple visual similarity. This paper introduces Task-Aligned Context Selection (TACS), a framework that moves beyond finding images that look the same to finding images that are specifically helpful for the task at hand.
Methodology
The TACS framework consists of two primary components trained in tandem: a Selector and a Downstream Task Network. The Selector evaluates a query image against a pool of candidates to predict a "utility score" for each. The Task Network (either a classifier or segmentor) then uses both the query and the highest-scoring reference image to produce a final output.
To optimize the selection process, the authors employ a hybrid strategy:
- Differentiable Sampling (Gumbel-Softmax): Enables gradient-based learning by allowing "soft" image selection during training.
- Reinforcement Learning (Policy Gradient): Provides a reward signal based on the actual reduction in task loss achieved by the selected image.
This dual approach ensures the Selector learns to identify images that resolve uncertainty rather than just those that share superficial visual features.
Experimental Setup
The researchers evaluated TACS across a diverse suite of 18 datasets:
- Fine-grained Recognition: 11 datasets including CUB-200 (birds), Stanford Cars, and SUN397 (scenes).
- Medical Classification: 4 datasets covering breast cancer (DDSM), skin lesions (ISIC), colorectal cancer, and retinal disease (APTOS).
- Medical Segmentation: 3 datasets including ISIC-2017, Kvasir-SEG, and DRIVE.
Analysis and Results
TACS consistently outperformed both standard "No-Context" models and traditional similarity-based retrieval methods. In fine-grained classification, TACS achieved an average gain of +1.7% over similarity baselines, with improvements reaching +3.8% on CUB-200. In medical contexts, it provided a +1.3% AUC improvement on the DDSM dataset and boosted Mean IoU by +1.1 on Kvasir-SEG.
A key finding is the principle of complementarity. Statistical analysis (as seen in the figure above) demonstrates that TACS often selects "cross-class" examples. By picking an image from a different category that shares similar textures, the model learns to distinguish subtle differences, effectively resolving ambiguity through contrast. Visualizations further suggest a division of labor: the Selector identifies global structures, while the Task Network focuses on discriminative details.
Conclusion and Future Work
TACS demonstrates that task-aligned retrieval significantly enhances the performance of vision models, particularly in data-limited or ambiguous scenarios. While currently limited to selecting a single image from a static pool, future research will explore retrieving multiple perspectives and extending the framework to dynamic, open-world environments and multimodal tasks such as video analysis and object detection.
Summary updated