: Learning to predict ingredient quantities from recipe contexts

Donghee Choi, Mogan Gim, Samy Badreddine, Hajung Kim, Donghyeon Park, Jaewoo KangExpert Systems with Applications 2023 · OpenReview

TL;DR

This paper introduces KitchenScale, a novel system that uses pre-trained language models (PLMs) to predict ingredient quantities and units from recipe text. By breaking down the problem into measurement type classification, unit classification, and quantity regression, and employing a specialized regression technique (DExp), KitchenScale achieves robust ingredient quantity prediction, offering a step towards more intelligent cooking assistants.

What Problem Does This Paper Address?

Determining the correct quantities of ingredients is crucial for successful cooking, impacting taste and health. While many NLP approaches have focused on recipe generation or retrieval, accurately predicting ingredient quantities has remained a challenge. Existing methods often treat numerical quantities as text, failing to capture their true numerical nature, or rely on ratios rather than absolute amounts. This gap highlights the need for a data-driven model that can understand the nuances of recipe context to predict precise ingredient quantities.

Methods

The core of KitchenScale is a fine-tuned Pre-trained Language Model (PLM), specifically BERT, adapted for the ingredient quantity prediction task. This task is decomposed into three sub-tasks:

  • Ingredient Measurement Type Classification: Predicting whether an ingredient is measured by weight or volume.
  • Unit Classification: Identifying the specific unit of measurement (e.g., cups, grams, ounces).
  • Quantity Regression: Estimating the numerical value of the ingredient quantity.

A key innovation is the use of the Discrete Latent Exponent (DExp) method for the quantity regression task. This approach is designed to handle the high variance and multi-modal distributions often found in numerical data within recipe corpora, which traditional regression methods (like Mean Squared Error) struggle with. The model leverages transfer learning by fine-tuning BERT on a large corpus of recipe texts to acquire cooking knowledge.

Datasets

The researchers constructed a dataset for KitchenScale by merging data from RecipeDB (Batra et al., 2020) and Reciptor (Li and Zaki, 2020). This combined dataset contains 101,573 recipes. For training and evaluation, the dataset was split into training, validation, and test sets in an 8:1:1 ratio.

Key Insights and Ideas

  • Decomposition is Key: Breaking down the complex task of ingredient quantity prediction into three distinct, yet related, sub-tasks (type, unit, quantity) allows for a more targeted and effective modeling approach.
  • DExp for Numerical Variance: The DExp method proves crucial for handling the inherent variability in how quantities are expressed in recipes, outperforming simpler regression techniques. This highlights the importance of specialized numerical handling in NLP tasks.
  • Transfer Learning from Recipes: Fine-tuning PLMs on a large recipe corpus effectively imbues them with "cooking knowledge," enabling them to better understand recipe semantics and predict quantities.
  • Context Matters: The model's success hinges on its ability to leverage various contextual elements of a recipe (title, other ingredients, tags, servings) to make accurate predictions.

Key Results

  • Ingredient Measurement Type Classification: KitchenScale achieved an accuracy of 0.9233 using BERT with all recipe context elements, outperforming baselines and ablations.
  • Ingredient Measurement Unit Classification: The model achieved an accuracy of 0.7335 for this task, again demonstrating the benefit of fine-tuned BERT and comprehensive recipe context.
  • Ingredient Quantity Regression: KitchenScale achieved strong results across multiple metrics, including E-Acc of 0.7365, LMAE of 0.3333, MAPE of 1.4380, and MAE of 109.9340. These results indicate its ability to capture quantity scales effectively.
  • Qualitative Analysis: The model demonstrated impressive performance on various ingredients (chicken, beef, water, pepper), with prediction errors generally below 6% for meat and 10% for water. It also showed an understanding of context-specific measurements, like using volume for pepper in a "Beef Wellington" recipe.

Limitations and Future Work

  • Limitations: The paper acknowledges that the model's performance can be sensitive to the quality and completeness of the input recipe context. While the DExp method handles variance, extreme outliers or highly ambiguous recipes might still pose challenges.
  • Future Work: The authors propose several exciting directions:
  • Personalization: Incorporating user-specific behaviors and preferences to tailor recommendations.
  • Integration: Connecting KitchenScale with other food computing systems for tasks like food pairing and ingredient recommendation.
  • Downstream Tasks: Applying KitchenScale's learned numerical understanding to other NLP tasks like recipe generation and retrieval.
  • Enhanced User Experience: Improving feedback mechanisms and error correction to continually update the knowledge base.

Summary updated

Abstract

Highlights•We introduce an ingredient quantity prediction task consisting of three sub-tasks.•We developed KitchenScale which performs the ingredient quantity prediction task.•KitchenScale adopts transfer learning of cooking knowledge from recipes to PLMs.•Robustness in KitchenScale is attributed to the DExp approach for the quantity regression task.
BibTeX
@article{choi2023learning,
  author = {Donghee Choi and Mogan Gim and Samy Badreddine and Hajung Kim and Donghyeon Park and Jaewoo Kang},
  title = {{: Learning to predict ingredient quantities from recipe contexts}},
  journal = {Expert Systems with Applications},
  year = {2023},
  url = {https://openreview.net/forum?id=F0WFMl0Ltn},
}
Figure