Pre-trained vision-language models (VLMs) excel in multimodal tasks, commonly encoding images as embedding vectors for storage in databases and retrieval via approximate nearest neighbor search (ANNS). However, these models struggle with compositional queries and out-of-distribution (OOD) image-text pairs. Inspired by human cognition's ability to learn from minimal examples, we address this performance gap through few-shot learning approaches specifically designed for image retrieval. We introduce the Few-Shot Text-to-Image Retrieval (FSIR) task and its accompanying benchmark dataset, FSIR-BD - the first to explicitly target image retrieval by text accompanied by reference examples, focusing on the challenging compositional and OOD queries. The compositional part is divided to urban scenes and nature species, both in specific situations or with distinctive features. FSIR-BD contains 38,353 images and 303 queries, with 82% comprising the test corpus (averaging per query 37 positives, ground truth matches, and significant number of hard negatives) and 18% forming the few-shot reference corpus (FSR) of exemplar positive and hard negative images. Additionally, we propose two novel retrieval optimization methods leveraging single shot or few shot reference examples in the FSR to improve performance. Both methods are compatible with any pre-trained image encoder, making them applicable to existing large-scale environments. Our experiments demonstrate that: (1) FSIR-BD provides a challenging benchmark for image retrieval; and (2) our optimization methods outperform existing baselines as measured by mean Average Precision (mAP). Further research into FSIR optimization methods will help narrow the gap between machine and human-level understanding, particularly for compositional reasoning from limited examples.
Figures & tables
Figure 1: Example of FSIR-BD. Per query text we have multiple positive and hard-negative images.
Table 1: Analysis of quantitative and benchmarking aspects of FSIR-BD, CIRR and CIRCO datasets.
Prompt learning training employs learnable vectors with positive-negative image pairs to optimize context vectors, establishing an effective decision boundary for 1-way retrieval tasks.
Figure 2: BLIP scores fall within [0.1,0.5]; learnable scaling factors a,b map these to the full BCE range [0,1].
Figure 3: FSIR-CTR training architecture. The reference image plus text query are input to the MLLM, which fuse them and align the result to the external image encoder’s embedding space.
Figure 4: Query text plus reference image vs. target images from FSIR-TD.
VG
INQUIRE
OOD
Average
BLIP-L
41
28.2
15
28
BLIP-L PL
45.9
33
32.9
37.3
FSIR-CTR-Phi-3.5-BLIP-L
40.8
29.2
24.6
31.5
CLIP-L
25.9
34.5
27.7
29.4
CLIP-L PL
28.3
42.7
48.6
39.9
FSIR-CTR-Phi-3.5-CLIP-L
29.7
33
28.2
30.3
Table 2: mAP retrieval performance on FSIR-BD. Values in italic represent baseline performance for each image encoder, while values in bold indicate the results of best model performance and values in underline indicate the second best results.
Baseline
1
2
4
8
16
Compositional-VG
41
34.4
37.1
41.7
43.1
45.9
Compositional-Inquire
28.2
24.9
25.9
27.3
28.8
33
OOD
15
18.7
19.9
21
22.5
32.9
Table 3: mAP retrieval performance on FSIR-BD for different number of shots for BLIP-L PL. Values in italic represent baseline performance for each image encoder, values in underline indicate higher than baseline results, while values in bold indicate the results of best model performance.
Figure 5: Example pf FSIR-BD-Compositional-VG data. Per text query we provide multiple positive images and negative images.
Figure 6: Example pf FSIR-BD-Compositional-Inquire data. Per text query we provide multiple positive images and negative images.
Figure 7: Example pf FSIR-BD-OOD data. Per text query we provide multiple positive images and negative images.
Semantic aspect
FSIR
CIRR
CIRCO
Examples
Attributes
49.8%
63.0%
“blond girl or woman on a wooden bench”, “red brick building with signage”, “female beautiful demoiselle”, “male Northern Elephant Seal”.
Actions
17.8%
47.0%
“adults play with children”, “pedestrian crossing a street near park”, “macaques engaging in mutual grooming behavior”, “Dolphins performing acrobatics”.
Spatial relationships
20.5%
61.4%
45.7%
“adult and child on staircase or platform or escalator”, “bus next to blue or red sign”, “bike chained illegally to a street lamp post or traffic sign but not to fence”, “grebe with babies on its back”.
Conjunctions (and, with…)
23.4%
43.7%
75.1%
“man and woman both wearing glasses”, “dark shirt and backpack on man in park”, “Male Blue-black Grassquit in patchy blue-black and brown plumage”
Disjunctions (or, either)
10.6%
14.0%
“adult and child on staircase or platform or escalator”, “window with curtains that are not red or yellow”
Negations
6.6%
11.9%
12.2%
“bike chained illegally … but not to fence”, “pedestrians … with a car that is not white”, “red brick residential building without emergency ladder”, “Caribou without palmate antlers”.
Table 4: Analysis of semantic aspects covered by FSIR-BD, CIRR and CIRCO datasets, with examples from the FSIR-BD.
Figure 8: Example of FSIR-TD. Per query text we have multiple positive and hard-negative images.
VG
INQUIRE
OOD
Average
BLIP-L
41
28.2
15
28
Phi-3.5-E5V
31.4
28.6
28.6
29.5
FSIR-CTR-Phi-3.5-BLIP-L
40.8
29.2
24.6
31.5
Table 5: mAP retrieval performance on FSIR-BD. Values in italic represent baseline performance for each image encoder, while values in bold indicate the results of best model performance and values in underline indicate the second best results.
Louis Vuitton · Inria, École normale supérieure, CNRS, PSL Research University · Courant Institute of Mathematical Sciences and Center for Data Science, New York University