Skip to main content

Reranking in practice

We discussed how reranking can improve product recommendations. Now, let's see how reranking affects our jeans recommendations for the customer inquiry "I'm looking for women's jeans for a summer party."

All images/dataset used throughout this guide are from: Aggarwal, P. (2022). Fashion Product Images (Small). Available online: https://www.kaggle.com/datasets/paramaggarwal/fashion-product-images-dataset

Reranking and hybrid search

To demonstrate the difference, we’ll examine how reranking affects both our optimized data and hybrid search queries.

You can use reranking with or without hybrid search.

The actual reranking

To perform reranking, we add an additional step: We feed the jeans recommendations received from the vector database through an additional LLM, asking it to rerank the results based on relevance and deeper semantic understanding.

Recap

Before comparing the reranked recommendations, let's revisit the top 5 recommendations we received from our vector database with hybrid search on optimized data:

Search Adjustment: 0.50

  • Lee Men Blue Party Jeans
    Lee Men Blue Party Jeans
    Rank: 1
  • Jealous 21 Women's Blue Jegging
    Jealous 21 Women's Blue Jegging
    Rank: 2
  • Peter England Men Blue Party Jeans
    Peter England Men Blue Party Jeans
    Rank: 3
  • Peter England Men Navy Blue Party Jeans
    Peter England Men Navy Blue Party Jeans
    Rank: 4
  • Peter England Men Party Blue Jeans
    Peter England Men Party Blue Jeans
    Rank: 5
  • Flying Machine Men Blue Slim Fit Mid-Rise Clean Look Jeans
    Flying Machine Men Blue Slim Fit Mid-Rise Clean Look Jeans
    Rank: 1
  • John Players Men Blue Slim Fit Low-Rise Clean Look Stretchable Jeans
    John Players Men Blue Slim Fit Low-Rise Clean Look Stretchable Jeans
    Rank: 2
  • Lee Men Blue Party Jeans
    Lee Men Blue Party Jeans
    Rank: 3
  • Jealous 21 Women's Blue Jegging
    Jealous 21 Women's Blue Jegging
    Rank: 4
  • Peter England Men Party Blue Jeans
    Peter England Men Party Blue Jeans
    Rank: 5
  • Lee Men Blue Party Jeans
    Lee Men Blue Party Jeans
    Rank: 1
  • Jealous 21 Women's Blue Jegging
    Jealous 21 Women's Blue Jegging
    Rank: 2
  • ONLY Women Peach Jeans
    ONLY Women Peach Jeans
    Rank: 3
  • Lee Women Mid Stone Blue Maxi Fit Jeans
    Lee Women Mid Stone Blue Maxi Fit Jeans
    Rank: 4
  • ONLY Women Blue Jeans
    ONLY Women Blue Jeans
    Rank: 5

The top row represents text vectors, the middle row shows image-only vectors, and the last row displays text and image vectors.

The slider starts at 0.5, representing a balance between keyword and semantic search. Initially, we see a mix of dark men's jeans. As we slide towards a higher semantic search weight (right side), more light-colored women's jeans appear.

Reranked Data

Now, let's look at the same data after applying our reranking LLM:

Search Adjustment: 0.50

  • ONLY Women Blue Jeans
    ONLY Women Blue Jeans
    Rank: 1
  • ONLY Women Blue Jeans
    ONLY Women Blue Jeans
    Rank: 2
  • Denizen Women Blue Jeans
    Denizen Women Blue Jeans
    Rank: 3
  • Denizen Women Blue Jeans
    Denizen Women Blue Jeans
    Rank: 4
  • Denizen Women Blue Jeans
    Denizen Women Blue Jeans
    Rank: 5
  • Spykar Women Washed Blue Jeans
    Spykar Women Washed Blue Jeans
    Rank: 1
  • Spykar Women Ep Jeans Blue Jeans
    Spykar Women Ep Jeans Blue Jeans
    Rank: 2
  • Lee Women Mid Stone Blue Maxi Fit Jeans
    Lee Women Mid Stone Blue Maxi Fit Jeans
    Rank: 3
  • Lee Women SS Blue Jeans
    Lee Women SS Blue Jeans
    Rank: 4
  • Puma Women Blue Jeans
    Puma Women Blue Jeans
    Rank: 5
  • Lee Women Mid Stone Blue Maxi Fit Jeans
    Lee Women Mid Stone Blue Maxi Fit Jeans
    Rank: 1
  • Lee Womens Blue Maxi Fit Jeans
    Lee Womens Blue Maxi Fit Jeans
    Rank: 2
  • Lee Womens Blue Jeans
    Lee Womens Blue Jeans
    Rank: 3
  • ONLY Women Peach Jeans
    ONLY Women Peach Jeans
    Rank: 4
  • ONLY Women Blue Jeans
    ONLY Women Blue Jeans
    Rank: 5

Observations

By comparing the pre-and post-reranking results, we can see significant improvements in relevance:

  • Text Vectors
    Reranking aligns the recommendations more closely with the customer inquiry, reducing the appearance of irrelevant items
  • Image Vectors
    The reranked results better match the desired characteristics, such as color and style
  • Text and Image Vectors
    The combined approach benefits the most, as reranking refines the selection to ensure a more accurate and contextually relevant list of recommendations

Conclusion

Reranking enhances the effectiveness of hybrid search by leveraging the deep semantic understanding of LLMs. This ensures that the final product recommendations are not only similar but also contextually aligned with the customer's needs and preferences.

Summary

We've walked through various techniques including data examination, vectorization, hybrid search, and reranking. Each step has demonstrated how AI and LLMs can be utilized to improve product recommendations significantly.

Now that we have a comprehensive understanding of these methods and have seen their impact on our jeans dataset, let's explore the playground where you can apply all these techniques interactively.