Search

Search papers and lessons

Wide & Deep Learning for Recommender Systems

Heng-Tze Cheng, Levent Koc, Jeremiah Harmsen et al. · 2016

Wide & Deep trains a linear model on crossed features and a neural network together, so one recommender both memorises known feature pairs and generalises to new ones.

On this page

  • Colour = topic mix
  • Probability
  • Calculus
  • Discrete math
  • Linear algebra
  • Classical models
  • Neural network basics
  • ReadReady to readNot yet

TL;DR

A recommender has two jobs. It must remember that certain feature pairs go together, such as "installed this app" and "shown that app", and it must also suggest sensible items for pairs it has never seen. The paper trains one model with two parts: a linear "wide" part that keeps explicit crossed features for memorisation, and a neural "deep" part that uses learned embeddings for generalisation. In a three-week live test on Google Play, the combined model increased app acquisitions more than either part alone.

Builds on: Generalized Linear Model, Cross-Product Transformation, Feedforward Neural Network, Embedding Layer · Leads to: DeepFM

Why it mattered

The paper describes a production system, not a benchmark model. Google Play has over one billion active users and over one million apps, and the ranking model orders the apps shown to each user. The paper reports that the combined model raised app acquisitions by 3.9 percent over the previous wide-only ranking model in a live A/B test. The authors also released a TensorFlow implementation with a high-level API, so the pattern of "a wide linear part plus a deep part, trained jointly" became a template other teams could reuse. Later recommender papers, including DeepFM, build directly on it.

The problem

Before this paper, the ranking model at Google Play was a wide-only logistic regression with many hand-built cross-product features. A cross such as "user installed Netflix AND impression is Pandora" is 1 only for that exact pair, so it captures a pattern the training data has shown. This is memorisation: strong for frequent pairs, but silent on pairs that never appeared. Covering new pairs needs more hand-made crosses, which takes engineering effort.

Embedding models solve the coverage problem. Each category gets a short dense vector (an embedding), and a neural network combines the vectors, so unseen pairs get a sensible score. The paper points out the failure case. When the user-item matrix is sparse and high-rank, which is typical for niche apps and users with narrow tastes, dense embeddings give a nonzero score to almost every pair. Most pairs should have no interaction, but the embedding model cannot say so, so it over-generalises and recommends less relevant apps. A linear model with a few crosses can store these "exception rules" with far fewer parameters. The question the paper asks is how to keep both behaviours in one model.

How it works

The recommender runs in three stages: data generation, model training and model serving. The walkthrough follows one impression through the model's forward pass, with tiny round numbers in place of the real ones.

Set up one impression. The user has installed Netflix, and the store shows Pandora. The label is 1 if the user installs the app and 0 otherwise. Here the user installs, so the label is 1. The bias is -1.

  1. Make the training example. One impression becomes one example, and its label is the app acquisition: 1 if the shown app was installed. Check: this example has label 1.
  2. Build the wide input. The cross "installed Netflix AND impression Pandora" is active, so its input is 1, and every other wide input is 0. The wide part is a linear sum, so its contribution is the cross weight times 1. Take the cross weight to be 2.0. Check: the wide contribution is 2.0.
  3. Build the deep input. Each categorical value, such as the app category or the country, looks up its embedding row, which here has 32 numbers. The embeddings are concatenated with the dense features, passed through ReLU layers, and the last layer gives a set of activations. Take the deep part's contribution, after its output weights are applied, to be -0.5. Check: the deep part is a second, separate contribution, computed from different inputs.
  4. Add the parts and the bias. The model's logit is the sum of the wide contribution, the deep contribution and the bias: 2.0 + (-0.5) + (-1.0) = 0.5. Check: the parts add, so a wide cross can override a deep part that over-generalises, and the reverse.
  5. Turn the logit into a probability. The sigmoid of 0.5 is about 0.622. Check: the probability is above 0.5, so this impression is predicted to be more likely installed than not.
  6. Measure the error. The logistic loss for label 1 is minus the natural log of 0.622, which is about 0.47. Check: a confident correct prediction would have a loss near 0, and this one is moderate.
  7. Update both parts with one gradient. The error signal is 0.622 - 1 = -0.378. Both parts receive it. The wide cross weight changes by the learning rate times 0.378, so with learning rate 0.1 it moves from 2.0 to 2.0378. The deep weights change by the same error times their own inputs. Check: one loss trains both parts, and neither is trained alone.
  8. Serve the model. At serving time only the forward pass runs. The servers score each candidate app and sort the apps by score, from most to least likely to be installed.
