0%

COLD- Towards the Next Generation of Pre-Ranking System

COLD (Computing power cost-aware Online and Lightweight Deep pre-ranking system).

abstract

长久以来觉得pre-ranking是ranking模型的简化版本,因此花了很大力气去做ranking model的简化版本。比如广告系统的的双塔,只有user-wise和ad-wise的点积,缺乏user-ad的特征交叉。

重新思考pre-ranking,从algorithm-system联合设计(algorithm-system co-design)的视角; 以前:

graph LR
    限制模型结构-->节省计算资源;

现在:f(pre-ranking model, computing power it costs).具有以下优点:

  • 在可控算力成本约束下,在COLD中可以应用任意交叉特征的深度模型;
  • 通过应用优化技巧进行推理加速,计算能力成本显着降低,进一步为COLD应用更深模型以达到更好性能打开了空间;
  • COLD可以online learing and serving,能更好地处理data distribution shift问题。提高模型迭代和A/B testing效率。

自从2019年,几乎应用在阿里巴巴所有的广告系统中。

introduction

搜索引擎、推荐系统、在线广告,大多数都是级联架构。

graph LR
    matching-->pre-ranking;
    pre-ranking-->ranking;
    ranking-->reranking;
  • pre-ranking: 几千几万条,10-20ms
  • ranking:几百条,10-20ms

从模型的视角看pre-ranking system的历史:

  1. click/impr,高频更新
  2. LR
  3. 双塔,相比前2代有巨大提升,但仍有空间
    1. 模型表达能力受vector-product form的限制
    2. 模型更新频率,embedding需离线预计算,难以适应data di stribution shift(比如双11)
  4. COLD

前3代pre-ranking system遵循同一个范式:算力是个常数。而COLD将算力作为变量,灵活控制model performance和算力之间的权衡。

双塔结构的缺点:

  • 模型表达能力受限,无法表达user-ad cross features
  • 需要预先计算好向量,耗时长,实时性不好,无法适应data distribution shift
  • user/ad的向量索引必须同时更新,同时切换,实践中很难达到,切换会有延迟

双塔结构过于追求减少算力要求了。

COLD主要2点优化:

  • 模型结构更灵活,能够在算力和模型性能间做trade-off
  • 工程优化技巧

第一点优化如何达成:

  • 简言之,需要生成一个大模型的轻量版,常见方法是:
    • network pruning
    • feature selection
    • neural architecture search
  • 本文选用feature selection
    • 具体方法是SE(Squeeze-and-Excitation) block
    • Importance weight calculation
      • \(s=\sigma(\matrix{W}[e_1,\dots,e_m]+b)\)
      • \(s\in \mathbb{R}^{M}, \matrix{W\in \mathbb{R}^{k\times M}},b\in \mathbb{R}^M\)
      • \(e_i\)是第i个feature group的embedding,\(s_i\)是第i个feature group的重要性权重
    • Feature group selection
      • 根据vector \(s\) 代表了每个feature group的重要性
      • 选取top \(K\)的feature group
        • 启发式选择\(K\): 离线测试\(K\)个feature group的指标(如GAUC)

第二点优化如何达成:

  • Parallelism at All Level
    • 尽可能并行化
  • Column based Computation
    • 传统上,特征的计算时“row-based”的,比如广告是一条一条广告计算所有特征
      • 这种方法not cache-friendly
    • 本文提出"column-based"的方法:同一个feature column的计算一起计算,利用SIMD (Single Instruction Multiple Data)来进行加速(利用数据并行)
  • Low precision GPU calculaton
    • 对于COLD模型,大部分时间都是稠密矩阵的运算
    • Float16的理论FLOPS峰值是Float32里的8倍
      • 但是由于sum pooling操作,数值可能超过Float16的表示,解决方案
        • 方案一:引入normalization(比如batch-norm),但BN-layer的moving-variance方差可能更大,因此需要mix-precision优化:
          • fully-connected layers使用Float16
          • Batch-norm使用Float32
        • 方案二:使用parameter-free的normalization layer
          • 考虑log变换
          • \[ \begin{equation} linear\_log(x)=\left\{ \begin{array}{lr} -\log(-x)-1, &x<-1 \\ x, & -1\leq x\leq 1.\\ \log(x)+1, & x>1 \end{array} \right. \end{equation} \]
          • \(linear\_log()\)函数可以把Float32映射到合理的区间,把它放到第一层,可以保证网络的输入变小,实践中把它加上,网络仍然可以达到原始模型的accuracy
    • 使用Float16之后
      • CUDA kernel的running time大幅下降
      • kernel的launching time成为瓶颈
        • 进一步使用MPS(Multi-Process Service)来减少overhead
        • Float16+MPS使系统的吞吐量提高一倍

总结COLD的好处

  • Online learning使系统更能处理data distribution shift场景,从实验中可以看出在数据分布剧烈变化的场景,相比双塔提升更明显
  • 提升模型开发和A/B测试效率(不用提前刷embedding了)

实验部分

指标:topk@m

\(recall = \frac{|\{top\ k\ ad\ candidates \}| \cap |\{top\ m\ ad \ candidates\}| }{|\{top\ m\ ad\ candidates\}|}\)

  • \(top\ k\ ad\ candidates\)是pre-ranking(粗排)的top k
  • \(top\ m\ ad \ candidates\)是ranking(精排)的top m
  • 以DIEN(精排模型)作为上界