File size: 3,641 Bytes
7c58a59
5a2c453
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c58a59
5a2c453
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
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

```json
{"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.

```python
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`.

```python
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.

```python
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.