Downloads · 30 days
71
35% of all-time downloads
Chama99/flan-t5-small-recipe-generator
flan-t5-small-recipe-generator is a text generation model from Chama99. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
This model is a fine-tuned version of google/flan-t5-small specifically optimized for recipe generation. It can create detailed, step-by-step cooking instructions based on a list of ingredients.
Downloads · 30 days
71
35% of all-time downloads
All-time downloads
203
Public
Repo size
3.6 MB
Likes
0
Public
Click a slice to open those files.
.safetensors2.8 MB · 77%
From the Hugging Face model README
This model is a fine-tuned version of google/flan-t5-small specifically optimized for recipe generation. It can create detailed, step-by-step cooking instructions based on a list of ingredients.
✅ Instruction-Following: Responds to natural language prompts ✅ Detailed Recipes: Generates step-by-step cooking instructions ✅ Professional Quality: Includes temperatures, timing, and techniques ✅ Memory Efficient: Uses LoRA for minimal storage requirements ✅ CPU Compatible: Optimized for CPU inference with 16GB RAM
from transformers import T5ForConditionalGeneration, T5Tokenizer
from peft import PeftModel
# Load base model and tokenizer
base_model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-small")
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-small")
# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "Chama99/flan-t5-small-recipe-generator")
# Generate recipe
def generate_recipe(ingredients):
prompt = f"Create a detailed recipe using these ingredients: {ingredients}. Include step-by-step cooking instructions:"
inputs = tokenizer(prompt, return_tensors="pt", max_length=512, truncation=True)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_length=400,
num_beams=5,
temperature=0.8,
do_sample=True,
repetition_penalty=1.4,
no_repeat_ngram_size=3
)
recipe = tokenizer.decode(outputs[0], skip_special_tokens=True)
return recipe.replace(prompt, "").strip()
# Example usage
ingredients = "chicken, mushrooms, garlic, cream"
recipe = generate_recipe(ingredients)
print(recipe)