algo-ecom-ranking

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

E-Commerce Product Ranking

电商产品排序

Overview

概述

E-commerce ranking combines text relevance (BM25) with commercial signals (CTR, conversion rate, revenue, margin) into a unified ranking score. Uses learning-to-rank (LTR) models trained on click and conversion data to optimize for business-relevant outcomes.
电商排序将文本相关性(BM25)与商业信号(CTR、转化率、营收、利润率)整合为统一的排序得分。使用基于点击和转化数据训练的学习排序(LTR)模型,优化与业务相关的结果。

When to Use

使用场景

Trigger conditions:
  • Building a product search/browse ranking beyond pure text relevance
  • Incorporating business metrics (margin, inventory) into ranking
  • Implementing a learning-to-rank pipeline
When NOT to use:
  • For pure text search relevance only (use BM25)
  • When no click/conversion data exists (start with rule-based ranking)
触发条件:
  • 构建超越纯文本相关性的产品搜索/浏览排序系统
  • 将业务指标(利润率、库存)纳入排序逻辑
  • 实现学习排序(LTR)流程
不适用于:
  • 仅需纯文本搜索相关性的场景(使用BM25即可)
  • 无点击/转化数据的场景(先从规则排序入手)

Algorithm

算法

IRON LAW: Relevance Is Necessary But NOT Sufficient for E-Commerce Ranking
A result that is textually relevant but has zero sales history, no
reviews, and is out of stock serves no one. E-commerce ranking must
balance: relevance (does it match the query?), quality (is it a good
product?), and commercial value (does it generate revenue?).
铁律:相关性是电商排序的必要条件,但绝非充分条件
一个文本相关但无销售历史、无评价且缺货的产品对任何人都毫无价值。电商排序必须平衡三点:相关性(是否匹配查询?)、质量(是否为优质产品?)和商业价值(是否能产生营收?)。

Phase 1: Input Validation

阶段1:输入验证

Collect features per product-query pair: text relevance score (BM25), historical CTR, conversion rate, average rating, review count, price competitiveness, inventory level, margin. Gate: Minimum features available, click data from 30+ days.
收集每个产品-查询对的特征:文本相关性得分(BM25)、历史CTR、转化率、平均评分、评价数量、价格竞争力、库存水平、利润率。 准入条件: 具备最低限度的特征,拥有30天以上的点击数据。

Phase 2: Core Algorithm

阶段2:核心算法

Rule-based baseline: Score = w₁×relevance + w₂×popularity + w₃×rating + w₄×recency. Manually tune weights.
LTR approach:
  1. Generate training data from click logs (clicked = positive, skipped = negative, with position debiasing)
  2. Features: text match, behavioral (CTR, add-to-cart rate), product quality (rating, reviews), freshness, price
  3. Train: LambdaMART or gradient-boosted ranking model optimizing NDCG
  4. Blend: final_score = α × LTR_score + (1-α) × business_boost
规则基准方案: 得分 = w₁×相关性 + w₂×流行度 + w₃×评分 + w₄×新鲜度。手动调整权重。
LTR方案:
  1. 从点击日志生成训练数据(点击=正样本,跳过=负样本,同时进行位置偏差校正)
  2. 特征:文本匹配度、行为数据(CTR、加购率)、产品质量(评分、评价)、新鲜度、价格
  3. 训练:使用LambdaMART或梯度提升排序模型,优化NDCG指标
  4. 融合:最终得分 = α × LTR得分 + (1-α) × 商业增益

Phase 3: Verification

阶段3:验证

Evaluate offline: NDCG@10, MRR. A/B test online: revenue per search, click-through rate, conversion rate. Gate: NDCG improves over baseline, A/B test positive on primary metric.
离线评估:NDCG@10、MRR。在线A/B测试:每搜索营收、点击率、转化率。 准入条件: NDCG优于基准方案,A/B测试在核心指标上呈现正向结果。

Phase 4: Output

阶段4:输出

Return ranked product list with score decomposition.
返回带有得分分解的产品排序列表。

Output Format

输出格式

json
{
  "results": [{"product_id": "P123", "rank": 1, "final_score": 0.92, "components": {"relevance": 0.85, "popularity": 0.95, "quality": 0.90}}],
  "metadata": {"query": "wireless earbuds", "model": "lambdamart", "ndcg_at_10": 0.72}
}
json
{
  "results": [{"product_id": "P123", "rank": 1, "final_score": 0.92, "components": {"relevance": 0.85, "popularity": 0.95, "quality": 0.90}}],
  "metadata": {"query": "wireless earbuds", "model": "lambdamart", "ndcg_at_10": 0.72}
}

Examples

示例

Sample I/O

输入输出示例

Input: Query "laptop", 500 matching products Expected: Top results balance text match + high conversion + good ratings, not just keyword relevance.
输入: 查询“笔记本电脑”,匹配到500个产品 预期结果: 顶部结果平衡文本匹配度、高转化率和良好评分,而非仅依赖关键词相关性。

Edge Cases

边缘场景

InputExpectedWhy
New product, no historyRely on text relevance + category avgCold start — no behavioral signal
Out of stock itemDemote or removeShowing unavailable products frustrates users
Sponsored productBlend ad rank with organicSeparate sponsored from organic clearly
输入预期结果原因
无历史数据的新产品依赖文本相关性 + 品类平均值冷启动场景——无行为信号可用
缺货商品降权或移除展示不可购买的产品会使用户不满
付费推广商品将广告排名与自然排名融合需明确区分付费推广和自然排序结果

Gotchas

注意事项

  • Position bias in training data: Higher-ranked items get more clicks regardless of quality. Debias training data using inverse propensity weighting or randomization experiments.
  • Popularity bias: Without diversity controls, popular items dominate rankings. New or niche products get no exposure. Add exploration bonus.
  • Revenue optimization ≠ user satisfaction: Ranking by margin pushes expensive products up. Users lose trust if results feel commercially manipulated.
  • Feature freshness: Click signals change daily. Retrain or update features frequently. Stale features degrade ranking quality.
  • Category-specific models: A single ranking model may not work across all categories. Electronics ranking differs from fashion ranking.
  • 训练数据中的位置偏差:排名靠前的产品无论质量如何都会获得更多点击。使用逆倾向加权或随机化实验校正训练数据。
  • 流行度偏差:若无多样性控制,热门产品会主导排序结果,新品或小众产品无法获得曝光。需添加探索性增益。
  • 营收优化≠用户满意度:按利润率排序会推高高价产品,若结果明显受商业操纵,用户会失去信任。
  • 特征新鲜度:点击信号每日变化。需频繁重新训练或更新特征,过时特征会降低排序质量。
  • 品类专属模型:单一排序模型可能不适用于所有品类。电子产品排序与时尚品类排序存在差异。

References

参考资料

  • For LambdaMART implementation, see
    references/lambdamart.md
  • For position debiasing techniques, see
    references/position-debiasing.md
  • LambdaMART实现详情,请查看
    references/lambdamart.md
  • 位置偏差校正技术,请查看
    references/position-debiasing.md