Next-basket recommendation is the task of predicting the set of items a user will purchase together in the next transaction, based on the ordered history of that user’s previous baskets. Within recommender systems, it sits between sequential recommendation, which predicts a single next item, and classic top-N recommendation, which ignores time.
The problem is central to grocery, pharmacy and replenishment retail, where customers return regularly and buy many items per visit. Its defining features are that the target is an unordered set rather than one item and that a large share of each basket consists of products the customer has bought before.
How next-basket recommendation models purchase history
A next-basket model treats each customer as a sequence of baskets B1, B2 through Bt, where every basket is a set of item identifiers with a timestamp. The model learns a representation of this history and outputs a score for every candidate item; the top k items form the predicted next basket, usually with k between 5 and 20.
Two signals dominate the history. Repeat behavior captures items a customer buys again, such as milk or coffee, often on a characteristic cycle. Exploration behavior captures items new to that customer, which depend on co-purchase patterns across the population. Strong models weigh both, because they require different evidence and fail in different ways.
The table below lists the main components found in most next-basket architectures.
| Component | Function | Typical implementation |
|---|---|---|
| Basket encoder | Turns a set of items into one vector | Mean or attention pooling over item embeddings |
| Sequence encoder | Summarizes the basket history over time | GRU, LSTM or Transformer |
| Repeat module | Scores previously bought items | Frequency and recency features or a copy mechanism |
| Explore module | Scores items new to the user | Item embeddings and co-purchase relations |
| Mixing gate | Balances repeat and explore scores | Learned weight per user or per item |
Main families of next-basket methods
Next-basket methods range from simple frequency heuristics to deep sequence models. A consistent and somewhat uncomfortable finding in published evaluations is that well-tuned personal frequency baselines are very hard to beat on repeat-heavy data, and several neural methods gain mainly by reproducing that repeat signal.
| Family | Core idea | Strength | Weakness |
|---|---|---|---|
| Popularity and frequency | Recommend the user’s most frequent or recent items | Strong, fast, transparent baseline | No discovery of new items |
| Markov chain models | Learn transitions from one basket to the next | Captures short-term complementarity | Limited long-range memory |
| Factorizing personalized Markov chains | Combine matrix factorization with transitions | Handles sparse transition data | Assumes first-order dependence |
| Recurrent and attention models | Encode the full basket sequence | Models long histories and context | Needs more data and tuning |
| Nearest-neighbor methods | Use baskets of similar users | Good exploration signal | Costly at large scale |
| Repeat-explore models | Separate scorers for known and new items | Matches real purchase behavior | More complex training |
Time-aware variants add inter-purchase intervals so that an item bought every two weeks is boosted near its expected date. Some systems also include basket context, such as weekday, store or promotional calendar, which follows the principles of context-aware recommendation.
Next-basket recommendation compared with related tasks
The task is easily confused with neighboring problems in recommender systems. The differences lie in what is predicted and what history is used, and they determine which datasets, losses and metrics fit.
| Task | Input | Prediction target |
|---|---|---|
| Next-basket recommendation | Sequence of past baskets per user | Set of items in the next basket |
| Sequential recommendation | Ordered sequence of single items | The next single item |
| Session-based recommendation | Clicks within one anonymous session | Next click or item in the session |
| Top-N recommendation | Unordered interaction history | Ranked list of relevant items |
| Basket completion | Partially filled current basket | Missing items for the same basket |
Because a next basket typically mixes staples, complements and occasional novelties, a model optimized for one next item tends to over-predict the single most likely product and under-represent the rest of the set.
Evaluating next-basket models
Evaluation compares the predicted top-k list with the actual next basket using set-based ranking metrics. Common choices are recall at k, precision at k, F1, hit rate and NDCG at k, computed on a held-out final basket per user under a temporal split.
Experts recommend reporting repeat and explore performance separately. A model can achieve high overall recall by recommending only previously bought items, yet provide almost no value in helping customers discover new products. Splitting the metrics exposes this and makes model comparisons honest.
- Use a strict temporal split so that no future basket leaks into training features.
- Compare against a personal frequency baseline, not only against other neural models.
- Tune k to the use case: a reorder widget may show 10 items, a full basket suggestion 30 or more.
Limitations and common mistakes
Next-basket recommendation inherits the usual weaknesses of recommender systems and adds several of its own. The table maps frequent problems to their causes and remedies.
| Symptom | Likely cause | Remedy |
|---|---|---|
| Recommendations repeat past orders only | Repeat signal dominates training | Add an explore module and track explore recall |
| Weak results for new customers | Cold start problem with few baskets | Fall back to popularity and context features |
| Seasonal items recommended out of season | No time or calendar features | Add intervals and seasonal context |
| Inflated offline scores | Random rather than temporal split | Evaluate on each user’s final basket |
| Narrowing product exposure | Recommendation feedback loop | Inject diversity and monitor catalog coverage |
A further risk is optimizing only accuracy. Retailers also care about margin, availability and substitution, so production systems often combine the next-basket score with business rules or multi-objective ranking before display.
The simple explanation
Next-basket recommendation tries to guess what will be in a shopper’s cart on the next trip, not just one product but the whole likely shopping list. It looks at what the person bought on earlier visits and in what order.
Think of a neighborhood grocer who knows a regular customer buys bread every week and coffee every month. The grocer can have those ready and may also suggest something new that similar customers enjoy. Most of the list is familiar, and a few items are fresh ideas.
How it is used in practice
An online grocery service with weekly delivery wants to shorten the time customers spend building each order. Its data team trains a repeat-explore next-basket model on two years of order histories, using item embeddings, purchase intervals and the day of the delivery slot as features.
When a customer opens the app, the service shows a prefilled suggested basket of about 25 items: staples due for replenishment based on each customer’s own cycle, plus three or four new products that customers with similar baskets added recently. Customers can accept, remove or swap items with one tap.
In an A/B test against a simple list of previous orders, the team observes faster checkout and a modest rise in items per order, driven mostly by the explore suggestions. Offline, the new model matches the frequency baseline on repeat recall while clearly improving explore recall, which is the result the team uses to justify rollout.