Embedding strategy

How Meridian maps recipes into vector space for semantic search and similarity matching.

Ingredient-aware chunking

Each recipe is split into three overlapping chunks — title + description, ingredient list, and step-by-step instructions. This preserves structural boundaries so queries like “gluten-free pasta” hit ingredient chunks directly without noise from unrelated steps.

Model selection

We use text-embedding-3-small at 1536 dimensions. It balances latency (~12ms per chunk) with retrieval quality on culinary text. Embeddings are computed server-side at recipe creation and cached in the database.

Hybrid retrieval pipeline

Queries run through a two-stage pipeline. Stage one performs cosine similarity over chunk embeddings with a threshold of 0.78. Stage two re-ranks candidates using BM25 over raw ingredient tokens to boost exact matches — critical for dietary filters and allergy-safe results.

Indexing cadence

New and updated recipes are embedded within 30 seconds via a debounced queue. Bulk re-indexing runs nightly during the lowest-traffic window. Stale embeddings are flagged by a version counter on each recipe row.