# When Must You Re-Embed Everything?

> When a change means every document must be embedded again, and when it does not, explained simply for your AI interview.

**In short:** You must re-embed everything when a change alters the vectors themselves: a new embedding model, a new chunk size or a new prefix. Changing the chat model, the prompt or the number of results needs no new vectors.

AI and LLM interview question Q147, Retrieval-augmented generation (RAG). Advanced, occasional (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/when-must-you-re-embed-everything

## Say it in 30 seconds

You re-embed everything when a change alters the vectors themselves. That means a new embedding model, a different chunk size, or a new prefix on each chunk. Changing the chat model, the prompt or the number of results doesn't touch the vectors, so nothing gets embedded again. When I do have to switch models, I build the new index beside the old one, score both on real questions, and keep the old one for rollback.

## Say it in 2 minutes

Every chunk in a search index was turned into a list of numbers, called a vector, by one embedding model with one set of settings. A question gets the same treatment when someone asks it. The search only works because the question's numbers and the chunks' numbers come from the same recipe. So if the recipe changes, the stored numbers are out of date, and every document has to be embedded again.

The changes that force this are the ones that change those numbers: a new embedding model or version, a new chunk size or overlap, cleaning the text differently, or adding context to each chunk. Changing the chat model, the prompt, the number of results or adding a reranker (a second step that reorders the top results) does not change any stored vector, so those need no re-embedding.

Two things to watch. The index's size and distance settings are fixed when you create it, so a new size or metric (the rule for measuring how close two vectors are) means a new index. A new vector size can also mean new vectors, unless the vendor documents a way to shorten stored ones. And never mix vectors from two models in one index, because their scores mean nothing against each other.

When a model must change, I build the new index beside the old, store the model name with every vector, score both on a set of real questions, switch when the new one wins, and keep the old one on hand for rollback in case the new one fails in live use.

## When must you re-embed everything, in plain words?

An embedding is a list of numbers that stands for the meaning of a piece of text. A search index is a large store of these lists, one per chunk of your documents. When someone asks a question, the question is turned into numbers too, and the search finds the chunks with the closest numbers.

Those numbers only compare well if they were made the same way. Re-embedding means turning every chunk into numbers again, with the new settings. It is the expensive step, because every document goes through the model again.

Think of a law firm's filing clerk. If the firm changes its filing code, every contract must be re-filed under the new code, including the ones already on the shelves. A search index has the same problem: change the code, and the old filing no longer matches the new one.

- **Embedding:** A list of numbers, called a vector, that stands for the meaning of a piece of text.
- **Re-embed:** Turn every document into vectors again, with the new settings.
- **Chunk:** A piece of a document, usually a few hundred words, that gets its own vector.
- **Dimensions:** How many numbers each vector has. The model sets it, unless the provider lets you ask for a shorter one.
- **Index:** The store that holds the vectors and finds the closest ones to a question.

## Which changes force a full re-embed?

The rule is simple: if a change alters the numbers a document turns into, every document needs a new run. If the settings stay the same, only new or edited documents are embedded, and deleted ones are simply removed. The chart shows the split for a typical search app.

*Diagram, What a change touches: Settings that change the vectors send every document back through the model. Settings that only change search leave the stored vectors alone, so nothing is embedded again.*
1. A change that alters the vectors takes the orange path.
2. A search-only change takes the blue path.
3. Every document goes back through the model.
4. Stored vectors stay, and nothing is embedded again.

- **A new embedding model or version:** A new model, or a new version of one, gives different numbers for the same text.
- **New chunk size, overlap or cleaning:** The text that gets embedded is different, so the numbers are different too.
- **Context added to each chunk:** A short explanation written for each chunk, placed before it, changes what gets embedded. Anthropic's contextual retrieval does this, prepending chunk-specific explanatory context to each chunk before embedding.
- **A different task label:** Some models take a task label. Documents and questions should carry different labels, so changing the document label means re-embedding.

> "The configuration of an index cannot be changed after creation." (Cloudflare Vectorize)
>
> "To get the best performance, you must use different task types to generate embeddings for your corpus and your queries." (Google Cloud)
>
> "Contextual Retrieval solves this problem by prepending chunk-specific explanatory context to each chunk before embedding" (Anthropic)

A new vector size is a separate question. The index is built for one size, so in Vectorize a new size always needs a new index. Whether the vectors must be made again depends on the model. OpenAI says developers can shorten embeddings with the dimensions parameter, which means a new call for every document. The same page also shows a route that needs no new call: cut a stored vector by hand, then rescale it so its length is 1 (normalise it).

Here is a tiny check a team could run before any settings change. It sorts each change into one of three outcomes. The settings are made up, and the output is real.

```python
# Decide what a settings change costs. Vector settings change the numbers themselves.
# dims is a full re-embed here. A vendor that documents shortening stored vectors (OpenAI does) can skip it.
VECTOR_KEYS = ["model", "dims", "chunk_size", "doc_prefix", "clean"]
INDEX_KEYS = ["metric"]

def plan(old, new):
    changed = [k for k in VECTOR_KEYS if old[k] != new[k]]
    if changed:
        return "FULL RE-EMBED: " + ", ".join(changed)
    if any(old[k] != new[k] for k in INDEX_KEYS):
        return "REBUILD INDEX ONLY: vectors kept"
    return "NOTHING TO EMBED"

stored = {"model": "model-a", "dims": 1024, "chunk_size": 400, "doc_prefix": "", "clean": "v2", "metric": "cosine", "top_k": 5, "chat_model": "chat-a"}
print("top_k 5 -> 8:", plan(stored, {**stored, "top_k": 8}))
print("metric cosine -> dot:", plan(stored, {**stored, "metric": "dot"}))
print("add heading prefix:", plan(stored, {**stored, "doc_prefix": "Section: "}))
print("chat model swapped:", plan(stored, {**stored, "chat_model": "chat-b"}))
```

Output:

```text
top_k 5 -> 8: NOTHING TO EMBED
metric cosine -> dot: REBUILD INDEX ONLY: vectors kept
add heading prefix: FULL RE-EMBED: doc_prefix
chat model swapped: NOTHING TO EMBED
```

## What does a full re-embed cost in a real project?

Take a legal team that searches 40,000 contracts. Each contract is about 30 chunks, and each chunk is about 350 tokens, where a token is a small piece of text that models count. That is 1.2 million chunks and about 420 million tokens to embed once.

Now the team wants a short heading, such as Termination, added to every chunk, because lawyers search by clause name. That changes the embedded text, so everything gets embedded again. The heading adds about 40 tokens to each chunk, which is 48 million more, so the full run comes to about 468 million tokens. That is roughly 11 per cent more than the first pass.

> **Tip:** Multiply the token count by your provider's rate per million tokens. The rate is on the provider's pricing page, so read it on the day rather than trusting an old figure.

The old index keeps answering while the new one is built in the background, in one long run. Nothing is lost, but the bill and the wait are real. So the team tests the heading on a small set of questions first, and only pays for the whole run if the heading helps.

## How do you switch models without breaking search?

The switch is safe only when old and new vectors never share one index. Mixing two models gives scores that look normal but mean nothing, so the search misses the right chunks without any error showing.

1. **Tag every vector:** Store the model name, the vector size and the chunk settings with each vector, so you can tell which run made it.
2. **Build the new index beside the old:** The old index keeps answering users while the new one fills up.
3. **Score both on real questions:** Keep a gold set: a few hundred real questions with known right answers. Measure how often each index finds the right chunk.
4. **Switch when the new one wins:** Move traffic over in one step, and only after the scores show the new index is better.
5. **Keep the old index for rollback:** If something breaks in live use, switch back in minutes. Delete the old index only after that.

Cloudflare's index, for one, fixes its size and metric when it is created, so the new setup has to be a new index from the start.

### How would you handle a retired embedding model?

A bank's policy assistant indexes 85,000 pages of internal rules. The provider says its embedding model will be retired on a date a few months away. Nothing breaks today, but the new model needs every page embedded again, and the two sets of vectors cannot share an index.

*Diagram, Switching models without a mixed index: Build the new index beside the old one, score both on the same questions, and switch only when the new one wins. The old index stays ready for rollback.*
1. The new index fills up while the old one keeps answering users.
2. Both indexes answer the same questions, and the scores decide the switch.

- **Without a plan: Swap the model in place.** Old and new vectors end up in one index. Scores look fine at first, then answers go wrong after the switch.
- **With a plan: Run both, then switch.** Each index holds one model. The switch happens after the scores prove the new one finds the right pages.

Start early. Re-embedding 85,000 pages takes a while, so the team plans the rebuild well before the retirement date.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] The answer: re-embed when the stored numbers would no longer match the new settings.
- [ ] The changes that alter vectors: model, chunking, cleaning, prefix, task label. Vector size needs a new index, and often new vectors.
- [ ] The changes that don't: chat model, prompt, number of results, reranker.
- [ ] Never mix vectors from two models in one index.
- [ ] A safe switch: a new index, a set of real questions to score it, and a rollback.

