Papers
Topics
Authors
Recent
Search
2000 character limit reached

Ratatouille: AI Recipe Generator

Updated 3 July 2026
  • Ratatouille is a web-based application for novel recipe generation that utilizes deep learning methods, including LSTM and fine-tuned Transformer models, to create structured culinary recipes.
  • The system benchmarks LSTM and GPT-2 medium models on a comprehensive RecipeDB corpus, significantly enhancing recipe structure, measurement precision, and instructional coherence.
  • Its full-stack design with a ReactJS front end, Flask back end, and Dockerized microservices facilitates scalable, interactive recipe generation tailored to user-specified ingredient constraints.

Ratatouille is a web-based application for novel recipe generation utilizing deep learning methodologies, specifically Long Short-Term Memory (LSTM) networks and fine-tuned Transformer models. Developed within the context of NLP, it addresses the challenge of constructing realistic, structured, and customizable culinary recipes from user-supplied ingredient lists. The system builds upon previous work in recipe language modeling, enhancing coherence, structural fidelity, and ingredient constraint handling by leveraging large-scale, structured recipe corpora and Transformer-based architectures (Goel et al., 2022).

1. Motivation and Design Objectives

The proliferation of user-generated cooking recipes online has established a substantial, diverse dataset for computational culinary creativity. Prior approaches—including LSTM-based LLMs, encoder–decoder checklist methods, and Transformer-based systems (e.g., RecipeGPT)—displayed promise but exhibited notable deficits. These included inadequate encoding of ingredient quantities and units, lax enforcement of canonical structure (segmentation into title, ingredients, instructions), and limited respect for user-imposed ingredient constraints.

Ratatouille was conceived to rectify these limitations through three principal objectives:

  1. Generate recipes with realistic titles, precise ingredient quantities (including fractional representations and standard units), and coherent, stepwise instructions.
  2. Rigorously benchmark LSTM baselines against a fine-tuned medium-size GPT-2 model trained on a comprehensive recipe corpus.
  3. Deliver the best-performing generation model via a responsive, web-accessible interface that supports interactive user customization (Goel et al., 2022).

2. Recipe Corpus and Data Engineering

The system is underpinned by RecipeDB (Batra et al., 2020), a globally comprehensive, structured collection of 118,171 recipes spanning six continents, 26 geo-cultural regions, and 74 countries. Each entry includes a title, explicit ingredient listings (quantified and unit-scoped), and stepwise cooking instructions. RecipeDB also features granular metadata on 20,262 ingredients, including links to FlavorDB and USDA nutritional data, metadata on cooking processes, and disease associations.

Preprocessing entailed strict curation:

  • Removal of incomplete or redundant instances.
  • Truncation/padding of recipes to a fixed 2,000-character window, capturing ≈95.46% of empirical recipe lengths within ±2σ.
  • Merging of outlier-short recipes (those <–3σ) for mean-length normalization.
  • Serialization of each recipe into an explicit tag-based format:
    1
    
    <title>…</title><ingredients>…</ingredients><instructions>…</instructions>
    For GPT-2 fine-tuning, each valid recipe was paired with a “vanilla” (randomly constructed) pseudo-recipe within each example to expedite convergence (Goel et al., 2022).

3. Model Architectures and Training

3.1 LSTM Baselines

Two classes of LSTM architectures were evaluated: character-level and word-level variants. Inputs were processed via appropriate embedding lookups (character or word), followed by stacked LSTM layers, culminating in a dense softmax head for next-token prediction. Loss was standard cross-entropy at the character or word level. The canonical LSTM cell update equations are included for reference; however, hyperparameters such as the number of layers, sizes, or dropout rates are unspecified in the source.

3.2 Transformer-Based Model

The principal model is the “medium” GPT-2 Transformer (approximately 345 million parameters, 24 layers, hidden size 1,024, 16 heads), initialized with Hugging Face weights and fine-tuned on the tag-preprocessed RecipeDB. The architecture implements standard Transformer modules, including multi-head attention and position-wise feed-forward sublayers:

  • Multi-Head Attention:

Q=XWϕ,  K=XWk,  V=XWv;  headi=softmax(QiKiTdk)ViQ = XW^{\phi},\; K = XW^k,\; V = XW^v;\; \text{head}_i = \text{softmax}\left(\frac{Q_i K_i^T}{\sqrt{d_k}}\right)V_i

  • Feed-Forward:

FFN(x)=max(0,xW1+b1)W2+b2FFN(x) = \max(0, xW_1 + b_1)W_2 + b_2

Loss remains cross-entropy on the next token. No explicit hyperparameter search is described; the implementation uses Hugging Face’s default fine-tuning settings (nominally learning rate ≈ 5×1055 \times 10^{-5}, batch size 8–16) (Goel et al., 2022).

3.3 Training Protocol

