This blog-style summary provides an overview of the research paper "S2SRec2: Set-to-Set Recommendation for Basket Completion with Recipe," authored by researchers at Walmart Global Tech.
TL;DR
S2SRec2 moves beyond traditional "predict-the-next-item" recommendations by treating recipe completion as a set-to-set problem. Using a Set Transformer and multi-task learning, the model recommends a coherent group of missing ingredients and—crucially—dynamically predicts when a basket is "complete" for a specific meal.
What Problem Does This Paper Address?
In grocery e-commerce, customers often have a few ingredients in their cart but lack the culinary expertise to know what else is needed to make a full meal. Traditional recommendation systems tackle this using a "leave-one-out" strategy: they hide one ingredient and try to predict it.
However, this fails in two major ways:
- Complexity: Real-world users often need to add multiple ingredients, not just one.
- Coherence: Existing methods focus on the relationship between what’s in the cart and the missing item, but they ignore how the missing items relate to each other.
The authors argue that recipe completion should be a "set-to-set" (S2S) task, where the system understands the synergy of an entire ingredient set and knows exactly when to stop suggesting more items.
Methods
The researchers introduced S2SRec2, which utilizes two primary architectural choices:
- Set Transformer: Unlike standard Transformers or RNNs, Set Transformers are "permutation invariant." This is perfect for recipes because the order in which you put ingredients in a digital basket doesn't change the final dish. It excels at capturing complex inter-dependencies between items.
- Multi-task Learning (MTL): The model is trained to solve two problems simultaneously:
- Missing Ingredient Query: A learnable query vector "interrogates" the current basket to predict the most likely next ingredient.
- Completeness Prediction: A binary classifier that acts as a "stop signal," determining if the current set of ingredients (original + predicted) forms a complete recipe.
The Inference Loop: During use, the model doesn't just dump a list of items. It suggests an item, adds it to the virtual basket, checks if the basket is "complete," and repeats the process until the completeness probability exceeds 50%.
Datasets
The study used a large-scale culinary dataset from food.com.
- Scale: 141,782 recipes and 3,804 unique ingredients.
- Preprocessing: The authors filtered for recipes with 5–15 ingredients to ensure enough complexity for analysis while focusing on common cooking patterns.
- Embeddings: Ingredients were projected into 768-dimensional vectors using a pretrained BERT model to capture semantic meaning (e.g., knowing that "scallion" and "green onion" are related).
Key Insights and Ideas
- Order is a Distraction: One of the most interesting findings was that the Bi-LSTM baseline performed the worst. This suggests that forcing a sequential order on an unordered set of ingredients actually introduces noise that confuses the model.
- The "Stop Signal" is Essential: Most recommenders provide a ranked list of N items. S2SRec2’s ability to say "you have enough now" prevents over-recommending and ensures the suggested set is a coherent culinary unit rather than just a collection of likely-looking items.
- Synergy over Similarity: By using a query-based attention mechanism, the model learns which ingredients complement each other (synergy) rather than just which ingredients are similar to each other.
Key Results
S2SRec2 significantly outperformed baselines like Logistic Regression, Vanilla Neural Networks, and specialized models like Reciptor and Kitchenette.
- Accuracy: It achieved the highest Precision, Recall, and F1 scores across the board.
- Cardinality Prediction: The model was much better at estimating the correct number of missing items. It achieved a Mean Squared Error (MSE) of 1.0331 for set size prediction at k=3, compared to ~1.7 for most baselines.
- Qualitative Success: In tests (like completing a "Layered Taco Dip"), S2SRec2 correctly identified specific missing staples like refried beans, while baselines often suggested generic or unrelated items like mayonnaise or celery.
Limitations and Future Work
- The "Ground Truth" Hurdle: The authors noted that absolute precision numbers (around 3%) look low. This is a common issue in recipe AI: there are thousands of ingredients, and a model might suggest a perfectly valid completion (like "lime juice") that simply wasn't in the specific ground-truth recipe used for training.
- Personalization: The current model treats all users the same. Future work aims to integrate user-specific signals, such as past purchase history and dietary restrictions (e.g., vegan or gluten-free), into the set representation.
- Recipe Discovery: The authors plan to evolve the system from a "complement recommender" into a full-blown interactive recipe discovery engine that can surface entire recipe cards based on the completed basket.
Summary updated