An Online Algorithm for Large Scale Image Similarity Learning

Gal Chechik, Uri Shalit, Varun Sharma, Samy Bengio

Introduction

Learning how "similar" two objects are is a cornerstone of machine learning, essential for tasks ranging from image search and video recommendation to kernel-based classification. However, traditional metric learning—which often involves learning a Mahalanobis distance—faces a major scalability wall.

The OASIS (Online Algorithm for Scalable Image Similarity learning) algorithm addresses this bottleneck. Designed to learn semantic image similarity from massive datasets, OASIS abandons traditional metric constraints like symmetry and positive semi-definiteness during training. As a result, it achieves state-of-the-art precision while operating orders of magnitude faster than previous methods.

The Scalability Bottleneck in Metric Learning

Most existing metric learning methods require the learned similarity matrix to be positive semi-definite (PSD). Enforcing this constraint is computationally expensive, often scaling quadratically with the number of samples. Consequently, these methods struggle to move beyond small benchmarks to the "web-scale" reality of millions of images.

Furthermore, many traditional models focus strictly on visual similarity, whereas users typically care about semantic similarity—for example, recognizing that two different-looking breeds of dogs are more "similar" than a fluffy dog and a mop.

The OASIS Methodology

The authors introduce OASIS, which overcomes these limitations through three key design choices:

  1. Bilinear Similarity: Instead of enforcing a strict distance metric, OASIS uses a bilinear form $S_W(p_i, p_j) = p_i^T W p_j$. Crucially, the algorithm does not initially require the matrix $W$ to be symmetric or positive definite, removing the most significant computational bottleneck.
  2. Online Passive-Aggressive Learning: OASIS learns from "triplets" ($p_i, p_i^+, p_i^-$), where an image $p_i$ is known to be more relevant to $p_i^+$ than to $p_i^-$. The algorithm uses a large-margin criterion (hinge loss). If the similarity gap between the positive and negative pair isn't large enough, it performs a minimal update to $W$ to satisfy the constraint.
  3. Exploiting Sparsity: By representing images using sparse "bags of visual words," the computational cost of an update depends only on the number of non-zero features ($O(k_i k_j)$), rather than the total dimensionality of the feature space.

Datasets and Evaluation

The authors evaluated OASIS across two distinct scales:

  • Web-Scale Dataset: 2.7 million images scraped from Google Image Search. Relevance was determined by anonymized user click data (images co-clicked for the same query were deemed similar).
  • Caltech-256: A standard machine vision benchmark containing approximately 30,000 images across 256 categories. This was used to compare OASIS against traditional small-scale metric learning methods like LMNN and MCML.

Key Insights and Results

Massive Scalability

OASIS scales linearly with the number of training samples. In the study, it successfully trained on 2.3 million images in about 3 days on a single CPU. In stark contrast, competing methods like LMNN scale quadratically and would take an estimated 190 days to process the same volume of data.

Precision and Semantic Inference

On the Caltech-256 benchmark, OASIS consistently outperformed state-of-the-art methods (MCML, LMNN, LEGO) across various class sizes (10, 20, and 50 classes). Because the model learns from user behavior (clicks) on the web-scale dataset, it successfully captures high-level concepts. Human evaluators found that 35% of the top-10 neighbors returned by OASIS were semantically relevant—a remarkably high mark for such a massive, noisy search space.

The Burden of Constraints

The authors argue that in the large-scale regime, enforcing PSD constraints during every step of learning is not only slow but potentially detrimental. Early in training, the signal is noisy; forcing the model into a strict metric space too early can lead to poor generalization. Interestingly, even without enforcing symmetry, the learned matrix $W$ often converges to a nearly symmetric state naturally. If a true metric (PSD matrix) is strictly required for a downstream task, the authors found it is better to learn an unconstrained similarity first and then project the final result onto the PSD cone once as a post-processing step.

Limitations and Future Work

While OASIS presents a massive leap in training efficiency, the authors note a few areas for future exploration:

  • Class-Independent Model: OASIS currently learns a single global similarity matrix. Developing class-dependent models (learning different similarities for different types of objects) might improve precision further.
  • Retrieval Speed: While OASIS makes training fast, searching through millions of images during inference remains challenging. Techniques like Locality-Sensitive Hashing (LSH) would be necessary to deploy the learned model in a real-time production environment.
  • Transfer Learning: There is significant potential to explore how well a model trained on a large, diverse dataset generalizes to entirely new, unseen categories of images.

Summary updated

BibTeX
@inproceedings{chechik2009online,
  author = {Gal Chechik and Uri Shalit and Varun Sharma and Samy Bengio},
  title = {{An Online Algorithm for Large Scale Image Similarity Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2009},
}
Figure