@Applying Deep Learning To Airbnb Search

[[Abstract]]

  • The application to search ranking is one of the biggest machine learning success stories at Airbnb. Much of the initial gains were driven by a gradient boosted decision tree model. The gains, however, plateaued over time. This paper discusses the work done in applying neural networks in an attempt to break out of that plateau. We present our perspective not with the intention of pushing the frontier of new modeling techniques. Instead, ours is a story of the elements we found useful in applying neural networks to a real life product. Deep learning was steep learning for us. To other teams embarking on similar journeys, we hope an account of our struggles and triumphs will provide some useful pointers. Bon voyage!

[[Attachments]]

记录 Airbnb 深度模型探索历程。

业务:顾客查询后返回一个有序的列表(Listing,对应房间)。

深度模型之前使用 GBDT 对房子进行打分。

Model Evolution

  • 评价指标 [[NDCG]]

  • Simple NN

    • 32 层 NN + Relu,特征和优化目标和 GBDT 效果相同

    • 打通深度模型训练和线上预测的 pipeline。

  • LambdaRank NN

    • [[LambdaRank]] 直接优化 NDCG

    • 采用 pairwise 的训练方式,构造 <被预定的房间,未被预定的房间> 的训练样本

    • pairwise loss 乘上 item 对调顺序带来的指标变化 NDCG,关注列表中靠前位置的样本

      • 比如 booked listing 从 2 到 1 的价值比 books listing 从 10 到 9 的意义大。
  • Decision Tree/Factorization Machine NN

+ GBDT 叶子节点位置(类别特征) + FM 预测结果放到 NN 中。
  • Deep NN

    • 10 倍训练数据,195 个特征(离散特征 embedding 化),两层神经网络:127 fc + relu 以及 83 fc + relu。

    • 部分 dnn 的特征是来自其他模型,之间在 [[@Real-time Personalization using Embeddings for Search Ranking at Airbnb]] 里面提到的特征也有使用。

    • 在训练样本达到 17 亿后,ndcg 在测试集和训练集的表现一致,这样一来可以使用线下的效果来评估线上的效果?

    • 深度模型在图像分类任务上已经超过人类的表现,但是很难判断是否在搜索任务上也超过人类。一个关键是很难定义搜索任务中的人类能力。

Failed Models

  • Listing ID

    • listing id 进行 embedding,但是出现过拟合。

      • embedding 需要每个物品拥有大量数据进行训练,来挖掘他们的价值

      • 部分 Listing 有一些独特的属性,需要一定量的数据进行训练。

  • Multi-task learning

    • booking 比 view 更加稀疏,long view 和 booking 是有相关的。

    • 两个任务 Booking Logit 和 Long View Logit,共享网络结构。两个指标在数量级上有差异,为了更加关注 booking 的指标,long view label 乘上 log(view_duration)。

      • 线上实验中,页面浏览的时间提高,但是 booking 指标基本不变。

      • 作者分析长时间浏览一个页面可能是高档房源或页面描述比较长。

  • [[Feature Engineering]]

    • GBDT 常用的特征工程方法:计算比值,滑动窗口平均以及特征组合。

    • NN 可以通过隐层自动进行特征交叉,对特征进行一定程度上的处理可以让 NN 更加有效。

  • Feature [[Normalization]]

    • NN 对数值特征敏感,如果输入的特征过大,反向传播时梯度会很大。

    • 正态分布

    • $$(feature_val - \mu)/\rho$$

    • power law distribution

    • $$\log \frac{1+feature_val}{1+median}$$

  • Feature distribution

    • 特征分布平滑

    • 是否存在异常值?

    • 更容易泛化,保证高层输出有良好的分布

  • [[Hyperparameters]]

    • [[Dropout]] 看成是一种数据增强的方法,模拟了数据中会出现随机缺失值的情况。drop 之后可能会导致样本不再成立,分散模型注意力的无效场景。

      • 替代方案,根据特征分布人工产生噪音加入训练样本,线下有效果,线上没有效果。
    • [[神经网络参数全部初始化为0]] 没有效果,[[Xavier Initialization]] 初始化参数,Embedding 使用 -1 到 1 的随机分布。

    • Learning rate 默认参数 [[Adam]] 效果不太好,使用 [[LazyAdam]] 在较大 embedding 场景下训练速度更快

  • Feature Importance [[可解释性]]

    • Score Decomposition 将 NN 的分数分解到特征上。[[GBDT]] 可以这样做。

    • Ablation Test 每次训练一个模型删除一个特征。问题是模型可以从剩余的特征中弥补出缺失的特征。

    • Permutation Test 选定一个特征,随机生成值。[[Random Forests]] 中常用的方法。新生成的样本可能和现实世界中的分布不同。一个特征可能和其他特征共同作用产生效果。

    • TopBot Analysis 分析排序结果 top 和 bot 的单独特征分布

      • 左边代表房子价格的分布,top 和 bot 的分布存在明显不同,代表模型对价格敏感。

      • 右边代表页面浏览量的分布,top 和 bot 的分布接近,说明模型没有很好利用这个特征。

奇怪的东西

  • 论文中一直在引用 [[Andrej Karpathy]] 的建议:don’t be a hero

@Real-time Personalization using Embeddings for Search Ranking at Airbnb

