🍳 Recipe Card Generator (T5-small + LoRA merged)

This model generates recipe cards (title, ingredients, and step-by-step directions) from a list of ingredients.
It is fine-tuned from t5-small using LoRA adapters and merged into a standalone checkpoint.


✨ Model Details

  • Base model: t5-small
  • Fine-tuning method: LoRA (rank=16, Ξ±=32, dropout=0.05, query/value projection layers)
  • Dataset: Custom JSONL (input_text, target_text pairs), originally prepared from a Kaggle recipe dataset.
  • Task: Text-to-Text Generation

πŸ“₯ Usage

from transformers import T5ForConditionalGeneration, T5TokenizerFast

tok = T5TokenizerFast.from_pretrained("MahmutCanBoran/t5-recipe-card-en-lora-merged")
model = T5ForConditionalGeneration.from_pretrained("MahmutCanBoran/t5-recipe-card-en-lora-merged").eval()

prompt = "STRICT=yes | Ingredients: 1 cup sugar, 2 cups flour, 1/2 cup butter"
enc = tok(prompt, return_tensors="pt")
out = model.generate(
    **enc,
    max_new_tokens=160,
    num_beams=4,
    length_penalty=0.8,
    no_repeat_ngram_size=3
)
print(tok.decode(out[0], skip_special_tokens=True))

πŸ” Example

Input:

STRICT=yes | Ingredients: 1 cup milk, 2 eggs, 1 cup flour


Output:

Title: Pancakes
Ingredients:
- 1 cup milk
- 2 eggs
- 1 cup flour
Directions:
1. Whisk eggs and milk.
2. Add flour slowly.
3. Cook on pan.
Time: 20-60 minutes
Servings: 4

## πŸš€ Features
- **Input**: Raw ingredient list (e.g., `"chicken breast, yogurt, garlic, salt, pepper"`).  
- **Output**: Structured **recipe card** with:
  - Title suggestion πŸ“  
  - Ingredients (cleaned + normalized) πŸ§‚  
  - Step-by-step cooking instructions 🍲  
  - Optional serving tips 🍽️  

- Supports **strict** and **flexible** generation modes:
  - `STRICT=yes` β†’ Uses **only** given ingredients  
  - `STRICT=no` β†’ Allows creative variations  

---

## βš™οΈ Installation

```bash
# Clone repo
git clone https://github.com/<your-username>/recipe-card-t5-lora.git
cd recipe-card-t5-lora

# Create environment
python -m venv venv
source venv/bin/activate   # (Windows: venv\Scripts\activate)

# Install dependencies
pip install -r requirements.txt


pip install transformers peft torch
from transformers import pipeline
pipe = pipeline("text2text-generation", model="MahmutCanBoran/t5-recipe-card-en-lora-merged")




⚠️ Limitations

Time/Servings fields are currently fixed values (20-60 minutes, Servings: 4).

Model may hallucinate instructions if STRICT=no mode is used (future work: add dataset with variable strictness).

Optimized for English outputs.
Downloads last month
49
Safetensors
Model size
60.5M params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for MahmutCanBoran/t5-recipe-card-en-lora-merged

Base model

google-t5/t5-small
Finetuned
(2107)
this model

Space using MahmutCanBoran/t5-recipe-card-en-lora-merged 1