TL;DR
Display advertising ranks each ad by how likely the user is to click it, and that prediction is made from the user's past behaviour. Most deep models squeeze the whole history into one fixed-length vector that is the same for every ad, so it cannot hold all of a user's interests at once. The Deep Interest Network (DIN) builds a different user vector for each candidate ad: it weights each past behaviour by how relevant that behaviour is to the ad and adds the results up. It is deployed in Alibaba's display advertising system, where it serves the main traffic.
Builds on: Embedding Layer, Attention Mechanism, Feedforward Neural Network, Parametric ReLU (PReLU) · Leads to: ranking models for ads and products
Why it mattered
Alibaba's display advertising system ranks ads by eCPM, the bid price times the predicted click-through rate (CTR), so every gain in prediction quality flows into revenue. The paper describes a model that was built, trained on about 2 billion samples, and deployed. In a live A/B test run from May to June 2017, DIN trained with its two training techniques raised CTR by up to 10.0 percent and revenue per mille (RPM) by 3.8 percent over the production baseline. The authors note that the training techniques "can be easily generalized to other industrial deep learning tasks", which is why the paper is read as a method and not only as an Alibaba system.
The problem
Most deep CTR models of the time shared one design, which the paper calls Embedding&MLP. Each sparse category, such as a shop, a category or a visited item, is looked up in an embedding table. A user's behaviour list is a variable-length list of such vectors, so it is pooled into one fixed-length vector, usually by summing or averaging, and that vector is fed to a multilayer perceptron (MLP) together with the ad's own features.
The trouble is that the pooled user vector is the same for every ad. The paper's example is a young mother who has recently browsed a woollen coat, T-shirts, earrings, a tote bag, a leather handbag and a children's coat. If the system shows her a new handbag, only the tote bag and the leather handbag matter for that click. Pooling all six into one vector blurs them together. The usual fix, a longer vector, adds parameters, invites Overfitting and costs compute and storage that an online system with hundreds of millions of users cannot easily pay. The paper also tried an LSTM over the behaviour sequence and found no improvement. The authors suspect that a user's behaviours jump between several concurrent interests, so the sequence looks noisy.
How it works
The walkthrough builds the user vector for one user and two different ads. The numbers are tiny and round. A dot product stands in for the paper's small network that scores relevance, so the arithmetic can be done by hand.
Setup: the user has three past behaviours, each already an embedding (two numbers here): a tote bag, e1 = (2, 0); running shoes, e2 = (0, 1); and a handbag, e3 = (1, 1). Ad A is a handbag, with embedding v_A = (1, 0).
- Look up the behaviours. Each item the user visited is one row of the embedding table, so the history is the list e1, e2, e3. Check: the list has three vectors, and a different user would have a list of a different length, which is why pooling is needed at all.
- Score each behaviour against the ad. The activation unit compares every behaviour with the ad. Here the score is the dot product with v_A. For e1 it is 2 times 1 plus 0 times 0, which is 2. For e2 it is 0 times 1 plus 1 times 0, which is 0. For e3 it is 1 times 1 plus 1 times 0, which is 1. Check: the tote bag, the most related behaviour, gets the largest score, and the running shoes get zero.
- Pool with the scores as weights. The user vector for ad A is the weighted sum of the behaviours: 2 times (2, 0), plus 0 times (0, 1), plus 1 times (1, 1). That is (4, 0) + (0, 0) + (1, 1) = (5, 1). Check: the result points mostly along the tote bag direction, as the scores said it should.
- Keep the weights unnormalised. The weights are 2, 0 and 1, and they add up to 3. A softmax would rescale them to about 0.67, 0.09 and 0.24, which add up to 1. DIN skips that rescaling, so the total of 3 is kept. Check: a user with more relevant history gets a larger total weight, so the size of the vector carries information.
- Change the ad, keep the history. Candidate B is running shoes, with embedding v_B = (0, 1). The scores are now 0 for the tote bag (0 times 0 plus 0 times 1), 1 for the running shoes (0 plus 1) and 1 for the handbag (0 plus 1). The pooled vector is 0 times (2, 0), plus 1 times (0, 1), plus 1 times (1, 1), which is (1, 2). Check: the same history gives (5, 1) for ad A and (1, 2) for ad B, so the user vector follows the ad.
- Feed the result forward. The pooled vector is joined with the ad's embedding and the other features, and passed through the MLP. The paper's Alibaba model uses layers of size 192, 200, 80 and 2. The last two numbers become a click and no-click score, and a softmax turns them into the predicted click probability. Check: the MLP sees a different user vector for each ad, so it can answer each ad on its own relevance.
- Regularise only what the batch touched. Normal L2 regularisation would recompute a penalty over all embedding rows at every step, which is far too costly when the table has hundreds of millions of parameters. DIN's mini-batch aware version penalises only the rows whose ids appear in the current batch. Example: a batch that contains only the tote bag and the running shoes penalises those two rows this step, and every other row is left out. Check: the cost depends on the batch, not on the size of the table.
- Activate with Dice. The MLP's activation is Dice, a version of PReLU whose switch point moves with the mean of the batch instead of staying at zero. The math section works out the numbers. Check: when the batch mean is 0.5, the switch sits at 0.5.
flowchart LR H["User behaviours: list of embeddings"] --> A["Activation unit: score each behaviour against the ad"] AD["Candidate ad embedding"] --> A A --> P["Weighted sum pooling: user vector for this ad"] AD --> C["Join with ad and other features"] P --> C C --> M["MLP with Dice activations"] M --> O["Softmax: predicted click probability"]
- Dice, batch mean 0.5
- batch mean 0
The math
For a candidate ad with embedding and a user with behaviour embeddings , the user's interest representation is a weighted sum of the behaviours. Each weight is a learned function of that behaviour and the ad, so the vector changes with the ad.
Step 2 in symbols: the activation weights
Each weight is the output of a small feed-forward network applied to the behaviour and the ad:
Besides the two embeddings, the unit feeds the network their product, which the paper describes as explicit knowledge that helps relevance modelling. The walkthrough replaces with a dot product, so . For the tote bag, , as in step 2.
Step 3 in symbols: weighted sum pooling
Average pooling would be , which gives every behaviour the same weight whatever the ad. DIN replaces that fixed weight with the learned, ad-dependent . With the walkthrough's numbers, .
Step 4 in symbols: no normalisation
A softmax version would use , so that . DIN does not normalise, so is kept as an approximation of how strongly the user's interests are activated by this ad. The paper's example is a user whose history is 90 percent clothes and 10 percent electronics. A T-shirt ad activates most of the clothes history and gets a larger vector than a phone ad. A softmax would erase that difference in scale.
Step 7 in symbols: the mini-batch aware penalty
Let be the number of times feature occurs in the whole training set, and let if feature occurs in mini-batch and otherwise. The paper's approximation of the L2 penalty is , so the update for an embedding row is
Here is the learning rate, is the batch and is the penalty strength, which the paper sets to 0.01 for both this method and DiFacto's variant. In the walkthrough, a row not in the batch has , so its penalty term is zero for that step.
Step 8 in symbols: Dice
Dice replaces PReLU's hard switch with a smooth one centred on the batch mean:
Here and are the mean and variance of the input over the mini-batch during training, and moving averages of them at test time. is the learned slope of the second channel, and in the paper. When the mean and variance are both zero, Dice becomes PReLU.
Worked check with , (so the square root is 0.5, and is negligible) and a fixed for the arithmetic:
- Input is 0.5 above the mean, so and . PReLU would give , because .
- Input is 1.5 below the mean, so and . PReLU would give .
The first input stays mostly on its own line and the second is mostly on the scaled line. Dice has moved the rectified point to the batch mean, which is the paper's stated purpose.
Results
The paper reports offline AUC, the area under the ROC curve, and relative improvement over a baseline, RelaImpr. For a model with AUC and a baseline with AUC , the paper defines RelaImpr as , which measures the gain above a random guesser that scores 0.5. The Alibaba results are below, with the paper's values copied exactly.
| Model (Alibaba, full features) | AUC | RelaImpr over BaseModel |
|---|---|---|
| LR | 0.5738 | -23.92% |
| BaseModel | 0.5970 | 0.00% |
| Wide & Deep | 0.5977 | 0.72% |
| PNN | 0.5983 | 1.34% |
| DeepFM | 0.5993 | 2.37% |
| DIN | 0.6029 | 6.08% |
| DIN with MBA regularization | 0.6060 | 9.28% |
| DIN with Dice | 0.6044 | 7.63% |
| DIN with MBA and Dice | 0.6083 | 11.65% |
DIN alone adds 0.0059 absolute AUC over BaseModel on this dataset. The mini-batch aware regularizer adds a further 0.0031 over dropout, and Dice adds 0.0015 over PReLU. Together, the two techniques give 0.0113 absolute AUC over BaseModel. The paper argues that 0.001 of absolute AUC is significant at commercial scale.
On the two public datasets, the paper's Table 3 gives the following values for the same metric.
| Model | MovieLens AUC | MovieLens RelaImpr | Amazon (Electronics) AUC | Amazon RelaImpr |
|---|---|---|---|---|
| LR | 0.7263 | -1.61% | 0.7742 | -24.34% |
| BaseModel | 0.7300 | 0.00% | 0.8624 | 0.00% |
| Wide & Deep | 0.7304 | 0.17% | 0.8637 | 0.36% |
| PNN | 0.7321 | 0.91% | 0.8679 | 1.52% |
| DeepFM | 0.7324 | 1.04% | 0.8683 | 1.63% |
| DIN | 0.7337 | 1.61% | 0.8818 | 5.35% |
| DIN with Dice | 0.7348 | 2.09% | 0.8871 | 6.82% |
The regularisers were compared on Alibaba with the fine-grained goods-id features, which have a dimension of about 0.6 billion. Without any regulariser, the model overfits after the first epoch. Here RelaImpr is measured against the model without goods-id features and without regularisation (AUC 0.5940). Dropout, which discards half the feature ids in each sample, reaches AUC 0.5970 (3.19 percent RelaImpr). Filtering to the 20 million most frequent goods ids reaches 0.5983 (4.57 percent). DiFacto's regulariser reaches 0.5954 (1.49 percent). The mini-batch aware method reaches 0.6031 (9.68 percent), the best of the options tested.
In the online test, the system served the production baseline for almost a month, and the new model raised CTR by up to 10.0 percent and RPM by 3.8 percent. The serving section adds an engineering result. The system must score hundreds of ads per visitor in under 10 milliseconds, at peaks of more than 1 million users per second. Request batching, GPU memory access changes and concurrent CUDA kernels together doubled the queries per second one machine can handle.
The results have limits. All the industrial numbers come from one company's traffic and one ad system, and the paper's own argument for its regularisers depends on that scale. On the public datasets, which have about 0.1 million features, the paper notes that overfitting was not a serious problem, so the regularisers help mostly at Alibaba's scale. The paper does not compare DIN with the attention-based sequence models that were developed later, and it reports the LSTM attempt only briefly.
Reading guide
Read the paper in this order, with the lessons each section needs.
- Section 1 (Introduction) uses CTR and eCPM. The key claim, that a fixed-length user vector cannot hold diverse interests, needs Embedding Layer for what the vector is built from.
- Section 2 (Related work) traces the lineage. Read Attention Mechanism first: the paper says its local activation unit shares ideas with NMT attention, and it compares its design with DeepIntent's global attention. Wide & Deep is the nearest architecture.
- Section 3 (Background) describes the matching and ranking stages of the Alibaba system and the young-mother example. It needs only the floor.
- Section 4.1 (Feature representation) uses One-Hot Encoding. The paper's multi-hot vector is a version with several 1s, one for each item the user visited.
- Section 4.2 (Base model) uses the embedding table, sum or average pooling, an MLP and the loss. The loss is the negative log-likelihood, which is the same quantity as binary cross-entropy.
- Section 4.3 (DIN) is the core of the paper. Equation (3) is the weighted sum of step 3. The argument for dropping the softmax, which the paper names as the difference from traditional attention, needs Softmax.
- Section 5.1 (Mini-batch aware regularization) needs L2 Regularization and Stochastic Gradient Descent, and it compares with Dropout. Overfitting explains the Figure 4 curves.
- Section 5.2 (Data adaptive activation) needs Parametric ReLU (PReLU) and Rectified Linear Unit (ReLU). The Dice control function in Figure 3 extends the PReLU switch.
- Section 6.1 to 6.3 (Datasets, baselines, metrics) use Adam Optimizer, Learning Rate and AUC. Read the AUC definition before the RelaImpr formula.
- Section 6.8 (Visualisation) uses t-SNE to project the learned goods embeddings to two dimensions.