−3−2−1012300.20.40.60.81joint logit zprobability
  • p = sigmoid(z)
The joint logit is the sum of the wide part, the deep part and the bias. The marked point is the walkthrough's example: z = 0.5, p about 0.62.
flowchart LR
  I["Impression: query features and app features"] --> W["Wide part: crossed sparse features, linear"]
  I --> D["Deep part: embeddings, then ReLU layers"]
  W --> S["Sum of logits plus bias"]
  D --> S
  S --> P["Sigmoid gives probability of install"]
  P --> L["Logistic loss, one gradient for both parts"]

The math

Definition: Wide & Deep model

The wide part is a linear function of the raw features x\mathbf{x} and their cross-product transformations ϕ(x)\phi(\mathbf{x}). The deep part is a feed-forward network applied to the embedded features. The prediction is the sigmoid of the sum of the two logits and one bias, so a single probability comes from both parts together.

The math has four stages, one for each stage of the pipeline: normalising the inputs, computing the joint logit, training both parts with one gradient, and the cost of serving.

Stage 1 in symbols: quantile normalisation of continuous features

Continuous features such as an app's age are mapped to [0,1][0, 1] before training. A value xx is replaced by its cumulative distribution function P(X≤x)P(X \leq x), and the result is split into nqn_q quantile bins. A value in the ii-th bin gets the normalised value

i−1nq−1\frac{i - 1}{n_q - 1}

For example, with nq=5n_q = 5 bins, a value in the third bin becomes (3−1)/(5−1)=0.5(3 - 1) / (5 - 1) = 0.5. The bin edges are computed once, during data generation, so every model sees the feature on the same scale.

Stage 2 in symbols: the joint logit

Let x\mathbf{x} be the raw features, ϕ(x)\phi(\mathbf{x}) the cross-product transformations, and a(lf)\mathbf{a}^{(l_f)} the final activations of the deep network. The paper's prediction for a binary label is

P(Y=1∣x)=σ ⁣(wwide⊤[x,ϕ(x)]+wdeep⊤a(lf)+b)P(Y = 1 \mid \mathbf{x}) = \sigma\!\left(\mathbf{w}_{wide}^{\top}[\mathbf{x}, \phi(\mathbf{x})] + \mathbf{w}_{deep}^{\top}\mathbf{a}^{(l_f)} + b\right)

Here σ\sigma is the sigmoid, wwide\mathbf{w}_{wide} holds the wide weights, wdeep\mathbf{w}_{deep} holds the weights on the deep network's last layer, and bb is one bias. The two parts are summed inside one sigmoid, so there is one logit. This is what the walkthrough computed: 2.0 from the wide part, -0.5 from the deep part and -1.0 from the bias, giving z=0.5z = 0.5.

Each hidden layer of the deep network computes

a(l+1)=f ⁣(W(l)a(l)+b(l))\mathbf{a}^{(l+1)} = f\!\left(W^{(l)}\mathbf{a}^{(l)} + \mathbf{b}^{(l)}\right)

where ll is the layer number and ff is the activation, which is the ReLU in the paper's experiments. The input to the first layer is the concatenation of all embeddings and the dense features, about 1200 numbers in the paper.

Stage 3 in symbols: one gradient for both parts

Let zz be the joint logit, p=σ(z)p = \sigma(z), and let the loss be the logistic loss L=−[yln⁡p+(1−y)ln⁡(1−p)]L = -\left[y \ln p + (1 - y)\ln(1 - p)\right]. The derivative of LL with respect to zz is p−yp - y. Because zz is a sum, the chain rule sends the same signal to every term in it. For a wide weight on feature xkx_k the gradient is (p−y) xk(p - y)\,x_k, and for a deep weight it is (p−y)(p - y) times the activation that weight multiplies. With p=0.622p = 0.622 and y=1y = 1 the signal is −0.378-0.378, as in step 7. The paper trains the wide part with FTRL, an optimiser that uses an L1L_1 penalty to push many weights to exactly zero, and the deep part with AdaGrad, which gives each weight its own step size from its past gradients. Both optimisers receive the same error signal.

Stage 4 in symbols: the cost of serving

