Next-basket recommendation

On this page 7

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.

ComponentFunctionTypical implementation
Basket encoderTurns a set of items into one vectorMean or attention pooling over item embeddings
Sequence encoderSummarizes the basket history over timeGRU, LSTM or Transformer
Repeat moduleScores previously bought itemsFrequency and recency features or a copy mechanism
Explore moduleScores items new to the userItem embeddings and co-purchase relations
Mixing gateBalances repeat and explore scoresLearned weight per user or per item
Core components of a next-basket model

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.

FamilyCore ideaStrengthWeakness
Popularity and frequencyRecommend the user’s most frequent or recent itemsStrong, fast, transparent baselineNo discovery of new items
Markov chain modelsLearn transitions from one basket to the nextCaptures short-term complementarityLimited long-range memory
Factorizing personalized Markov chainsCombine matrix factorization with transitionsHandles sparse transition dataAssumes first-order dependence
Recurrent and attention modelsEncode the full basket sequenceModels long histories and contextNeeds more data and tuning
Nearest-neighbor methodsUse baskets of similar usersGood exploration signalCostly at large scale
Repeat-explore modelsSeparate scorers for known and new itemsMatches real purchase behaviorMore complex training
Families of next-basket recommendation methods

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.

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.

TaskInputPrediction target
Next-basket recommendationSequence of past baskets per userSet of items in the next basket
Sequential recommendationOrdered sequence of single itemsThe next single item
Session-based recommendationClicks within one anonymous sessionNext click or item in the session
Top-N recommendationUnordered interaction historyRanked list of relevant items
Basket completionPartially filled current basketMissing items for the same basket
How next-basket recommendation differs from related tasks

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.

SymptomLikely causeRemedy
Recommendations repeat past orders onlyRepeat signal dominates trainingAdd an explore module and track explore recall
Weak results for new customersCold start problem with few basketsFall back to popularity and context features
Seasonal items recommended out of seasonNo time or calendar featuresAdd intervals and seasonal context
Inflated offline scoresRandom rather than temporal splitEvaluate on each user’s final basket
Narrowing product exposureRecommendation feedback loopInject diversity and monitor catalog coverage
Common problems in next-basket systems

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.