Visually-aware Collaborative Food Recommendation

Xiaoyan Gao, Fuli Feng, Xiangnan He, Heyan Huang, Xinyu Guan, Chong Feng, Zhaoyan Ming, Tat-Seng ChuaarXiv 2018

Abstract

Food recommender systems play an important role in assisting users to identify the desired food to eat. Deciding what food to eat is a complex and multi-faceted process, influenced by factors such as ingredients, visual appearance, personal preference, and historical context. In this work, we formulate the food recommendation problem as predicting user preference based on three key factors: 1) user history; 2) recipe ingredients; and 3) descriptive images. We develop a dedicated neural network solution, Hierarchical Attention based Food Recommendation (HAFR), which captures collaborative filtering effects, infers ingredient-level preferences, and learns from visual content. Extensive experiments on a large-scale dataset from AllRecipes.com show that HAFR outperforms competing solutions like Factorization Machines and Visual Bayesian Personalized Ranking by an average of 12%.

Introduction

Most recommendation engines treat items as "atomic" units—simple IDs in a database. However, food is fundamentally different. A user’s preference for a recipe is rarely about the recipe ID itself; rather, it is driven by the specific ingredients used or the visual appeal of the final dish. Deciding what to eat involves a nuanced interplay between what similar people enjoy (collaborative filtering) and the specific content of the dish (content-based filtering).

Existing research often fails to capture this nuance, focusing on either ingredients or images in isolation. To bridge this gap, we identify three critical characteristics of food recommendation: food is non-atomic (a sum of its parts), visuals convey preparation methods that text might miss, and preferences are dynamic and personalized. A truly effective system must understand that one user might be an "ingredient-driven" eater while another is a "visual" eater.

The HAFR Framework

To address these challenges, we propose the Hierarchical Attention based Food Recommendation (HAFR) network. HAFR is designed to fuse user-recipe interaction history, recipe ingredients, and recipe images through a dual-layer attention mechanism.

Hierarchical Attention Mechanism

The core innovation of HAFR lies in its ability to weigh different components of a recipe based on individual user profiles:

  1. Ingredient-level Attention: Instead of treating all ingredients equally, this layer learns to "attend" to specific ingredients that a user prefers. For example, if a user frequently consumes spicy dishes, the model assigns a higher weight to "chili" when representing a new recipe for that user.
  2. Component-level Attention: This higher-level layer determines the relative importance of the Recipe ID (collaborative signal), the Ingredients (textual content), and the Image (visual content). It recognizes that the weight of these factors varies by user.
Personalized ingredient attention across different users.

For visual feature extraction, we utilize a ResNet-50 architecture, pre-trained on ImageNet and fine-tuned on food categories. These features are projected into a latent space compatible with user and ingredient embeddings. The final prediction is generated by a Multi-Layer Perceptron (MLP) using a pairwise ranking loss.

Experimental Setup and Datasets

Because existing food datasets often lack the user-interaction data necessary for recommendation tasks, we constructed a new large-scale benchmark from AllRecipes.com. This dataset contains over 1 million ratings from 68,768 users across 45,630 recipes featuring 33,147 unique ingredients. The dataset exhibits a realistic "long tail" distribution, providing a challenging testbed for our algorithms.

Key Results and Insights

HAFR was evaluated against several strong baselines, including Factorization Machines (FM) and Visual Bayesian Personalized Ranking (VBPR). Key findings include:

  • Superior Accuracy: HAFR achieved an average 12% improvement over the best-performing baseline (FM-VBPR) across metrics such as AUC, NDCG, and Recall.
  • Visual-Textual Complementarity: Our results confirm that images and ingredients provide non-redundant information. An image can reveal cooking styles (e.g., fried vs. steamed) that are not explicitly captured in a sparse ingredient list.
  • Robustness in Cold-Start Scenarios: The model maintained high performance even for niche recipes with few ratings, as it could rely on ingredient and visual similarities to make accurate predictions.

Conclusion and Future Work

HAFR represents a significant step toward more human-centric food recommendation by giving systems a "taste" for ingredients and aesthetics. Future work will explore incorporating nutritional and health factors, understanding functional relationships between ingredients (e.g., lime and lemon as substitutes), and accounting for contextual factors like time of day and weather.

Summary updated

BibTeX
@misc{gao2018visually,
  author = {Xiaoyan Gao and Fuli Feng and Xiangnan He and Heyan Huang and Xinyu Guan and Chong Feng and Zhaoyan Ming and Tat-Seng Chua},
  title = {{Visually-aware Collaborative Food Recommendation}},
  year = {2018},
  eprint = {1810.05032},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1810.05032},
}
Figure