Embedding Pipelines
Turning docs into a living index
An embedding pipeline takes corpus → clean → chunk → embed → index and query → re-embed. Reliability, idempotency and monitoring turn 'embeddings' from a demo into a service.
What you will learn
- Design an ingest pipeline end to end
- Make ingestion idempotent and resumable
- Plan for model and content changes
What is this?
An embedding pipeline is a repeatable process: normalize source documents, split into chunks, compute embeddings, upsert into a vector store, and rebuild/refresh as content or the model changes. What separates a demo from a service is idempotency (re-running is safe), versioning (models gut-tracked), and monitoring (coverage, drift, orphan vectors).
Why do you need it?
- Embeddings are stale the moment content changes — pipelines must refresh.
- Idempotent upsert means re-runs don't duplicate or corrupt.
- Chunking quality decides retrieval quality far more than model choice often does.
- Model upgrades are migrations, not background chores.
Mental model
Updating a library's card catalog
Embedding pipelines
New book (content) arrives → catalog a card (embed), file it (index), and cross-check old cards (refresh). Rebinding the collection (model upgrade) means re-cataloging everything, not just the new arrivals. A good librarian does this without ever losing a card or misfiling two for one title.
How it works
- Normalize: strip format noise, mark sections, handle attachments.
- Chunk: split with overlap by structure (headings, paragraphs) — never mid-sentence.
- Embed: batch and cache; attach source, chunk-id, model-version metadata.
- Upsert: replace by (source, chunk-id) — idempotent keys.
- Query: embed the question with the SAME model and search the same space.
The vector lifecycle.
In production
- Doc-index refresh jobs re-run nightly with upsert keys (source, rev, chunk).
- Support copilots re-embed FAQ updates the same day they edit the source.
- Model upgrade flight: dual-write new-space to a shadow index, cut over on eval improvement.
Best practices
- Give every chunk a deterministic ID for idempotent upserts.
- Track embedding model + chunking config as a version in every record.
- Run a nightly coverage check: index size vs source counts.
- Maintain a rerunnable re-embed script for model upgrades.
Common mistakes
- Full rebuilds on every change instead of incremental upserts.
- Ignoring chunk boundaries (mid-table splits destroy meaning).
- Querying with a different model than indexed.
- Orphan/duplicate vectors after deletions.
Common issues
New content never appears in searchIngest pipeline errored on that batch
Expose per-batch failures, retry with idempotent keys, alert on staleness.
Duplicates after rerunNon-deterministic upsert keys
Key on (source, content-hash, chunk-index).
Model swap broke thresholdsOld vectors still in the index
Re-embed whole corpus; keep thresholds in config tied to model+metric.
Debugging tips
- Search misses new docs → ingest job failed silently; check batch errors + latest-upsert time.
- duplicate-heavy results → missing deletes; audit upsert keys.
- Score distribution changed suddenly → embedding model or chunking config drifted.
Interview checkpoint
Quick quiz
The safest upsert key for a chunk is…
Queries must embed with the same model family as the index.