Table of Contents
Fetching ...

Monte Carlo Tree Search for Recipe Generation using GPT-2

Karan Taneja, Richard Segal, Richard Goodwin

TL;DR

The paper addresses unreliable long-range coherence in LLM-generated recipes by introducing RecipeMC, a decoding framework that uses Monte Carlo Tree Search over a fine-tuned GPT-2 to enforce soft constraints via handcrafted rewards. The approach combines $Z=20$ search iterations, PUCB-based token selection with $PUCB(i) = Q(i) + c \cdot p(x_i|x_{1:i-1}) \frac{\sqrt{N}}{n_i+1}$, top-$k$ expansion, and top-$p$ simulations to produce ingredient lists and instructions that align with the recipe name and content. Across Name→Ingr and Name+Ingr→Inst tasks, RecipeMC outperforms top-$p$ baselines on automatic metrics (coherence, $F_1$, ROUGE, BLEU, perplexity) and yields higher perceived human-likeness in a Recipe Turing Test, with preferences around 55% for ingredients and 62% for instructions. The work demonstrates that MCTS with simple reward signals can improve structured text generation without additional training, enabling flexible, constraint-driven recipe design and potential interactive collaboration with chefs and applications exposed via APIs.

Abstract

Automatic food recipe generation methods provide a creative tool for chefs to explore and to create new, and interesting culinary delights. Given the recent success of large language models (LLMs), they have the potential to create new recipes that can meet individual preferences, dietary constraints, and adapt to what is in your refrigerator. Existing research on using LLMs to generate recipes has shown that LLMs can be finetuned to generate realistic-sounding recipes. However, on close examination, these generated recipes often fail to meet basic requirements like including chicken as an ingredient in chicken dishes. In this paper, we propose RecipeMC, a text generation method using GPT-2 that relies on Monte Carlo Tree Search (MCTS). RecipeMC allows us to define reward functions to put soft constraints on text generation and thus improve the credibility of the generated recipes. Our results show that human evaluators prefer recipes generated with RecipeMC more often than recipes generated with other baseline methods when compared with real recipes.

Monte Carlo Tree Search for Recipe Generation using GPT-2

TL;DR

The paper addresses unreliable long-range coherence in LLM-generated recipes by introducing RecipeMC, a decoding framework that uses Monte Carlo Tree Search over a fine-tuned GPT-2 to enforce soft constraints via handcrafted rewards. The approach combines search iterations, PUCB-based token selection with , top- expansion, and top- simulations to produce ingredient lists and instructions that align with the recipe name and content. Across Name→Ingr and Name+Ingr→Inst tasks, RecipeMC outperforms top- baselines on automatic metrics (coherence, , ROUGE, BLEU, perplexity) and yields higher perceived human-likeness in a Recipe Turing Test, with preferences around 55% for ingredients and 62% for instructions. The work demonstrates that MCTS with simple reward signals can improve structured text generation without additional training, enabling flexible, constraint-driven recipe design and potential interactive collaboration with chefs and applications exposed via APIs.

Abstract

Automatic food recipe generation methods provide a creative tool for chefs to explore and to create new, and interesting culinary delights. Given the recent success of large language models (LLMs), they have the potential to create new recipes that can meet individual preferences, dietary constraints, and adapt to what is in your refrigerator. Existing research on using LLMs to generate recipes has shown that LLMs can be finetuned to generate realistic-sounding recipes. However, on close examination, these generated recipes often fail to meet basic requirements like including chicken as an ingredient in chicken dishes. In this paper, we propose RecipeMC, a text generation method using GPT-2 that relies on Monte Carlo Tree Search (MCTS). RecipeMC allows us to define reward functions to put soft constraints on text generation and thus improve the credibility of the generated recipes. Our results show that human evaluators prefer recipes generated with RecipeMC more often than recipes generated with other baseline methods when compared with real recipes.
Paper Structure (10 sections, 1 equation, 5 figures, 5 tables)

This paper contains 10 sections, 1 equation, 5 figures, 5 tables.

Figures (5)

  • Figure 1: Examples of inconsistencies in generated recipes. In the first example, an important ingredient "Shrimp" is missing from the baseline ingredients list. In the second example, baseline instructions do not use the ingredient "lemon zest". Our method, RecipeMC, also refers to the complete names of the ingredients such as "pepper Jack cheese" and "green onion" rather than shortening them to "grated cheese" and "onion" respectively.
  • Figure 2: Recipe format used to fine-tune GPT-2. Special tokens define the start and end of each recipe section.
  • Figure 3: In the Name$\rightarrow$Ingr task the system is given a recipe name and asked to generate a list of ingredients.
  • Figure 4: In the Name+Ingr$\rightarrow$Inst task the system is given a recipe name and a list of ingredients. The system is then asked to generate cooking instructions.
  • Figure 5: An illustrative example of RecipeMC in action for generating instructions. The initial prompt is "...add hot sauce. Next, mix all". The four MCTS steps Selection, Expansion, Simulation and Backpropagation are shown and color coded.