Skip to main content
QUICK REVIEW

[Paper Review] Learning Embeddings for Product Visual Search with Triplet Loss and Online Sampling

Eric Dodds, Huy Nguyen|arXiv (Cornell University)|Oct 10, 2018
Domain Adaptation and Few-Shot LearningComputer Science4 citations
TL;DR

This paper proposes a triplet loss-based deep metric learning approach with online batch-hard sampling for product visual search, significantly outperforming prior state-of-the-art on the DeepFashion dataset and achieving competitive results on Stanford Online Products by modifying sampling to favor within-category minibatches. The method improves generalization by including intra-domain image pairs during training.

ABSTRACT

In this paper, we propose learning an embedding function for content-based image retrieval within the e-commerce domain using the triplet loss and an online sampling method that constructs triplets from within a minibatch. We compare our method to several strong baselines as well as recent works on the DeepFashion and Stanford Online Product datasets. Our approach significantly outperforms the state-of-the-art on the DeepFashion dataset. With a modification to favor sampling minibatches from a single product category, the same approach demonstrates competitive results when compared to the state-of-the-art for the Stanford Online Products dataset.

Motivation & Objective

  • To improve content-based image retrieval in e-commerce by learning a robust embedding function for product images using deep metric learning.
  • To address the challenge of inefficient triplet sampling in large-scale visual search by proposing an online sampling strategy that dynamically selects hard negatives within mini-batches.
  • To evaluate the effectiveness of the proposed method on two major benchmark datasets: DeepFashion and Stanford Online Products, under varying sampling strategies.
  • To investigate whether including intra-domain image pairs (e.g., consumer-consumer or shop-shop) during training improves model generalization beyond cross-domain comparisons.
  • To analyze when and why within-class minibatch sampling improves performance, particularly on datasets where class separation is already strong.

Proposed method

  • Trains a ResNet-50-v2 backbone pre-trained on ImageNet, fine-tuned with triplet loss to embed query and catalog images into a shared metric space.
  • Employs a modified 'batch-hard' sampling strategy: for each anchor in a minibatch, the negative sample is the most similar positive from another pair in the same batch.
  • Uses cosine similarity between embeddings as the retrieval metric: $ s(x,y) = \frac{f(x) \cdot f(y)}{||f(x)|| ||f(y)||} $.
  • Applies standard triplet loss with margin $ m = 0.1 $: $ \mathcal{L}_{\text{triplet}} = \frac{1}{|T|} \sum_{(a,p,n) \in T} [s(a,n) - s(a,p) + m]_+ $.
  • Introduces a variant sampling strategy that forms minibatches predominantly from images of the same product category to improve gradient signal on easier datasets.
  • Performs ablation studies comparing training with only cross-domain pairs vs. including all matched pairs (including intra-domain) to assess data efficiency gains.

Experimental results

Research questions

  • RQ1Does online batch-hard triplet sampling with within-mini-batch negative selection significantly improve retrieval performance on product visual search benchmarks?
  • RQ2Can including intra-domain image pairs (e.g., consumer-consumer or shop-shop) during training improve model generalization beyond the standard cross-domain setup?
  • RQ3How does the performance of the proposed sampling strategy vary across datasets with different levels of domain shift and class separability, such as DeepFashion and Stanford Online Products?
  • RQ4What is the impact of batch size and sampling strategy on the fraction of non-zero loss triplets and model convergence?
  • RQ5In what scenarios is within-class minibatch sampling more effective than standard batch-hard sampling?

Key findings

  • The proposed method achieves a new state-of-the-art performance on the DeepFashion Consumer-to-Shop Clothes Retrieval benchmark, significantly outperforming prior work.
  • Including all matched pairs—especially intra-domain pairs (consumer-consumer and shop-shop)—during training leads to a measurable performance gain on DeepFashion, suggesting that dataset size and diversity are key.
  • On the Stanford Online Products dataset, the modified sampling strategy favoring within-category minibatches increases the fraction of non-zero loss triplets by up to 20 percentage points, improving model signal quality.
  • The method achieves competitive results on Stanford Online Products, matching or nearing state-of-the-art performance, particularly when combined with larger batch sizes (optimal around 48 pairs).
  • Small batch sizes (e.g., below 32 pairs) lead to poor performance due to insufficient gradient signal, but performance saturates beyond batch size 48, indicating diminishing returns.
  • The within-class sampling strategy is more effective on easier datasets like Stanford Online Products, where class separation is strong, suggesting it helps refine hard negatives when easy negatives are already well-separated.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.