Spaces:
Sleeping
Sleeping
File size: 2,755 Bytes
4b7520e edbe91d 4b7520e edbe91d 4b7520e edbe91d 4b7520e edbe91d 4b7520e edbe91d 4b7520e edbe91d 4b7520e edbe91d 4b7520e edbe91d 4b7520e edbe91d | 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 | # Problem Statement
## Problem Context
People with food allergies face real risk and stress when finding or adapting recipes online. Most recipes aren't personalized for specific allergies, and hidden allergens in ingredients make it difficult to trust any recipe at face value. Constantly checking every ingredient is time-consuming and error-prone. A key challenge is that allergens are often non-obvious: wheat hides in soy sauce, tree nuts appear in products labelled "vegan", and substitutes like almond milk are unsafe for nut allergy sufferers. An LLM-powered tool must handle these hidden risks, not just swap the obvious ingredients.
## Problem Statement
Given a recipe and a list of the user's allergies, rewrite the recipe so that all unsafe ingredients are replaced with safe alternatives, and return a structured summary of what changed and why.
## LLM Role
Enrichment/creation — the LLM transforms an existing recipe by substituting allergens with safe alternatives and rewriting the steps accordingly, rather than simply classifying or selecting from options.
## Example
**Input:**
```
Allergies: dairy, peanuts
Recipe: Peanut Butter Cookies
Ingredients: 1 cup peanut butter, 1 cup sugar, 1 egg, 1 tsp vanilla, 2 tbsp butter
Instructions: Mix all ingredients, roll into balls, flatten with a fork, bake at 350°F for 10 minutes.
```
**Expected Output:**
```json
{
"title": "Sunflower Seed Butter Cookies (Dairy & Peanut Free)",
"ingredients": ["1 cup sunflower seed butter", "1 cup sugar", "1 egg", "1 tsp vanilla", "2 tbsp coconut oil"],
"instructions": ["Mix all ingredients until smooth", "Roll into balls", "Flatten with a fork", "Bake at 350°F for 10 minutes"],
"swaps_made": [
"Peanut butter → sunflower seed butter (peanut allergy)",
"Butter → coconut oil (dairy allergy)"
],
"notes": "Both swaps maintain the texture and richness of the original. Sunflower seed butter has a similar consistency to peanut butter and works well in baking."
}
```
## Known Limitations (Week 4)
- `gemma2:2b` reliably detects and swaps allergens in short/simple recipes
- For long or complex multi-paragraph recipes, the model loses track of all ingredients and may drop some swaps (e.g. missing parmesan in a cream sauce recipe)
- This is a model capacity limitation, not a prompt issue — motivates fine-tuning in Week 5
## Success Criteria
- All ingredients matching the user's listed allergies are replaced
- The rewritten recipe is complete (ingredients + instructions)
- The `swaps_made` field clearly explains each substitution
- The output parses as valid JSON
- No unsafe substitutions are made, including non-obvious hidden allergen sources (e.g. wheat in soy sauce, nuts in vegan-labelled products)
|