GPU-accelerated training was performed using Nvidia A100 TensorCore servers for the GPT-2 model, achieving convergence in ≈16 hours; CPU-based fine-tuning (Google Colab) required 2–3 days. Checkpointing and stopping criteria are not exhaustively detailed; training was continued to BLEU improvement saturation (Goel et al., 2022).

4. Quantitative Evaluation

BLEU score (bilingual evaluation understudy, n-gram overlap) serves as the quantitative benchmark against a held-out RecipeDB test split, computed as:

BLEU=BPexp(n=14wnlogpn)BLEU = BP \cdot \exp\left(\sum_{n=1}^4 w_n \log p_n\right)

The comparative BLEU scores for evaluated models are:

Model BLEU
Char-level LSTM 0.347
Word-level LSTM 0.412
DistilGPT-2 0.442
GPT-2 medium 0.806

The GPT-2 medium significantly outperforms both recurrent and distilled Transformer baselines, demonstrating superior retention of recipe structure, ingredient/quantity coherence, and instructional fluency. The paper does not report perplexity, human evaluation (sensory or feasibility ratings), or metrics grounded in flavor/nutrition similarity, limiting interpretability to surface-level linguistic similarity (Goel et al., 2022).

5. System Demonstration and API Design

Ratatouille is implemented as a full-stack web application (https://cosylab.iiitd.edu.in/ratatouille2/), with a ReactJS-based front end and a Flask back end, each decoupled and containerized for scalability. The user interface accepts arbitrary ingredient lists (comma-separated), optional cuisine tags, and desired level of stepwise detail (brief vs. detailed). On submission, an AJAX POST transmits the request to a RESTful “/generate” endpoint, which returns a JSON representation of the generated recipe. Planned functionality includes vegetarian/vegan filters and adaptive step counts.

The backend microservices are Dockerized, suitable for horizontal scaling and straightforward replication on IIIT-Delhi servers or similar cluster environments. This architecture supports efficient load balancing and separates model inference from database and user interface logic (Goel et al., 2022).

6. Representative Outputs and Format

The generated recipes are presented in the application’s explicit tag-based format. Two publicly shared examples illustrate the output format and content:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<title>Spiced Chickpea & Tomato Stew</title>
<ingredients>
  – 2 cups canned chickpeas (drained)
  – 1 cup diced tomatoes (fresh or canned)
  – 1 small onion, chopped
  – 2 garlic cloves, minced
  – 1 tsp ground cumin
  – ½ tsp smoked paprika
  – 1 tbsp olive oil
  – Salt and pepper to taste
</ingredients>
<instructions>
  1. Heat olive oil in a pot over medium heat. Sauté onion until translucent.
  2. Add garlic, cumin, and smoked paprika; cook 1 more minute.
  3. Stir in diced tomatoes and simmer 5 minutes.
  4. Add chickpeas, season with salt & pepper; simmer 10 minutes.
  5. Serve hot with rice or crusty bread.
</instructions>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<title>Herbed Lemon Chicken Salad Wraps</title>
<ingredients>
  – 2 cups cooked shredded chicken
  – ¼ cup Greek yogurt
  – 1 celery stalk, diced
  – 1 tbsp chopped fresh parsley
  – Juice of ½ lemon
  – 6 whole-wheat tortilla wraps
  – Salt, pepper, and olive oil as needed
</ingredients>
<instructions>
  1. In a bowl, mix chicken, yogurt, parsley, celery, and lemon juice until combined.
  2. Season with salt and pepper.
  3. Warm tortillas briefly in a skillet with a drizzle of olive oil.
  4. Spoon chicken salad onto each wrap and roll tightly.
  5. Slice in half and serve immediately or chill.
</instructions>

This format encodes all required metadata—title, precise ingredients with standard measures, and procedural steps—in a machine-parseable, yet human-readable, representation (Goel et al., 2022).

7. Limitations, Failure Modes, and Future Work

The primary quantitative evaluation metric is BLEU score; there are no sensory/human evaluation studies, nutritional/balancing verifications, or domain-specific plausibility checks. Occasionally, the generation omits ingredient quantities, produces implausible instructions (e.g., “bake on the stove”), or mishandles rare unit conversions (e.g., grams-to-cups mapping). Resource constraints—limited GPU availability, RAM, storage on Google Colab—precluded experimentation with larger models (e.g., GPT-Neo, GPT-3), although these are logical future extensions.

Failure modes include pronounced reliance on frequent ingredient pairs (cliché outputs with rare or atypical ingredients) and incomplete handling of user-imposed quantity or step constraints. Planned research directions entail:

  • Adoption of larger, more contextually adept Transformer architectures.
  • Modular integration of nutrition/flavor knowledge.
  • Systematic human-subject experiments on taste, feasibility, and novelty of generated outputs.
  • Enhanced interface modalities (voice, mobile).
  • On‐the‐fly normalization and improved precision in quantification (Goel et al., 2022).

Ratatouille represents a state-of-the-art system for data-driven, structural recipe generation, evidencing the applicability of modern NLP architectures to high-utility, domain-specific generative text tasks.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Ratatouille.