🍳 Fridge Leftover Recipe Generator (Qwen2.5-1.5B-Instruct)
An instruction-tuned Small Language Model (SLM) designed to transform available leftover fridge ingredients into customized, step-by-step cooking recipes.
This model was fine-tuned on top of Qwen2.5-1.5B-Instruct using Parameter-Efficient Fine-Tuning (QLoRA) to provide fast, practical, and highly creative meal ideas without requiring hallucinated external ingredients.
💡 Model Description
- Developed by: Adel Hani Mohamed Adlan
- Model Type: Causal Language Model / Instruction-Tuned SLM
- Base Model:
Qwen/Qwen2.5-1.5B-Instruct - Fine-Tuning Method: QLoRA (4-bit quantization with LoRA adapters)
- Language(s): English
- License: Apache 2.0
🎯 Intended Uses & Limitations
Primary Use Cases
- Home Cooking & Meal Planning: Input a list of random fridge leftovers, and get an immediate recipe title, ingredients breakdown, step-by-step cooking instructions, and chef tips.
- Food Waste Reduction: Encourages creative usage of existing household ingredients before they expire.
- Edge / Local Deployment: Thanks to its compact 1.5B size, the model can run efficiently on low-VRAM GPUs, CPUs, or mobile devices via quantization.
Limitations & Out-of-Scope
- Nutritional Accuracy: Caloric and nutritional estimations are generalized and should not replace professional dietary advice.
- Severe Allergies: Always verify ingredients for specific medical allergies manually.
🛠️ Training Details
Training Data
The model was fine-tuned on a synthetic instruction-tuning dataset created using advanced LLM dataset orchestration (via Groq API / Qwen 2.5). Each sample consists of:
- Instruction: System context defining the role of a creative chef.
- Input: A randomized combination of 3 to 6 common fridge ingredients and spices.
- Output: A structured Markdown response detailing the recipe, step-by-step instructions, and a chef's secret tip.
Training Procedure & Hyperparameters
- Quantization: 4-bit NF4 with Double Quantization (
bitsandbytes) - LoRA Parameters:
r = 16lora_alpha = 32target_modules = ["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"]lora_dropout = 0.05
- Training Config:
- Optimizer: AdamW
- Learning Rate: 2e-4 (Cosine scheduler with 5% warmup)
- Batch Size: 2 per device (Gradient Accumulation Steps = 4, Effective Batch Size = 8)
- Epochs: 3
- Precision:
fp16
💻 How to Use
You can easily run this model using Hugging Face's transformers library:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "YOUR_USERNAME/leftover-recipe-generator-qwen1.5b"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto"
)
# Define input
ingredients = "eggs, potatoes, cheddar cheese, olives, salt & black pepper"
system_prompt = "You are a creative chef. Generate a quick, fitting meal recipe using only the available fridge ingredients."
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": f"Available ingredients: {ingredients}"}
]
# Apply chat template
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
# Generate recipe
outputs = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.7,
top_p=0.9,
do_sample=True
)
recipe = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(recipe)