The short version: the model in my vegan app learned which ingredients show up together in recipes. Onion goes with beef all the time. That makes it a great neighbor and a terrible substitute.

A few words first

  • Embedding: a list of numbers for each ingredient, learned from lots of recipes. Ingredients that turn up in similar recipes get similar numbers.
  • Neighbor: an ingredient whose numbers are close to another ingredient's. Higher scores mean closer neighbors.
  • Co-occurrence: two ingredients showing up in the same recipe.
  • Epicure: the ingredient embedding VeganSwap uses. It has about 1,800 ingredients with 300 numbers each, and it runs on the phone.

The lasagna that stopped the screenshots

On 2026-10-12 I approved the first full set of App Store screenshots. Capturing them showed a problem: a lasagna where ground beef became onion and the cheese became olive oil.

At the time, the hand-written swaps in the app covered dairy, eggs and baking. Anything else, like the beef in a lasagna, fell back to the model.

VeganSwap's recipe screen: 1 lb ground beef is struck through and replaced by Onion, marked Experimental, with the note: Onion is an option worth trying. Beef is hard to replicate exactly, but this gets you closest in the plant-based world. Two lines down, the recipe already lists 1 onion, chopped.
Reconstruction: VeganSwap rebuilt from its code as of 2026-10-12, before the fix, with a lasagna ingredient list pasted in. Its other two picks for ground beef were tomato and red onion, and the mozzarella became olive oil. The recipe already calls for an onion. Simulator capture; tap to enlarge.

Why it matters: a swap list can look right for brownies and be nonsense for dinner. You only find out when you try dinner.

What the model actually learned

Ask the model which ingredients sit closest to beef, and you get a shopping list for the same pot:

Closest to beef Score
onion 0.36
black pepper 0.36
oregano 0.35
pork 0.34
tomato 0.34

Onion is the single closest ingredient to beef, closer than pork. That isn't a mistake in the data. Onion and beef really do appear together that often.

Mozzarella does the same thing. Its closest vegan ingredients are pizza sauce, pasta, pizza crust, tomato and olive oil: a pizza, not a cheese.

Why it matters: "close" means "goes with", not "can replace". That's true of any model that learns from what appears together, not just this one.

The first fix sorted by food group

Back in June I had added a guard for this kind of thing. Every ingredient has a food group, and a swap had to come from a group that made sense. Meat could swap to meat, beans, vegetables, fruit, nuts or pantry items. That stopped flour and vanilla from replacing butter, and olives from replacing tuna.

It couldn't stop onion. Meat had to be allowed to swap to vegetables, because mushrooms and eggplant make real substitutes. But onion is a vegetable too. With the guard on, beef's closest swaps were onion, tomato, red onion, garlic and potato.

Mozzarella's list started with olive oil, because cheese was allowed to swap to fats.

Why it matters: a food group says what an ingredient is. A swap needs to know what it does.

The fix asks what the ingredient does

The same day the lasagna turned up, the app got role pools. For each job, like protein, cheese, milk and cream, egg, fat or stock, there's a short list of vegan ingredients that can actually do that job. The model may only pick from inside the pool.

Beef's list became mushroom, pinto bean, tofu, eggplant and chickpea.

If an ingredient has no pool, the app doesn't guess. In the words of the code's own comment, it "stays unresolved for a manual swap rather than a bad guess."

Beef's closest vegan swaps, at each stage
  1. 1. Anything close Every vegan ingredient, ranked by closeness.
    • onion0.36
    • black pepper0.36
    • oregano0.35
    • tomato0.34
    • bay leaf0.32
  2. 2. The June food-group guard Meat may swap to vegetables, and onion is a vegetable.
    • onion0.36
    • tomato0.34
    • red onion0.32
    • garlic0.31
    • potato0.31
  3. 3. The protein pool Only ingredients that can do a protein's job.
    • mushroom0.30
    • pinto bean0.25
    • tofu0.21
    • eggplant0.20
    • chickpea0.19
  4. 4. What the app shows first in a lasagna A hand-written swap, ahead of the model.
    • browned finely chopped mushrooms
    • crumbled vegan sausage
Scores are the closeness between beef and each ingredient in the model VeganSwap ships with. Onion is highlighted until it drops out.

Why it matters: the model went from choosing the swap to putting a checked list in order.

My kitchen goes first

The same day, swaps from my own answers went in ahead of the model, for meats, fish, stocks, sauces and dairy. For ground beef: plant-based ground beef, browned finely chopped mushrooms, or crumbled vegan sausage. In tacos, lasagna and chili, the mushrooms and vegan sausage come first. On a budget: brown lentils with chopped walnuts, or dried soy crumbles.

The model is now the fallback. When it's unsure, the app labels its suggestion Experimental.

You should always verify given information. I have the experience to know when a substitution seems off. The search only has the context of the current recipe. It doesn't have the wider context of my experience, or of cooking experience in general.

Why it matters: the swaps people see first come from someone who has cooked them.

Neighbors aren't substitutes

My vegan app suggested onion for ground beef because onion is what you cook ground beef with. The model was right about recipes and wrong about the question.

If you're building with embeddings, the fix is the same anywhere: decide what the thing has to do, verify what the model gives you, and let it rank, not choose.

Walk the ingredient map to follow beef's neighbors and see how the results change when the search is limited to substitutes.

If you want to try the swaps, VeganSwap is on the App Store. The story of why I made it is in The same feeling: why I made VeganSwap.