TL;DR
Rendle and colleagues study item recommendation from implicit feedback, where the only data is what a user did, such as viewing or buying, and never what they disliked. They propose BPR-Opt, a training criterion built from pairs of items: for each user, an item the user interacted with should score above an item they did not. A generic learning rule, LearnBPR, optimises that criterion with stochastic gradient descent on randomly drawn pairs. Applied to matrix factorization and nearest-neighbour models, it gives better rankings than the usual training methods on two datasets.
Builds on: Matrix Factorization, Sigmoid Function, Maximum a Posteriori (MAP) Estimation, Stochastic Gradient Descent · Leads to: Area Under the ROC Curve
Why it mattered
The paper turns a common practice into a principled one. Typical item recommenders, the paper says, label each observed user-item pair 1 and every other pair 0, then fit a model to predict those labels. The paper argues this fails for ranking: a model with enough capacity to fit the training labels predicts only 0s on the pairs it must rank later. Its pairwise criterion avoids this by training on comparisons, and its derivation links it to the area under the ROC curve (Section 4.1.1), which makes the objective easy to explain to anyone who knows that metric.
The problem
Suppose a shop logs the purchases of 10,000 users over 4,000 items. Each purchase is a positive observation. Every other user-item pair is unknown: the user may not want the item, or may want it later. Standard learners treat unknown pairs as negatives. That mixes two different things, and it trains the model on exactly the pairs it must rank in the future.
The paper's first move is to change the training data. Instead of asking "is this item selected?", it asks "does this user prefer item i over item j?". Only pairs where one item was observed and the other was not give a usable preference. Pairs where both are observed, or both are unobserved, carry no information and are skipped.
How it works
Trace one user through the method, with four items and a tiny model.
- Suppose user u has viewed items i1 and i3, and has not viewed i2 or i4. The observed items for u are i1 and i3.
- Build training triples (u, i, j), where i is an item the user viewed and j is one the user did not. There are four such triples: (u, i1, i2), (u, i1, i4), (u, i3, i2) and (u, i3, i4). Each one says "u prefers i over j".
- Score each item with the model: the score for i1 is 2.0, for i2 is 0.5, for i3 is 1.0 and for i4 is −0.5. The model only needs one score per user-item pair.
- Take the score difference for one triple, (u, i1, i2): 2.0 minus 0.5 is 1.5. A large positive difference means the model already agrees with the preference.
- Pass the difference through the logistic sigmoid to get a probability: σ(1.5) = 1 / (1 + e^(−1.5)) ≈ 0.818. The model gives about an 82 percent probability that u prefers i1 to i2. The log of that probability, ln(0.818), is about −0.201.
- The criterion sums this log term over all triples and subtracts a penalty on the size of the parameters.
- Take a gradient step on one randomly drawn triple, and move the parameters so that the difference for that triple grows. A triple the model gets wrong, such as a difference of −1.0, gives a large step, where the factor is about 0.73. A triple already ranked well, like the 1.5 above, gives a small one, about 0.18.
- Repeat with fresh random triples until the model stops improving. The paper samples with replacement, so training can stop at any step.
flowchart LR A["Observed interactions"] --> B["Draw a triple (u, i, j) at random"] B --> C["Score difference x = score of i minus score of j"] C --> D["Sigmoid of x gives the probability of the preference"] D --> E["Gradient step raises the log of that probability"] E --> B
The math
For a model with parameters and a set of training triples, the criterion is , where is the logistic sigmoid and .
Step 1 in symbols: the preference probability
The paper writes the probability that user prefers item to item as , with . The score is a difference of two model scores, so the model only has to estimate one score per user-item pair.
Step 2 in symbols: the training set
The training triples are , where is the set of items user interacted with. Each user contributes one triple for every observed item paired with every unobserved one.
Step 3 in symbols: the criterion
Assuming independence across users and pairs, and a zero-mean normal prior on with covariance (the paper's choice, which sets its scale with ), the log posterior is, up to a constant,
Maximising this is maximum a posteriori estimation. The paper links it to AUC: the AUC of a user counts the share of triples with , using the step function. BPR replaces that step with , which is differentiable and is the log of the probability from step 1.
Step 4 in symbols: the gradient
The derivative of with respect to is . So the gradient of BPR-Opt is a sum over triples of this factor times the gradient of , minus the penalty term. The factor is large when the model is wrong about a triple and small when it is already right. This is why the sampling in step 7 of the walkthrough concentrates effort on the triples that teach the most.
Step 5 in symbols: the update rule
LearnBPR draws one triple at random and updates
where is the learning rate. The paper's pseudo-code writes the penalty with a plus sign; the sign used here follows from the criterion, and it pulls the parameters towards zero.
Step 6 in symbols: matrix factorization
Matrix factorization sets , the dot product of a user vector and an item vector with dimensions. Then , and . These three derivatives are all LearnBPR needs.
Results
The paper evaluates on two datasets. The Rossmann dataset is from an online shop, with 10,000 users, 4,000 items and 426,612 purchases. The Netflix data is a subsample of 10,000 users and 5,000 items with 565,738 rating actions, where the ratings are removed so that only the fact of a rating is used, and each user has at least 10 items and each item at least 10 users. Evaluation holds out one action per user, and the metric is the average AUC over the held-out pairs. Results are averaged over 10 random splits, with hyperparameters tuned by grid search in the first round.
The scale matters for the sampling choice. On the Netflix subsample, the average user has about 56.6 observed items and about 4,943 unobserved ones, so each user contributes roughly 280,000 triples and the whole set is on the order of 2.8 billion. A full gradient over all of them at every step is too costly, which is why LearnBPR samples one triple at a time.
- The two BPR-trained models, BPR-MF and BPR-kNN, have the highest AUC on both datasets, across the model dimensions the paper tries (8 to 128 for the factorisation methods).
- The same matrix factorization model gives very different AUC depending on training. SVD-MF, which fits the training data best in the least-squares sense, ranks worst among the factorisation methods and degrades as dimensions grow, which the paper attributes to overfitting.
- On Netflix, BPR-MF with 8 dimensions reaches about the quality of WR-MF with 128 dimensions.
- The paper reports that LearnBPR converges much faster than user-wise stochastic gradient descent on the Rossmann data, with BPR-MF of 16 dimensions.
- The limits: the study is offline, with one held-out action per user, and the metric is AUC. The paper's own numbers show that on Netflix the most-popular baseline scores 0.8794 on test, close to its non-personalised upper bound of 0.8801, so that split leaves little room for personalised methods to show an advantage. The paper leaves online updates to future work.
Reading guide
- Section 1, Introduction: the case for implicit feedback. Needs Recommender System for the setting.
- Section 2, Related Work: kNN, matrix factorization and weighted regularised factorisation. Needs Matrix Factorization and L2 Regularization.
- Section 3, Personalized Ranking: the construction of training pairs. The set notation is the only hurdle.
- Section 4.1, BPR Optimization Criterion: the derivation. Needs Bayes' Rule, Maximum a Posteriori (MAP) Estimation, Gaussian (Normal) Distribution and Sigmoid Function.
- Section 4.1.1, Analogies to AUC optimization: needs Area Under the ROC Curve.
- Section 4.2, BPR Learning Algorithm: LearnBPR. Needs Stochastic Gradient Descent and Gradient Descent; Bootstrap Sampling explains sampling with replacement.
- Section 4.3, Learning models with BPR: matrix factorization and kNN. Needs Matrix Factorization.
- Section 6, Evaluation: datasets, leave-one-out, AUC and results. Needs Area Under the ROC Curve.
- Section 7, Conclusion: the summary of the claims above.
Check yourself
QuestionRecall: what does the sigmoid turn the score difference x into, and what does ln σ(x) measure in BPR?Show answer
The sigmoid turns x into a probability between 0 and 1, here the probability that the user prefers item i to item j. ln σ(x) is the log of that probability, so maximising it means making the model confident in the observed preference.
QuestionFor a user with 50 observed items out of 1,000, how many training triples does the user contribute?Show answer
The user contributes 50 times (1,000 minus 50), which is 50 times 950, or 47,500 triples.
QuestionWhy does BPR sample one triple at a time rather than taking a full gradient step over all triples?Show answer
The full set of triples is huge: the Netflix subsample implies about 2.8 billion, so a full gradient at every step is too costly. Sampling one triple at a time gives a cheap update that is correct in expectation. The paper also finds that bootstrap sampling with replacement converges faster than going through the data user by user, because user-wise traversal makes many consecutive updates on the same user and item.
QuestionA colleague says WR-MF with 128 dimensions must be better than BPR-MF with 8 dimensions because it is bigger. What does the paper's Netflix result say?Show answer
The paper reports that BPR-MF with 8 dimensions reaches about the quality of WR-MF with 128 dimensions on Netflix. Size alone does not decide ranking quality here; the training criterion matters more.
Sources
- BPR: Bayesian Personalized Ranking from Implicit Feedback, arXiv:1205.2618, Rendle, Freudenthaler, Gantner and Schmidt-Thieme.
- Receiver operating characteristic, Wikipedia, for the AUC background.