**Common traps**

- Trap: "Just embed the new documents, the old ones are fine." Better: Only if no setting changed. A new model or chunk size means every document goes back through the model.
- Trap: "Changing the chat model means re-embedding." Better: No. The chat model reads the chunks it is given. The stored vectors stay the same.
- Trap: "Tagging the mixed vectors makes them safe." Better: Tags help you find the mess. Unless every search filters by model, scores still compare across models. Separate indexes are the simple, safe route.

## Can you spot the risk?

**Spot the risk:** The team moved to a new embedding model on Monday. Which change puts the search at risk?

A. Raised the number of results from 5 to 8.
B. Switched the chat model that writes the answer to a cheaper one.
C. Added 500 new contracts to the existing index, embedded with the new model, next to the vectors of the 40,000 old contracts.
D. Shortened the system prompt so it fits on one screen.

**Answer:** C. The old and new vectors now share one index. Scores between them mean nothing, so the search misses clauses at random. Build a new index and embed every contract with the new model.

**Quick check:** A team changes only the chat model that writes the answer. Do they need to re-embed the documents?

A. Yes, every document
B. No, the stored vectors stay the same
C. Only the first 1,000 documents
D. Only if the new chat model is larger

**Answer:** B. The chat model writes the answer from the chunks it is given. It never changes the stored vectors, so the index stays as it is.

