Spaces:
Running
Running
A newer version of the Gradio SDK is available:
5.43.1
metadata
title: Recipe-GPT
emoji: 🍳
colorFrom: yellow
colorTo: red
sdk: gradio
sdk_version: 4.27.0
app_file: app.py
pinned: false
license: mit
tags:
- gpt2
- gradio
- transformers
- recipe-generation
- huggingface
short_description: 'Turn ingredients into step-by-step cooking directions. '
Recipe-GPT
This project fine-tunes the pretrained openai-community/gpt2
model using Hugging Face’s transformers
and datasets
libraries on a large corpus of human-written recipes.
The goal is to teach GPT-2 how to generate coherent cooking instructions from a list of ingredients.
Key Features:
- Base Model: GPT-2 (117M) from Hugging Face Model Hub
- Frameworks:
transformers
for model loading, training, and generationdatasets
for loading and managing large recipe dataTrainer
API for end-to-end fine-tuning
- Custom Tokens:
- Added
<start>
and<end>
tokens to mark recipe boundaries - Tokenizer and model embeddings resized accordingly
- Added
- Data Format:
- Recipes formatted as plain text blocks with titles, ingredients, and step-by-step directions
- Training Strategy:
- Causal language modeling (not masked)
- Evaluated on validation set each epoch
- Supports CPU, CUDA, and Apple MPS backends
This setup allows the model to learn full-text generation patterns and structure, making it effective at translating structured ingredient lists into complete, human-readable cooking instructions.
Dataset
Source: tengomucho/all-recipes-split
2.1M+ recipes with:
title
ingredients
directions
How to Use
Install dependencies
pip install -r requirements.txt
Download dataset and tokenize
python scripts/dataset.py
Train the model
python scripts/train.py
Run Inference
python scripts/inference.py
Enter comma-separated ingredients when prompted, for example,
Enter ingredients (comma-separated): chicken, rice, garlic