S2SRec2: Set-to-Set Recommendation for Basket Completion with Recipe

Yanan Cao, Omid Memarrast, Shiqin Cai, Sinduja Subramaniam, Evren Körpeoglu, Kannan Achan

Abstract

In grocery e-commerce, customers often build ingredient baskets guided by dietary preferences but lack the expertise to create complete meals. Leveraging recipe knowledge to recommend complementary ingredients based on a partial basket is essential for improving the culinary experience. Traditional recipe completion methods typically predict a single missing ingredient using a leave-one-out strategy. However, they fall short in two key aspects: (i) they do not reflect real-world scenarios where multiple ingredients are often needed, and (ii) they overlook relationships among the missing ingredients themselves. To address these limitations, we reformulate basket completion as a set-to-set (S2S) recommendation problem, where an incomplete basket is input into a system that predicts a set of complementary ingredients. We introduce S2SRec2, a set-to-set ingredient recommendation framework based on a Set Transformer and trained in a multitask learning paradigm. S2SRec2 jointly learns to (i) retrieve missing ingredients from the representation of existing ones and (ii) assess basket completeness after prediction. These tasks are optimized together, enforcing accurate retrieval and coherent basket completion. Experiments on large-scale recipe datasets and qualitative analyses show that S2SRec2 significantly outperforms single-target baselines, offering a promising approach to enhance grocery shopping and inspire culinary creativity.

Introduction

In modern grocery e-commerce, users frequently add a few core ingredients to their digital carts but may lack the culinary knowledge to identify the remaining items necessary for a complete meal. Traditional recommendation systems often treat this as a "leave-one-out" problem, attempting to predict a single hidden item. However, this approach fails to capture the complexity of real-world cooking, where multiple ingredients are often required simultaneously, and the synergy between those missing items is just as important as their relationship to the existing basket.

Overview of the S2SRec2 framework translating a partial grocery cart into recommended recipe ingredients.

To bridge this gap, S2SRec2 treats recipe completion as a set-to-set (S2S) task. The goal is to recommend a coherent group of missing ingredients and dynamically determine when a basket has reached a "complete" state for a specific dish.

Methodology

The S2SRec2 framework leverages two key architectural innovations to handle the unordered nature of grocery baskets and the complexity of recipe completion:

  1. Set Transformer: Unlike sequential models (RNNs or standard Transformers), Set Transformers are permutation invariant. This is critical for recipes, as the order in which ingredients are added to a basket does not change the final culinary outcome. This architecture excels at capturing complex inter-dependencies between items in a set.
  2. Multi-task Learning (MTL): The model is trained to solve two problems simultaneously. A Missing Ingredient Query uses a learnable query vector to interrogate the current basket representation and predict the most likely next ingredient. Concurrently, a Completeness Prediction head acts as a binary classifier, serving as a "stop signal" to determine if the current set of ingredients forms a complete recipe.
The S2SRec2 architecture featuring a Set Transformer and multi-task learning for missing ingredient prediction and basket completeness.

During inference, the model operates in a loop: it suggests an item, adds it to the virtual basket, checks for completeness, and repeats until the completeness probability exceeds a defined threshold (e.g., 50%).

Experimental Results

The study utilized a large-scale dataset from food.com, consisting of over 141,000 recipes and nearly 4,000 unique ingredients. Ingredients were represented using 768-dimensional BERT embeddings to capture semantic relationships (e.g., the similarity between "scallion" and "green onion").

Performance Metrics

S2SRec2 significantly outperformed traditional baselines, including Logistic Regression, Vanilla Neural Networks, and specialized models like Reciptor and Kitchenette. Key findings include:

  • Accuracy: The model achieved the highest Precision, Recall, and F1 scores across all test scenarios.
  • Cardinality Prediction: S2SRec2 was notably superior at estimating the correct number of missing items, achieving a Mean Squared Error (MSE) of 1.0331 for set size prediction at k=3, compared to approximately 1.7 for most baselines.
  • Qualitative Analysis: In practical tests, such as completing a "Layered Taco Dip," S2SRec2 correctly identified specific missing staples like refried beans, whereas baselines often suggested generic or irrelevant items like mayonnaise.

Discussion and Future Work

A significant insight from the research was that sequential models like Bi-LSTM performed poorly, confirming that imposing an artificial order on ingredient sets introduces noise. Furthermore, the "stop signal" provided by the completeness prediction prevents over-recommendation, ensuring the suggested items form a coherent culinary unit.

Future research will focus on integrating user-specific signals, such as dietary restrictions (e.g., vegan or gluten-free) and past purchase history, into the set representation. Additionally, the authors aim to evolve the system into a full-scale interactive recipe discovery engine that can surface complete recipe cards based on the predicted ingredient sets.

Summary updated

Abstract

In grocery e-commerce, customers often build ingredient baskets guided by dietary preferences but lack the expertise to create complete meals. Leveraging recipe knowledge to recommend complementary ingredients based on a partial basket is essential for improving the culinary experience. Traditional recipe completion methods typically predict a single missing ingredient using a leave-one-out strategy. However, they fall short in two key aspects: (i) they do not reflect real-world scenarios where multiple ingredients are often needed, and (ii) they overlook relationships among the missing ingredients themselves. To address these limitations, we reformulate basket completion as a set-to-set (S2S) recommendation problem, where an incomplete basket is input into a system that predicts a set of complementary ingredients. We introduce S2SRec2, a set-to-set ingredient recommendation framework based on a Set Transformer and trained in a multitask learning paradigm. S2SRec2 jointly learns to (i) retrieve missing ingredients from the representation of existing ones and (ii) assess basket completeness after prediction. These tasks are optimized together, enforcing accurate retrieval and coherent basket completion. Experiments on large-scale recipe datasets and qualitative analyses show that S2SRec2 significantly outperforms single-target baselines, offering a promising approach to enhance grocery shopping and inspire culinary creativity.
BibTeX
@misc{cao2025s,
  author = {Yanan Cao and Omid Memarrast and Shiqin Cai and Sinduja Subramaniam and Evren Körpeoglu and Kannan Achan},
  title = {{S2SRec2: Set-to-Set Recommendation for Basket Completion with Recipe}},
  year = {2025},
  eprint = {2507.09101},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.09101},
}
Figure