Recipe-Generator / README.md
mansurii's picture
Upload folder using huggingface_hub
5a2c453 verified
|
Raw History Blame Contribute Delete
3.64 kB
metadata
language:
  - en
license: apache-2.0
task_categories:
  - text-generation
tags:
  - recipe
  - food
  - culinary
  - instruct
  - unsloth
  - trl
pretty_name: Recipe-Generator
size_categories:
  - n<1K

Recipe-Generator

A high-quality, curated dataset of 400 input/output pairs designed for training a Recipe-Generator to create practical, coherent recipes based on available ingredients.

Dataset Summary Card

Property Value
Records 400
Format JSONL (one JSON object per line)
Fields input, output
Language English
Splits train, validation, test

Topics: recipes, cooking, culinary arts, food preparation, ingredient utilization, meal planning, and global cuisines.

Dataset Structure

Data Fields

  • input (string): A comma-separated list of realistic ingredients provided by the user.
  • output (string): The generated recipe containing exactly three sections: Recipe name, Ingredients used (strictly matching inputs plus basic staples like salt, pepper, oil, water), and numbered cooking Steps.

Data Example

{"input": "cabbage, salt", "output": "Recipe name: Quick Homemade Sauerkraut\nIngredients: cabbage, salt, water\nSteps: 1. Shred cabbage and massage with salt until it releases liquid. 2. Pack into a jar with the liquid. 3. Ferment at room temperature 5-7 days."}

Data Splits

Split Records
train 320
validation 40
test 40

Usage

Standard Python

You can load all three splits into a Python dictionary containing lists of JSON objects.

import json

datasets = {}
splits = ["train", "validation", "test"]

for split in splits:
    with open(f"{split}.jsonl", encoding="utf-8") as f:
        datasets[split] = [json.loads(line) for line in f]

print("Train samples:", len(datasets["train"]))
print("Validation samples:", len(datasets["validation"]))
print("Test samples:", len(datasets["test"]))
print("\nFirst train sample:\n", datasets["train"][0])

Hugging Face Datasets

To load all files into a unified DatasetDict, pass a dictionary of file paths to data_files.

from datasets import load_dataset

data_files = {
    "train": "train.jsonl",
    "validation": "validation.jsonl",
    "test": "test.jsonl"
}

ds = load_dataset("json", data_files=data_files)
print(ds)

Convert to Chat Format (TRL / Unsloth)

Since the raw dataset uses input and output keys, you can map the entire DatasetDict directly into the standard messages format required by TRL, Unsloth, and SFTTrainer for fine-tuning small language models.

def to_chat(row):
    return {
        "messages": [
            {"role": "user", "content": f"Create a recipe using these ingredients: {row['input']}"},
            {"role": "assistant", "content": row["output"]},
        ]
    }

# Apply the mapping function to all splits in the DatasetDict simultaneously
chat_ds = ds.map(to_chat)

# Verify the format of the first training example
print(chat_ds["train"][0]["messages"])

Dataset Creation

This dataset was generated with strict quality controls prioritizing meaningful culinary diversity over random variation. The generation process adhered to strict ingredient guardrails, allowing only the provided inputs alongside basic pantry staples (salt, pepper, oil, water). Every sample across the training, validation, and test splits was independently verified to ensure no duplicates, near-duplicates, or hallucinated ingredients were included, resulting in a clean, high-signal dataset ready for fine-tuning.