Learning Structural Representations for Recipe Generation and Food Retrieval

Hao Wang, Guosheng Lin, Steven Hoi, Chunyan Miao · DOI

TL;DR

This paper introduces a novel method to learn unsupervised, sentence-level tree structures for cooking recipes. These learned structures significantly improve both recipe generation from food images and food cross-modal retrieval tasks, achieving state-of-the-art performance on the Recipe1M dataset.

What Problem Does This Paper Address?

Generating coherent and detailed cooking instructions from food images is challenging due to the inherent complexity of recipes. Unlike typical image captioning tasks with single-sentence descriptions, recipes are lengthy, multi-sentence paragraphs that describe a sequential process. Furthermore, existing datasets often lack structural annotations for these recipes, making it difficult for models to grasp the underlying procedural logic. This paper tackles the problem of learning these implicit recipe structures to enhance both recipe generation and the retrieval of recipes based on food images (and vice-versa).

Methods

The core innovation lies in the recipe2tree module, which learns sentence-level tree structures for recipes in an unsupervised manner. This is achieved by extending the ON-LSTM architecture and training it using a "quick thoughts" approach to capture the sequential order of recipe steps. These learned tree structures then serve as "pseudo labels" for training an img2tree module. This module generates recipe tree structures directly from food images using an RNN.

For recipe generation, the generated image-based tree structures are encoded using Graph Attention Networks (GAT) and then combined with image and ingredient features. This combined representation is fed into a transformer decoder to generate the recipe instructions.

For food cross-modal retrieval, the learned recipe tree structures are encoded using GAT and concatenated with ingredient and instruction features to form enhanced recipe representations. These enhanced representations are then used to learn similarity with image features via a triplet loss.

Datasets

The primary dataset used for training and evaluation is Recipe1M. This dataset contains food images paired with ingredients and cooking instructions. The paper notes that this dataset differs from common image-text datasets like MS-COCO by featuring lengthy, multi-sentence recipe descriptions.

Key Insights and Ideas

  • Unsupervised Structure Learning is Key: The paper demonstrates that learning implicit structural information within recipes, even without explicit annotations, can significantly boost performance in downstream tasks.
  • Recipes are More Than Just Sentences: Treating recipes as simple sequences of sentences is insufficient. Their inherent hierarchical and procedural structure is crucial for accurate generation and retrieval.
  • Tree Structures Bridge Modalities: The learned tree structures act as a powerful intermediate representation, effectively connecting visual information (images) with textual information (recipes).
  • Img2tree for Retrieval is Tricky: While img2tree is beneficial for recipe generation, its direct application to retrieval is less straightforward. The accuracy of image-based tree generation directly impacts retrieval performance, suggesting a need for more robust image-to-tree models in this context.

Key Results

  • Recipe Generation: The proposed SGN model (Structure-aware Generation Network) significantly outperforms baseline models across perplexity, BLEU, and ROUGE-L metrics. For instance, with a pretrained BERT model, SGN achieves a BLEU score of 12.75, a substantial improvement over the baseline's 9.29. The generated recipes also exhibit a more comparable average length to human-written recipes (112.5 vs. 116.5 words).
  • Food Cross-Modal Retrieval: The inclusion of learned tree structures improves retrieval performance. For the 1k test set, the proposed method achieves a MedR of 1.0 for image-to-recipe retrieval and 1.0 for recipe-to-image retrieval, outperforming strong baselines like ACME (1.0 MedR but with slightly lower R@K scores).

Limitations and Future Work

  • Image Structure Ignored: The current framework focuses on learning textual structure. The authors acknowledge that food images themselves have inherent semantic structures (e.g., ingredient arrangements) that are not explicitly modeled. Future work could explore incorporating visual structural representations.
  • Img2tree Accuracy for Retrieval: The performance of the img2tree module in the retrieval task is sensitive to the accuracy of the generated trees. Future work could focus on improving the image-to-tree generation for better retrieval outcomes.
  • Redundant Sentences: While SGN generates longer recipes, it can sometimes produce redundant sentences. Better utilization of input ingredient information is suggested to mitigate this.
  • Extending to Videos: The authors propose extending their work to cooking video datasets, where temporal and visual-recipe correspondences can be explored.

Summary updated

BibTeX
@article{wang2021learning,
  author = {Hao Wang and Guosheng Lin and Steven HOI and Chunyan Miao},
  title = {{Learning Structural Representations for Recipe Generation and Food Retrieval}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2021},
  doi = {10.1109/tpami.2022.3181294},
}
Figure