Abstract
In-context learning (ICL) has revolutionized natural language processing, allowing models to adapt to new tasks via prompting without parameter updates. However, computer vision has largely remained reliant on the "pretrain-then-finetune" paradigm, particularly for dense prediction tasks like semantic segmentation and depth estimation. This paper introduces Hummingbird, a framework that enables in-context scene understanding by replacing task-specific decoders with a non-parametric nearest-neighbor retrieval mechanism. By utilizing contextual pretraining and spatial attention pooling, Hummingbird achieves performance competitive with fine-tuned specialists while offering superior data efficiency and near-instant task adaptation.
1. Introduction
The current standard for dense scene understanding involves training heavy, task-specific decoder heads on top of pretrained backbones. While effective, this approach is rigid; adapting a model to a new label space or a different modality (e.g., switching from segmentation to depth) requires significant computational resources and time-consuming gradient-based optimization.
In contrast, Large Language Models (LLMs) demonstrate the ability to perform new tasks simply by observing a few examples in their input context. Hummingbird aims to bring this "Hummingbird moment" to computer vision. By treating dense prediction as a retrieval problem, the model can perform complex visual tasks on the fly, using a set of annotated images as a "visual prompt."
2. Methodology
Hummingbird departs from the traditional architectural design by eliminating the learned decoder. Instead, it relies on a three-part framework: the visual prompt, the retrieval mechanism, and contextualized representations.
2.1 The Visual Prompt as Context
In this framework, the "prompt" consists of a small collection of images paired with their corresponding ground-truth labels (e.g., segmentation masks or depth maps). These images serve as the reference memory for the model during inference.
2.2 Nearest Neighbor Retrieval
To predict labels for a new query image, the model computes dense feature representations for every image patch. It then performs a similarity search against the features stored in the prompt memory bank. The final prediction for a query patch is an aggregation of the labels associated with its most similar neighbors in the feature space. This non-parametric approach ensures that the model's underlying parameters remain unchanged regardless of the task.
2.3 Contextual Pretraining
Standard Vision Transformers (ViTs) are typically trained to process images in isolation. To make features "retrieval-ready," the authors introduced Contextual Pretraining. During this phase, the model is forced to attend to features across different images within a memory bank. Combined with Spatial Attention Pooling, this allows the model to learn distinctive, discriminative features that are highly effective for cross-image matching.
3. Experimental Results
The researchers evaluated Hummingbird across several benchmarks, including PASCAL VOC and ADE20K for semantic segmentation, and NYUv2 for monocular depth estimation. The models were pretrained on ImageNet-1k and ImageNet-22k.
3.1 Performance and Scaling
Hummingbird demonstrates impressive scaling properties. Moving from ImageNet-1k to the larger ImageNet-22k dataset resulted in significant gains in retrieval accuracy. On the PASCAL VOC benchmark, a Hummingbird model using a ViT-L backbone achieved 77.3 mIoU. This result is particularly notable as it approaches the performance of state-of-the-art specialists that have been fully finetuned on the task, despite Hummingbird using only retrieval.
3.2 Efficiency and Adaptation Speed
One of the most significant advantages of the retrieval-based approach is the speed of adaptation. While traditional finetuning might require 3 hours of GPU time to reach peak performance on a specific dataset, Hummingbird can reach comparable levels in just 3 minutes—the time required to populate its feature memory bank. This represents a 60x speedup in task deployment.
3.3 Low-Data Regime
Hummingbird excels in scenarios where labeled data is scarce. When limited to only 100 labeled examples, the retrieval-based mechanism significantly outperforms standard end-to-end finetuning, which often overfits or fails to converge with such small datasets.
4. Discussion and Limitations
While Hummingbird represents a significant step toward universal in-context vision models, several challenges remain:
- The Few-Shot Gap: Although efficient with 100 examples, the model does not yet match the extreme few-shot (1-5 examples) capabilities seen in modern LLMs.
- Spatial Constraints: The current implementation assumes a degree of spatial correspondence between features and labels. Tasks involving significant geometric transformations (like heavy rotation) may require more robust matching mechanisms.
- Task Expansion: The current study focuses on segmentation and depth. Future work is needed to extend this retrieval-based interface to object detection and more complex 3D geometric tasks.
5. Conclusion
Hummingbird demonstrates that task-specific decoders are not a prerequisite for high-performance scene understanding. By leveraging contextual pretraining and a simple nearest-neighbor retrieval interface, the model achieves a level of flexibility previously unseen in computer vision. This work paves the way for interactive visual assistants capable of learning and executing new dense prediction tasks instantly through visual prompting.
Summary updated