Introduction
Compositional generalization—the ability of a system to combine known components into novel configurations—is a hallmark of human intelligence. While modern Large Language Models (LLMs) demonstrate impressive performance on synthetic benchmarks, their ability to reason through complex, real-world procedural changes remains under-explored. This paper introduces Counterfactual Recipe Generation (CRG), a task designed to test whether models can adapt a base recipe when a single ingredient is substituted (e.g., replacing pork with fish). This requires more than simple word-swapping; it demands an understanding of the underlying procedural logic and the causal relationships between ingredients and cooking actions.
Task Definition and Methodology
The researchers frame CRG as a conditional generation problem: given a base recipe $y$, an original ingredient set $x_y$, and a new target ingredient set $x'$, the model must generate a target recipe $y'$.
To evaluate current capabilities, the authors tested three distinct approaches using a 102M-parameter GPT-2 backbone:
- Direct Generation (GPT-2 D/D+R): The model generates a recipe from scratch or rewrites the original based on a prompt.
- Editing-based (EDUCAT): An iterative model that identifies contradictions in the base recipe and applies local edits (insertion, deletion, or replacement).
- Constraint-based (DELOREAN): A model that generates a draft for the target dish and uses back-propagation to ensure the output maintains the stylistic characteristics of the original recipe.
The XIACHUFANG Dataset
To support this research, the authors introduced the XIACHUFANG Recipe Dataset, a massive collection of 1.55 million Chinese recipes. This dataset is significantly larger than previous benchmarks like Recipe1M+. For rigorous evaluation, the authors curated 50 "dish pairs" (e.g., Spicy Crayfish vs. Spicy Chicken Feet) and 2,500 specific instances. These pairs include fine-grained, action-level annotations to track whether models correctly add or remove specific culinary steps necessitated by the ingredient swap.
Competency Levels: Surface vs. Action
A key contribution of this work is the distinction between two levels of model competency:
- Level 1 (L1) - Surface-level: The ability to mention the new ingredient in the text.
- Level 2 (L2) - Action-level: The ability to adjust the cooking process (e.g., removing "blanching" for fish or adding "de-shelling" for seafood).
To measure L2 competency, the authors used causal estimation to identify "pivot actions"—steps statistically required for the new ingredient but irrelevant to the old one.
Key Results and Analysis
The experimental results reveal a significant gap between surface-level fluency and procedural logic:
- The L1/L2 Gap: While models like DELOREAN achieved high ingredient coverage (90.8%), they failed to correctly adjust the cooking actions. All models performed poorly on "Hard" action-level evaluations, with the best model achieving only a 17.5% F1 score in correctly modifying necessary actions.
- Style vs. Substance: There is a clear trade-off between preserving the original chef's style and making logical changes. EDUCAT preserved the original text well (BLEU 24.4) but failed to change ingredients effectively (43.5% coverage). Conversely, models that successfully changed ingredients often lost the original recipe's stylistic nuances.
- Human vs. AI: Human experts outperformed models by a massive margin. On a correctness scale of -100 to 100, the best model scored -7.3, while humans scored 82.5.
- Causal Failures: Models frequently struggle with the chronological order of operations, such as failing to understand that a crab must be de-shelled before its gills are removed.
Discussion and Limitations
The study highlights that current Pretrained Language Models (PLMs) lack deep procedural common sense. They are "fluent but shallow," often leaving nonsensical steps in place (e.g., "cleaning the scales" of a chicken).
Limitations of the current study include its focus on Chinese cuisine and the inherent difficulty of evaluating "object omission"—the tendency for human-written recipes to omit obvious steps (like washing vegetables). Future work aims to move beyond statistical word association toward models that explicitly represent the causal dependencies between ingredients and actions.
Summary updated