Scoring NN candidate apps for one request takes NN forward passes. The servers split the candidates into batches and run them on several threads. Table 2 of the paper reports 31 ms for one batch of 200 on one thread, and 14 ms for batches of 50 on four threads. The batch-size and thread trade-off is an engineering choice, not part of the model.

Results

The paper evaluates the model two ways: offline AUC on a holdout set, and online acquisition gain in a live A/B test on the Google Play main landing page. The table copies the paper's Table 1.

ModelOffline AUCOnline acquisition gain
Wide (control)0.7260%
Deep0.722+2.9%
Wide and Deep0.728+3.9%

The live experiment ran for three weeks, with 1 percent of users in each group. The control group saw the previous wide-only logistic regression model, and the experiment group saw the combined model trained on the same features. The paper reports the 3.9 percent gain as statistically significant. It also reports about a 1 percent gain of the combined model over a deep-only model with the same features and network structure.

The serving results are in Table 2, which measures latency against batch size and thread count. A batch of 200 on one thread takes 31 ms, while batches of 50 on four threads take 14 ms. The text reports 14 ms client-side latency including serving overhead, and says that at peak the servers score over 10 million apps per second.

The results have limits. All experiments come from one commercial app store, using the paper's own features and labels. The offline gain is small, only 0.002 in AUC, and the authors suggest that the live system, which mixes memorised and generalised recommendations and learns from new user responses, explains the larger online gain. The paper does not establish that the same balance holds for other recommenders.

Reading guide

Read the paper in this order, with the lessons each section relies on.

  • Section 1 (Introduction) needs Recommender System for the ranking framing and Generalized Linear Model for why linear models are used in industry. The memorisation and generalisation idea is the central claim.
  • Section 2 (Recommender system overview) describes retrieval and ranking. The ranking model estimates the probability of a user action given the features, which is a logistic target.
  • Section 3.1 (The wide component) uses the cross-product transformation. Read Cross-Product Transformation first; the paper's definition for binary features is the one given there.
  • Section 3.2 (The deep component) uses embeddings and feed-forward networks with ReLU activations.
  • Section 3.3 (Joint training) uses the logistic loss, Cross-Entropy Loss, and Stochastic Gradient Descent with mini-batches. The distinction from an ensemble is explained here.
  • Section 4 (System implementation) covers data generation, warm starting and serving. The L1L_1 penalty in the wide optimiser is a close relative of L2 Regularization.
  • Section 5 (Experiment results) reports offline AUC and the online gain. Read the AUC definition first to see why a 0.002 difference is small.
  • Section 6 (Related work) cites factorization machines as earlier work that inspired the idea.

Check yourself

QuestionRecall: what does the wide part of the model memorise, and what does the deep part generalise?Show answer
The wide part is a linear model over crossed features, so it memorises specific pairs seen in the training data, such as installed app and shown app. The deep part uses learned embeddings and a neural network, so it generalises to feature combinations it has rarely or never seen. Joint training lets each part cover the other's weakness.
QuestionComputation: the wide contribution is 1.5 because a cross is active, the deep contribution is 0.2, and the bias is -0.5. What are the joint logit zz and the probability pp? Give numbers.Show answer
The logit is z=1.5+0.2−0.5=1.2z = 1.5 + 0.2 - 0.5 = 1.2. The probability is p=σ(1.2)=1/(1+e−1.2)p = \sigma(1.2) = 1 / (1 + e^{-1.2}), which is about 0.769. Answer: z=1.2z = 1.2 and pp is about 0.77.
QuestionWhy: the paper says the wide part needs only a few cross-product transformations when it is trained jointly with the deep part. Why would separate models that are averaged need a larger wide part?Show answer
In joint training, both parts receive the same error signal, so the wide part can focus on the pairs the deep part gets wrong. In an ensemble each model is trained without knowing the other, so each must be accurate on its own and needs more features and crosses. Joint training therefore needs a smaller wide part.
QuestionApplied: a new app with no install history appears, so the wide part has no active cross for it. Can the model still give a useful score, and what carries that score?Show answer
Yes. The deep part still produces a contribution from the embeddings of the app's category and related features, so the score is not just the bias. The score is less confident than for an app with memorised crosses, because it comes from related items rather than exact pairs. As installs accumulate, the cross weights for the new app can be learned and the wide part takes over the exact pairs.

Sources

Read the full paper

Heng-Tze Cheng, Levent Koc, Jeremiah Harmsen et al., 2016. arXiv:1606.07792