STIR: Siamese Transformer for Image Retrieval Postprocessing

Aleksei Shabanov, Aleksei Tarasov, Sergey I. Nikolenko

TL;DR

Researchers have introduced STIR (Siamese Transformer for Image Retrieval), a postprocessing method that achieves state-of-the-art results by looking at images side-by-side. By using a Transformer to attend to pixel-level details between a query and its top candidates, STIR corrects "blind" retrieval errors made by standard embedding-based models.

What Problem Does This Paper Address?

In traditional image retrieval, a model converts an image into a single vector (an embedding). To find similar items, you simply look for the closest vectors in a database. However, this "global" approach has a weakness: the model must represent the image "blindly," without knowing which specific features will be important for a future comparison.

Recent "State of the Art" (SOTA) methods have tried to fix this by using complex math, like mapping images into hyperbolic spaces. While effective, these are often a nightmare to deploy in production environments. The authors of STIR argue that we don't need fancy geometry; we need a better way to look at the top few results.

Methods

The paper proposes a two-stage approach:

  1. ViT-Triplet (The Baseline): The authors first show that a standard Vision Transformer (ViT) fine-tuned with a classic triplet loss and "hard negative mining" (training on the most difficult examples) is actually much stronger than previously thought. It matches or beats many complex recent models just by being well-implemented.
  2. STIR (The Reranker): This is the core innovation. Instead of just comparing two pre-computed vectors, STIR takes the query image and a candidate image, concatenates them into one large image, and feeds them into a ViT.
  3. Cross-Attention: Because the images are processed together, the Transformer’s attention mechanism can directly compare patches of the query image with patches of the candidate image.
  4. Binary Classification: A small MLP head on top predicts the probability that the pair is a "negative" (a mismatch).

Because STIR is computationally "heavy," it isn't used to search the whole database. Instead, it acts as a "refiner" that reranks only the top 5 or 10 results returned by the faster baseline model.

Datasets

The authors evaluated their approach on two industry-standard benchmarks:

  • Stanford Online Products (SOP): 120,053 images of 22,634 products.
  • DeepFashion In-shop Clothes Retrieval: 52,712 high-quality images of 7,982 clothing items.

Key Insights and Ideas

  • Simplicity Wins: One of the most striking findings is that a well-tuned "simple" ViT with triplet loss (ViT-Triplet) is a formidable baseline that often outperforms specialized, complex architectures.
  • The Power of "Looking Twice": Global embeddings lose local detail. By allowing the model to perform pixel-level comparisons via cross-attention during the reranking phase, the model can spot subtle differences (like a pattern on a shirt or the cut of a sleeve) that a single vector might smooth over.
  • Saturation at the Top: The authors observed that for many models, the correct answer is almost always in the top 5 results, even if it isn't at rank #1. This justifies using a "heavyweight" model like STIR for just the very top of the list—it’s a high-impact, low-volume task.

Key Results

STIR set a new state-of-the-art on both major datasets:

  • In-Shop: STIR achieved a 95.0% Recall@1, significantly outperforming the previous best of 92.7% (HypViT).
  • SOP: STIR reached 88.3% Recall@1, beating the previous SOTA of 86.0%.
  • Efficiency: By reranking only the top $n=5$ results, STIR provides a massive accuracy boost with a manageable computational overhead compared to running a full-pair comparison across an entire database.

Limitations and Future Work

  • Computational Cost: STIR is "heavyweight." Because it uses a standard ViT, the complexity is quadratic relative to the image size. The authors suggest that future versions could use Swin Transformers (which have linear complexity) to speed things up.
  • Feature Reuse: Currently, STIR processes the raw pixels of the concatenated images. The authors note that a more efficient version might reuse intermediate features from the first-stage retrieval model rather than starting from scratch.
  • Dataset Ambiguity: The authors noted that in some cases, the "ground truth" in datasets is ambiguous (e.g., a query shows a whole outfit, but the label only cares about the shirt). Improving how models handle these multi-object queries is a noted direction for the field.

Summary updated

BibTeX
@inproceedings{shabanov2024stir,
  author = {Aleksei Shabanov and Aleksei Tarasov and Sergey I. Nikolenko},
  title = {{STIR: Siamese Transformer for Image Retrieval Postprocessing}},
  booktitle = {ACM International Conference on Information and Knowledge Management},
  year = {2024},
  doi = {10.1145/3627673.3680075},
}
Figure