[[Abstract]]

  • Search Ranking and Recommendations are fundamental problems of crucial interest to major Internet companies, including web search engines, content publishing websites and marketplaces. However, despite sharing some common characteristics a one-size-fitsall solution does not exist in this space. Given a large difference in content that needs to be ranked, personalized and recommended, each marketplace has a somewhat unique challenge. Correspondingly, at Airbnb, a short-term rental marketplace, search and recommendation problems are quite unique, being a two-sided marketplace in which one needs to optimize for host and guest preferences, in a world where a user rarely consumes the same item twice and one listing can accept only one guest for a certain set of dates. In this paper we describe Listing and User Embedding techniques we developed and deployed for purposes of Real-time Personalization in Search Ranking and Similar Listing Recommendations, two channels that drive 99% of conversions. The embedding models were specifically tailored for Airbnb marketplace, and are able to capture guest’s short-term and long-term interests, delivering effective home listing recommendations. We conducted rigorous offline testing of the embedding models, followed by successful online tests before fully deploying them into production.

论文解决问题:

  • 数据稀疏情况下如何进行训练?

    • 稀疏 id 聚类处理
  • 将 user id 和 listing id 聚合成 user type、listing type

  • word2vec 中加入 booked listing 作为 global context

目标函数

image.png

$$\underset{\theta}{\operatorname{argmax}} \sum_{(l, c) \in \mathcal{D}{p}} \log \frac{1}{1+e^{-\mathbf{v}{c}^{\prime} \mathbf{v}{l}}}+\sum{(l, c) \in \mathcal{D}{n}} \log \frac{1}{1+e^{\mathbf{v}{c}^{\prime} \mathbf{v}{l}}}+\log \frac{1}{1+e^{-\mathbf{v}{l}^{\prime} \mathbf{v}_{l}}}$$

booked listing 是正样本,所以有一个负号。由于只有一项,所以没有 sigma 符号。

原始负采样是在全体样本中随机选择,业务特殊性,在正样本同一市场的样本中负采样。更好能发现同一市场中内部 listing 的差异。

new listing 通过附近 3 个同类型、相似价格的 listing embedding 进行平均。

word2vec 方法本来是无监督的,通过引入 booked listing 以及 reject 信息传递部分监督信息

利用 booked 数据训练时,文章中提到 user type 和 listing type 要在同一个空间,不知道为什么下面要有两个公式,以及 c 的含义是什么?

$$\underset{\theta}{\operatorname{argmax}} \sum_{\left(u_{t}, c\right) \in \mathcal{D}{b o o k}} \log \frac{1}{1+e^{-v{c}^{\prime} v_{u_{t[[}}}}]]+\sum_{\left(u_{t}, c\right) \in \mathcal{D}{n e g}} \log \frac{1}{1+e^{v{c}^{\prime} v_{u_{t[[}}}}]]$$

$$\underset{\theta}{\operatorname{argmax}} \sum_{\left(l_{t}, c\right) \in \mathcal{D}{b o o k}} \log \frac{1}{1+e^{-\mathrm{v}{c}^{\prime} \mathrm{v}{l{t[[}}}}]]+\sum_{\left(l_{t}, c\right) \in \mathcal{D}{\text {neg}}} \log \frac{1}{1+e^{v{c}^{\prime} \mathrm{v}{l{t[[}}}}]]$$

embedding 之间直接对比需要在相同的向量空间。根据上面的计算可以生成一个特征 UserTypeListingTypeSim。

在如何在实时模型中引入 embedding 特征:根据一些规则收集一些 listing,计算这些 listing embedding 的平均值,再和当前排序的 lisitng 计算一个相似度,做为一个特征放到模型中。

如何评估按上面方法生成的 emb sim 特征重要性?利用 GBDT?

[[冷启动]] listing embeddings

  • 找方圆 10 英里之内的 3 个最相似的 listing,取 listing embedding 的平均

使用 Embedding 方法要考虑的问题:#card

    1. 希望Embedding表达什么,即选择哪一种方式构建语料
    1. 如何让Embedding向量学到东西
    1. 如何评估向量的效果
    1. 线上如何使用

基于 [[向量化召回统一建模框架]] 角度理解

  • 如何定义正样本 #card

    • 如同前边分析的那样,给定 $t$ 个用户点击的房屋(Airbnb叫 listing)序列,序列内部的房屋,其两两之间都应该是相似的。

    • 但由于两两组合太多,因此仿照Word2Vec采用滑窗,认为某个房屋 I 只与窗口内的有限几个房屋 $c$ 是相似的。

    • 但是,如果一个点击序列最终导致某个房屋 $l_b$ 成功预订,则 $l_b$ 业务信号非常强,必须保留。

    • 因此,Airbnb还额外增加了一批正样本,即点击序列中的每个房屋 I 与最终被成功预订的房屋 $l_b$ 是相似的。

  • 如何定义负样本 #card

    • 根据召回的一贯原则,随机采样得到的其他房屋肯定是主力负样本。

    • 但是民宿中介的业务特色决定了,在一个点击序列中的房屋(即正样本)基本上都是同城的,而随机采样得到的负样本多是异地的。

    • 如果只有随机负采样,模型可能只使用“所在城市是否相同”这一粗粒度差异来判断两房屋相似与否,导致最终学到的房屋句量按所在城市聚类,而忽视了同一城市内部不同房屋的差异。

    • 为了弥补随机负采样的不足,Airbnb还为每个房屋在与其同城的其他房屋中采样一部分作Hard Negative, 迫使模型关注所在城市之外的更多细节。

  • 如何使用 embedding #card
    image.png

  • 如何定义损失函数 #card
    image.png

[[向量化召回统一建模框架]] 来理解从用户类别到房屋类别的召回

  • 如何定义正样本 #card
    image.png

  • 如何负样本 #card
    image.png

  • 如何 embedding #card
    image.png

  • 如何定义损失函数 #card
    image.png