Attention-based Ingredient Phrase Parser

Zhengxiang Shi, Pin Ni, Meihui Wang, To Eun Kim, Aldo Lipani

Introduction

As conversational AI agents like Alexa and Siri evolve, their utility in specialized domains such as guided cooking is increasingly scrutinized. To provide meaningful assistance, these agents must move beyond simple keyword matching and understand recipes at a granular level. However, ingredient lists found online are often unstructured and exhibit significant lexical variation—for instance, "1 (8 ounce) package cream cheese, softened" versus "1 garlic clove, crushed."

To answer specific user queries like "How much cheese do I need?" or "Does the butter need to be melted?", an AI must accurately extract attributes such as Name, Quantity, Unit, and State. This paper introduces a novel attention-based neural network designed to parse these messy ingredient phrases into structured data with state-of-the-art precision.

Model Architecture

The proposed model treats ingredient parsing as a token classification task. The architecture is divided into three primary components:

  1. Text Encoder: The system tokenizes the input phrase and maps tokens to 300-dimensional pre-trained GloVe word embeddings. To capture syntactic nuances, the model also extracts Part-of-Speech (POS) tags using the NLTK toolkit. These tags are embedded via a trainable lookup table and summed with the word embeddings, providing a strong structural prior.
  2. Attention-based Recurrent Module: The core of the network consists of four stacked layers ($N=4$). Each layer features a self-attention mechanism followed by a feed-forward network, incorporating dropout and layer normalization. This design allows the model to capture long-range dependencies, such as linking a state descriptor like "softened" at the end of a phrase back to the ingredient "cream cheese."
  3. Output Layer: A final linear projection and softmax layer classify each token into one of eight categories: Name, State, Unit, Quantity, Size, Temperature, Dry/Fresh, or Others.
Architecture of the proposed attention-based ingredient phrase parser.

Dataset and Evaluation

The model was evaluated using two datasets derived from RecipeDB: AllRecipes (1,470 training phrases) and Food.com (5,142 training phrases). These datasets provide a diverse range of ingredient descriptions to test the model's robustness.

A significant focus of this work was addressing the "reproducibility gap" in existing literature. While previous state-of-the-art models claimed F1-scores as high as 0.95, the authors found that without open-source code, a reproduced version of the leading baseline only achieved an F1-score of approximately 0.61. This discrepancy highlights the importance of the authors' commitment to open-sourcing their high-performing model.

Results

The proposed model demonstrates exceptional performance across all metrics. When trained and tested on a combined dataset, it achieved an overall 93.64 F1-score, vastly outperforming the reproduced baseline's 60.83. In specific scenarios, such as testing on the AllRecipes set after training on the combined data, the F1-score reached as high as 97.30.

Entity-level performance comparison between the proposed model and the reproduced baseline.

As shown in the entity-level breakdown, the model is particularly adept at identifying core attributes:

  • Quantity: 96.47 F1-score
  • Unit: 95.68 F1-score
  • Name: 93.31 F1-score

While attributes like "Temperature" proved more challenging (80.90 F1-score), the model still maintains a high standard of accuracy across the board, providing the reliable data extraction necessary for fluid conversational interactions.

Conclusion

By leveraging self-attention and syntactic signals from POS tags, this model successfully parses complex recipe data into actionable information. The high accuracy in extracting quantities, units, and ingredient names directly translates to a more capable conversational agent. Future work will focus on integrating this parser into end-to-end systems to evaluate its impact on user satisfaction in real-world cooking scenarios.

Summary updated

BibTeX
@inproceedings{shi2022attention,
  author = {Zhengxiang Shi and Pin Ni and Meihui Wang and To Eun Kim and Aldo Lipani},
  title = {{Attention-based Ingredient Phrase Parser}},
  booktitle = {ESANN},
  year = {2022},
  url = {https://openreview.net/forum?id=azO0CJjYkeZ},
}
Figure