Problem
Instacart had separate retrieval systems for each recommendation surface, for both ads and organic content. They relied on an ad hoc mix of product co-occurrence, similarity and popularity, and ignored the order of what the user did in the session. Each system was costly to maintain and did not use the contextual sequence of the session. The team wanted one retrieval layer that serves surfaces with different ranking goals (engagement and revenue for organic content, plus advertiser value for sponsored content).
Example from the article: a user adds pancake mix to the cart, views bacon and then adds eggs. The system infers a breakfast intent and retrieves breakfast products.
Solution in brief
Treat retrieval as next-product prediction. Train a BERT-like model with masked language modeling on historical sequences of product ids from shopping sessions, then use the encoded session to score every product id in the vocabulary and pass the top K to the ranking layer. Product-id sequences alone, without user or product features, already beat the old retrieval systems.
Questions this case answers
- How to retrieve candidates in real time from a very large item catalog using the order of a user's recent actions in the current session
- How to replace several heuristic retrieval systems built on co-occurrence and popularity with one learned retrieval layer shared by surfaces with different ranking goals
- How to predict the next product in a shopping session to power contextual recommendations?
- How to replace several ad hoc retrieval systems with one retrieval layer shared by organic and sponsored surfaces?
Tools and methods
- Masked language modeling (MLM) — trains the model by masking product ids inside session sequences
- BERT-like transformer encoder — encodes the session and outputs probabilities over all product ids
- Recall@K — offline metric for the last item of a test sequence
Google or a one-time email code. No password.