## Can you answer these from memory?

**Flash cards**

- **When must you re-embed everything?** When a change alters the stored vectors: model, chunking, cleaning, a prefix or a task label.
- **Does a new chat model need re-embedding?** No. The stored vectors stay the same. Only the text sent to the chat model changes.
- **Can one index hold two models' vectors?** No. Their scores mean nothing against each other. Build a new index.
- **Can a vector size change later?** Not in Cloudflare Vectorize. Size and metric are fixed at creation, so you need a new index.
- **What is a gold set?** Also called a gold set: a few hundred real questions with known right answers, used to score two indexes.
- **Why keep the old index?** For rollback. If the new one fails in live use, you switch back in minutes.

## Likely follow-up questions

- Q149 How do you clean and deduplicate documents first? https://designervenkat.online/interview/ai/how-do-you-clean-and-deduplicate-documents-first
- Q150 How would you design RAG for 10 million documents? https://designervenkat.online/interview/ai/how-would-you-design-rag-for-10-million-documents
- Q148 What are vector and embedding security weaknesses? https://designervenkat.online/interview/ai/what-are-vector-and-embedding-security-weaknesses
- Q146 How do you pick top-k? https://designervenkat.online/interview/ai/how-do-you-pick-top-k
- Q151 "The answer was in the docs, but the bot missed it." How do you debug? https://designervenkat.online/interview/ai/debug-a-rag-bot-that-missed-the-answer

## Learn it in depth

- [Indexing Embeddings](https://designervenkat.online/learn/ai-engineering/indexing-embeddings)
- [Choosing an embedding model](https://designervenkat.online/learn/ai-engineering/embedding-models)
