This is a very common and effective strategy in e-commerce and content platforms! You have a good base with your similarity search (relevance based on attributes), and now you want to layer in commercial signals (demand). This is essentially a two-stage ranking process:
- Stage 1: Candidate Generation (Your current similarity search with product attributes + Elasticsearch) - This provides a diverse set of relevant items.
- Stage 2: Re-ranking (Based on demand signals) - This orders the relevant candidates to prioritize those most likely to convert or be popular.
Here's a breakdown of the literature and approaches for re-ranking based on demand signals:
I. Understanding Demand Signals
First, let's define what "demand signals" can entail in this context:
- Sales Data:
- Units Sold: Number of items sold in a given time period (e.g., last 7 days, last 30 days).
- Revenue Generated: Total revenue from an item.
- Velocity: Sales per unit time (e.g., sales per day).
- Recency of Sales: How recently was the item purchased? More recent sales often indicate higher current demand.
- Engagement Data (Implicit Feedback):
- Click-Through Rate (CTR): Number of clicks / Number of impressions.
- Conversion Rate (CVR): Number of purchases / Number of product page views (or clicks).
- Add-to-Cart Rate: Number of add-to-carts / Number of product page views.
- Wishlist Adds:
- Product Page Views: Absolute number of views.
- Inventory & Pricing Data:
- Stock Levels: High stock might mean lower demand (or overstocking), low stock might mean high demand (if it's selling out). Can be used to demote out-of-stock items or boost items with limited stock.
- Price Elasticity / Promotional Lift: How demand changes with price or promotions.
- Returns Data:
- Return Rate: High return rates can be a negative signal, indicating customer dissatisfaction despite initial purchases.
- Ratings & Reviews:
- Average Rating: While not direct demand, high ratings often correlate with higher demand and satisfaction.
- Number of Reviews: Indicates popularity and trust.
- Seasonal/Trend Data:
- Are there external trends influencing demand for certain categories or products? (e.g., summer clothes in summer).
II. Re-ranking Approaches
The approaches range from simple heuristics to complex machine learning models.
1. Heuristic/Rule-Based Re-ranking
- Concept: Simple rules or weighted combinations of the original similarity score and demand signals.
- Methodology:
- Weighted Sum:
Final Score = w1 * Similarity_Score + w2 * Demand_Signal_Score
- You'll need to normalize both scores (e.g., Min-Max scaling, Z-score) so they are on a comparable scale.
- Weights (w1, w2) are determined by domain expertise or A/B testing.
- Boosting/Demoting Rules:
- "If an item is in the top 10% for
units_sold_last_7_days, boost its similarity score by X%."
- "If an item has
inventory_level == 0, demote it significantly or remove it."
- "If
CTR > average CTR, add Y points to the score."
- Cascading: First rank by similarity, then for items with similar similarity scores, break ties by a demand signal (e.g., highest
conversion_rate). Or vice versa.
- Pros: Easy to implement, highly interpretable, fast.
- Cons: Not optimal, requires manual tuning of weights/thresholds, doesn't capture complex interactions between features.
- Literature: Often considered "baseline" approaches in academic papers, but widely used in industry for their simplicity and quick impact.
2. Feature-Based Machine Learning Models
- Concept: Treat the re-ranking problem as a prediction task (e.g., predict the probability of a click or purchase) given a set of features.
- Methodology:
- Features: Combine original similarity scores, various demand signals, product attributes, and potentially user features (if personalized re-ranking is desired).
- Target Variable: A binary outcome (click/no click, purchase/no purchase) or a continuous variable (e.g., predicted conversion rate, estimated sales for next week).
- Models: Logistic Regression, Gradient Boosting Machines (XGBoost, LightGBM, CatBoost), Random Forests, or even simple Neural Networks.
- Training: Train on historical data where you observe user interactions (clicks, purchases) with search results.
- Pros: More sophisticated than heuristics, can learn non-linear relationships, better performance.
- Cons: Requires more data and engineering, less interpretable than simple rules, doesn't directly optimize for ranking metrics (like NDCG).
- Literature: Common in general recommendation systems. Think about papers on predicting CTR or conversion.
3. Learning to Rank (LTR)
- Concept: Specifically designed to optimize the order of items in a list, rather than just predicting a score for each item independently. This is the gold standard for re-ranking problems.
- Methodology:
- Features: All the features from the previous ML approach (similarity score, demand signals, product attributes, query features, user features).
- Labels: User feedback (clicks, purchases, add-to-carts, time spent on page). These are used to infer item relevance. For example, a purchase is a stronger signal than a click, which is stronger than a view.
- Types of LTR Models:
- Point-wise LTR: Predicts a relevance score for each item independently (e.g., treating it as a regression or classification problem to predict a relevance label). Models: RankSVM (can be point-wise), simple regression/classification models.
- Pair-wise LTR: Learns to distinguish between two items, determining which one is more relevant. Models: RankNet, LambdaRank.
- List-wise LTR: Optimizes directly on the entire list of items, considering the global ordering. Models: ListNet, ListMLE, AdaRank, LambdaMART. LambdaMART (often implemented in LightGBM/XGBoost) is one of the most widely used and powerful LTR algorithms in industry.
- Pros: Directly optimizes for ranking quality metrics (NDCG, MRR, Precision@K), handles complex interactions, can incorporate many features.
- Cons: More complex to set up and train, requires a good amount of labeled interaction data, susceptible to exposure bias (items displayed higher get more clicks, even if less relevant). Careful data collection and debiasing techniques are crucial.
- Literature:
- "Learning to Rank for Information Retrieval" by Hang Li (book)
- "From RankNet to LambdaRank to LambdaMART: An Overview" by Christopher J.C. Burges (Microsoft Research) - Explains the progression of these powerful algorithms.
- Many papers from top conferences like KDD, SIGIR, WWW on search and recommendation systems.
4. Multi-Armed Bandits (MAB)
- Concept: Useful for situations where demand signals are highly dynamic or uncertain, and you want to balance exploration (trying new items/strategies) with exploitation (sticking with what's known to work).
- Methodology: Each item (or re-ranking strategy) can be considered an "arm." The system iteratively pulls arms and observes rewards (e.g., clicks, conversions).
- Algorithms: UCB1, Thompson Sampling, Epsilon-Greedy.
- Application: You could use MABs to dynamically adjust the weights (w1, w2) in a heuristic approach, or to determine which version of a re-ranking model to deploy in real-time. It's particularly good for cold-start items or discovering emerging trends.
- Pros: Adaptive, handles uncertainty, good for online learning and cold-start.
- Cons: Can be more complex to set up and monitor, might not be suitable for static, batch-oriented re-ranking.
- Literature: Classic MAB papers, or those applying MABs to online recommendation and search.
5. Reinforcement Learning (RL)
- Concept: An agent learns to make a sequence of decisions (e.g., which item to show next, or the entire re-ranked list) to maximize a long-term reward (e.g., total sales over a user session).
- Methodology: Defines states (user context, query, initial results), actions (re-ranking the list), and rewards (conversion, engagement).
- Pros: Can capture complex sequential interactions and long-term optimization.
- Cons: Extremely complex, requires significant data and computational resources, often overkill for basic re-ranking. More suited for highly personalized, dynamic recommendation environments.
- Literature: Deep Q-Networks (DQN), Policy Gradient methods applied to recommendation systems.
III. Key Considerations & Challenges
- Data Quality and Availability: Accurate and timely demand signals are critical. Ensure robust tracking of impressions, clicks, conversions, etc.
- Exposure Bias: Items displayed higher (due to initial similarity ranking or previous re-ranking strategies) naturally get more clicks. This can create a positive feedback loop that biases your demand signals. LTR models, especially, need careful handling of this bias (e.g., using position bias mitigation techniques, inverse propensity weighting).
- Cold Start Problem: New products have no historical demand data. Strategies:
- Initially rely more heavily on similarity.
- Boost new items for a limited period to gather data (exploration).
- Leverage attributes of similar successful products.
- Sparsity: Many products might have very low or zero demand.
- Recency vs. Volume: A product with 10 sales yesterday might be more "in-demand" than a product with 100 sales last month. Incorporate decay functions or time-weighted averages.
- Seasonality & Trends: Demand signals can fluctuate significantly. Consider rolling averages, year-over-year comparisons, or specific models for seasonality.
- Multi-Objective Optimization: Beyond demand, you might have other business goals (e.g., maximize margin, promote specific categories, ensure diversity, avoid showing irrelevant items even if popular). LTR models can be extended to handle multi-objective optimization, or you can add post-processing steps.
- Offline vs. Online Evaluation:
- Offline: Use metrics like NDCG@K, MRR, Precision@K on historical data.
- Online: A/B testing is crucial. Deploy your re-ranking strategy to a subset of users and measure actual business impact (conversion rate, revenue per session, user engagement).
IV. Recommendation for your path
Given your current setup, here's a suggested progression:
-
Start Simple (Heuristics):
- Identify your top 2-3 most impactful demand signals (e.g.,
last_7_day_sales_velocity, conversion_rate_last_30_days).
- Implement a simple weighted sum:
Final_Score = w_similarity * Similarity_Score + w_demand * Demand_Signal_Score.
- A/B test different weights. This provides immediate value and helps you understand the impact of demand signals.
- Consider adding explicit rules for out-of-stock items.
-
Move to Feature-Based ML / Basic LTR:
- Once you have good data collection, migrate to a more sophisticated model.
- Gather all relevant features (similarity score, various demand signals, product attributes, query features).
- Train a LambdaMART model (e.g., using LightGBM) as an LTR approach. This will directly optimize for ranking quality based on historical user interactions (clicks, purchases).
- This is generally the sweet spot for many large-scale e-commerce re-ranking systems.
-
Advanced (Bandits / RL):
- Consider these if you have very dynamic environments, significant cold-start issues, or complex long-term optimization goals that simpler LTR doesn't fully address. These are typically later-stage optimizations.
The literature on "Learning to Rank" is your best friend here, as it directly addresses how to combine various relevance signals (like your initial similarity score) with other business signals (like demand) to produce an optimal ranking.