Deployed Lab

Module 4 · Data and runtime infrastructure · Chapter 14 · Free

Embedding pipelines: ingestion, reindexing and versioning

20 min1 clickable picture1 hands-on lab1 predict, 2 quick quizzes, 5-question final quiz5-min video review
In 30 seconds

The picture: a conveyor to the index, queue depth as its pulse.

What this chapter gives you
The cold open

Copperline is a made up B2B SaaS company. Priya Nair, its staff platform engineer, upgraded the copilot's embedding model on a Friday, in place, one document at a time. All figures here are illustrative.

Nothing crashed. The index was quietly wrong, which is worse. This chapter is the rebuild that stops it happening again.

The plan for this chapter
  1. The pipeline: sources, chunking, embedding, index writes.
  2. Model versioning: why old vectors become invalid.
  3. Reindex strategies: fresh build and swap, dual write, backfill.
  4. Safe ingestion: idempotency, retries, dead letters, drift checks.
  5. Throughput math and queue depth as the health signal.
  6. The picture, a worked example, and a reindex planning lab.

Next: the four stages every document passes through.

Step 1: The pipeline, from source document to searchable vector

Chapter 13 covered the vector database itself. This chapter covers the conveyor that feeds it. For retrieval basics, see RAG end to end in the AI engineering course.

Chunking is an operational step, not just a quality choice. Chunk size sets embedding call volume and re-embed cost when a paragraph changes. Priya's team re-chunks only the changed section.

Think of a warehouse conveyor: goods arrive, get boxed, labelled and shelved. Where the picture breaks down:

Next: why the embedding model version is part of every vector's identity.

Step 2: Model versioning, why old vectors stop being valid

An embedding model defines a space: which texts land near each other, and how many numbers each vector has. A new model, even from the same provider, defines a different space.

So a mixed index is not half upgraded. It is two half indexes interleaved, and ranking across them is meaningless.

The fix is bookkeeping: stamp every vector, and the index, with the model version. The query path checks the stamp first. If stamps disagree, the request fails loudly instead of answering badly.

Next: three ways to rebuild, and the risk each one carries.

Step 3: Reindex strategies, fresh build, dual write, backfill

When the model changes, every chunk must be re-embedded. How do new vectors reach serving while the old index keeps answering?

Priya's default is fresh build and swap, with dual write added only when the build outlasts a source freeze. Backfill in place is reserved for tiny, low risk collections where a mixed window is acceptable.

Think of repainting a bridge: build a new span, paint both during a closure, or paint lane by lane under traffic. Where the picture breaks down:

Next: making daily ingestion safe to retry, because pipelines fail mid flight.

Step 4: Idempotent ingestion, retries and dead letters

Between model changes, the pipeline runs daily. Workers crash, embedding calls time out, writes fail. The design question is what a retry does.

Predict first:

A dropped chunk leaves no trace, so nobody knows which documents are missing until a user reports a bad answer. The dead letter queue is the record: what failed, why, and what to replay once the cause is fixed.

Next: how Priya proves the index still matches the source store.

Step 5: Drift checks, proving index and source still agree

Even a healthy pipeline drifts: a missed delete, a stuck consumer. Priya's team checks agreement at three depths.

Repair is simple: drifted documents go back through normal ingestion, with the same idempotent writes.

Next: the throughput math, and the one number that shows pipeline health.

Step 6: The picture, one document through the pipeline

Press Next to walk a changed article from store to index.

The embedding pipeline A source document is chunked, queued, embedded by the current model, and written to the index under its version stamp. Source storethe truth Chunkersplit and hash Work queuedepth is health Embed modelversion stamped Vector indexidempotent writes Dead lettersfailures kept
  1. An editor saves a help article. The store is the truth; everything downstream is a copy.
  2. Only changed sections are re-chunked. Each chunk gets an ID and a hash.
  3. Chunks queue for embedding. A growing queue is the first sign of falling behind.
  4. Each chunk is embedded by the current model, and the vector carries that stamp.
  5. Good chunks are written by key, so retries are safe. Repeat failures go to dead letters.

Next: the worked example, how fast the pipeline drains a backlog.

Step 7: Worked example, throughput through three stages

A help centre migration lands 12,000 documents in the queue at once. All figures are illustrative. The slowest stage sets the pace.

1. Chunk stage. The chunker handles an illustrative 2,000 documents per hour. Chunking alone: 12,000 / 2,000 = 6 hours.

2. Embed stage. Each document makes an illustrative 8 chunks, so 12,000 x 8 = 96,000 embedding calls, at an illustrative 12,000 calls per hour. Time: 96,000 / 12,000 = 8 hours.

3. Write stage. The index accepts an illustrative 20,000 chunk writes per hour. Time: 96,000 / 20,000 = 4.8 hours.

4. The pipeline rate. Stages run in parallel, so the backlog drains at the slowest stage: embedding, at 12,000 / 8 = 1,500 documents per hour end to end. Total time: about 8 hours.

5. The lesson. Adding chunker workers changes nothing. The queue before the embedding stage grows whenever arrivals beat 1,500 documents per hour.

Queue depth is the health signal: flat means keeping up, rising means a stage is saturated or down, a sudden jump means a bulk change landed. Chapter 16, "Caching and queues: semantic caches, backpressure and fair sharing", builds the discipline behind it.

Next: the lab, planning a real reindex on paper.

Step 8: Hands-on lab, plan a reindex

Why this exercise: a reindex is a planned migration, not an incident. Writing the plan first is what keeps an upgrade from becoming the cold open.

Lab: Priya is rehearsing the v2 to v3 reindex on a small event stream before the real build. This lab runs in your browser and needs JavaScript enabled.

What to notice

Next: a field note and the mix-ups.

Field note, November 2026

In production practice, mature retrieval teams treat the embedding model like a schema version: recorded with the data, migrated by planned, verified builds, the old version kept until the new one has carried real traffic. Tooling varies by vector database, so confirm your alias features before promising a swap based rollback.

Mix-ups to avoid

Chapter quiz

Five questions, 70% to pass.

Review this chapter in 5 minutes

Watch the whole chapter recapped: source to index pipeline, model versioning, fresh build and swap reindexing, drift checks and throughput.

Decision rule: treat the embedding model as a schema version: pin it, stamp it, rebuild beside the old index, not inside it.

Review

Glossary

Embedding pipeline
The conveyor from source documents to searchable vectors. Example: the nightly help centre sync.
Chunking
Splitting a document into passages for embedding. Example: one article, 8 chunks.
Embedding model version
The exact model that produced a vector, recorded with it. Example: vectors stamped v2.
Vector space
The geometry one model uses to place texts by meaning. Example: v2 neighbours differ from v3.
Reindex
Rebuilding an index from source, usually for a model change. Example: the weekend v3 build.
Dual write
Writing each change to old and new indexes during a migration.
Idempotent write
A write that can repeat without changing the result. Example: one chunk key, stored once.
Dead letter queue
Where repeatedly failing items wait, with their errors, for review.
Drift
Disagreement between the source store and the index. Example: an edited policy never re-embedded.
Queue depth
How many items wait at a pipeline stage. Example: a rising embed queue.

Next: "Agent runtimes in production: sandboxes, tool gateways and state".