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
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 JeansRank: 1
- Jealous 21 Women's Blue JeggingRank: 2
- Peter England Men Blue Party JeansRank: 3
- Peter England Men Navy Blue Party JeansRank: 4
- Peter England Men Party Blue JeansRank: 5
- Flying Machine Men Blue Slim Fit Mid-Rise Clean Look JeansRank: 1
- John Players Men Blue Slim Fit Low-Rise Clean Look Stretchable JeansRank: 2
- Lee Men Blue Party JeansRank: 3
- Jealous 21 Women's Blue JeggingRank: 4
- Peter England Men Party Blue JeansRank: 5
- Lee Men Blue Party JeansRank: 1
- Jealous 21 Women's Blue JeggingRank: 2
- ONLY Women Peach JeansRank: 3
- Lee Women Mid Stone Blue Maxi Fit JeansRank: 4
- ONLY Women Blue JeansRank: 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 JeansRank: 1
- ONLY Women Blue JeansRank: 2
- Denizen Women Blue JeansRank: 3
- Denizen Women Blue JeansRank: 4
- Denizen Women Blue JeansRank: 5
- Spykar Women Washed Blue JeansRank: 1
- Spykar Women Ep Jeans Blue JeansRank: 2
- Lee Women Mid Stone Blue Maxi Fit JeansRank: 3
- Lee Women SS Blue JeansRank: 4
- Puma Women Blue JeansRank: 5
- Lee Women Mid Stone Blue Maxi Fit JeansRank: 1
- Lee Womens Blue Maxi Fit JeansRank: 2
- Lee Womens Blue JeansRank: 3
- ONLY Women Peach JeansRank: 4
- ONLY Women Blue JeansRank: 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.