# Mission 11.4: The hits have been useless since the switch to a local embedding model

Part of the course “AI from Zero to Autonomous Agents” (https://llm.yoga/en). Page for humans: https://llm.yoga/en/einsatz-11-4

Belongs to [Chapter 11: RAG, embeddings and grounding](https://llm.yoga/en/11-rag.md).

Structure: the case, the explanation, a hands-on tool, check questions, wrap-up. The answers to all questions are collected at the end.

## The case

**Ines**, HR department:

> “We had embedded our 5,000 HR documents with OpenAI’s text-embedding-3-small, shortened to 1,024 numbers. Now IT computes the questions locally with Qwen3-Embedding 0.6B, also 1,024 numbers, cheaper, and nothing leaves the building. Since then, ‘How much vacation can I take?’ brings up the travel expense policy. No error message, nothing.”

Embedded means an embedding model turns each text into a list of numbers, a vector, and the search compares these lists. The 5,000 documents are still in the database, unchanged. Only the model that turns the questions into vectors was switched.

**Question 1 (decision):** What do you advise Ines’s team?

- A) Add a reranker, a second model for reordering, after the search.
- B) Compute questions and documents with the same model again.
- C) Fetch 50 hits instead of 5; then the right one is sure to be among them.

## What’s behind it

Two mapmakers draw the same city, each with their own grid. On one map, “square C4” is city hall; on the other, the train station. If you look up coordinates from map B on map A, you reliably find a place, just the wrong one.

That’s exactly what switching the **embedding model** on only one side does. Each model places texts in a space with hundreds of axes according to its own rules. Nobody knows exactly what the individual axes mean, and two models don’t share them. That’s why documents and questions have to be embedded with the same model. The docs of Ollama, a program for running models on your own computer, state the rule explicitly.

Why was there no error message? Because both models return 1,024 numbers. The database doesn’t understand meaning; it only computes angles. With 1,024 against 1,024 numbers, that works fine technically. If the lengths hadn’t matched, say 1,536 against 768, the comparison would usually have failed right away. So the matching length hid the error.

For Ines, this means anyone who switches models has to re-embed all documents. That only works if the original text and metadata (file name, page, date) are stored with every vector. Until then, the queries stay with the old model. Ideally, each vector records which model created it; then the database can’t compare foreign vectors in the first place.

### In more detail: shortening, dimensions and memory

Shortening isn’t converting. OpenAI’s models can be asked for shorter vectors through the `dimensions` parameter, and Qwen3-Embedding, EmbeddingGemma and nomic-embed-text can be shortened too. But a shortened vector stays in its own model’s space.

One reason to look at the dimension when choosing the model: pgvector only indexes the `vector` type up to 2,000 dimensions. A million chunks with 3,072 numbers take up 12.3 GB, with 768 numbers 3.1 GB, in each case without an index.

Re-embedding means sending every chunk through the new model again and replacing the old vector. A mix of old and new vectors in the same search has the same problem as Ines’s team.

### How tybo does it: the provider is recorded with the vector

tybo, the assistant that serves as an example in this course, searches its conversation history, facts and a knowledge base with embeddings. According to its architecture docs, the database checks that only vectors from the same embedding provider are compared with each other. So the rule “same model for index and query” is enforced technically there. Without embeddings, search falls back to text.

## Try it

**Ines’s search: what is the question computed with?**

**Task:** Make sure Ines’s vacation question lands on the right document again and the values in the ranking mean something.

There are three models to choose from, all returning 1,024 numbers: Qwen3-Embedding, as IT set it up, and the two OpenAI models text-embedding-3-large and text-embedding-3-small, each shortened to 1,024 numbers.

The selection needs JavaScript. Here’s what it looks like: with Qwen3-Embedding, “Travel expenses” is at the top (0.62), with text-embedding-3-large “Data breach” (0.07), both times against documents from a different model. Only with text-embedding-3-small, the model of the documents, is “Vacation” at the top (0.62), ahead of “Shift leave” (0.34).

Example values, schematic: two axes instead of 1,024. In two dimensions, the values spread more than in real models, including into the negative. Measured with EmbeddingGemma, four paragraphs for a vacation question were between 0.08 and 0.49 (mission 11.2). A question arrow from a different model points in a random direction.

## Check

**Question 2 (check question):** Why did Ines’s team get no error message?

- A) Because vector databases even out differences between models on their own.
- B) Because both return 1,024 numbers and the database only computes.
- C) Because Qwen3-Embedding and OpenAI use the same space of meaning.

**Question 3 (check question):** The team wants to be able to switch safely in the future. What should be stored with every vector?

- A) Original text, metadata and the name of the model.
- B) Only the vector, since it contains the whole meaning.
- C) The threshold above which a hit counts as a match.

**Question 4 (check question):** Someone from IT says: “If we hadn’t shortened the OpenAI vectors (1,536 against 1,024 numbers), we’d have noticed right away.” Is that true?

- A) No, with more numbers the hits would just have been better.
- B) Yes, with different lengths the comparison usually fails right away.
- C) Yes, and then you’d simply have shortened 1,536 numbers to 1,024.

## Done

**What you can do now**

- You recognize the silent error when question and documents come from different embedding models.
- You can explain why the same dimensions don’t mean compatibility and even hide the error.
- When a customer complains about useless hits without an error message after a model switch, you first ask whether questions and documents are computed with the same embedding model.

### Two cards for review

**Card 1:** True or false? “Two embedding models with the same number of dimensions can be mixed: documents with one, questions with the other.”

**Card 2:** Why is it risky to store only the vectors in the vector database?

- [Next mission: Does the model check the weather itself?](https://llm.yoga/en/einsatz-12-1.md)
- [Read chapter 11](https://llm.yoga/en/11-rag.md)

## Read more in the chapter

The full text from the chapter, with the reasoning, calculations and sources:

- [Embeddings](https://llm.yoga/en/11-rag-1.md)
- [Vector databases and embedding models](https://llm.yoga/en/11-rag-3.md)
- [Typical mistakes when building](https://llm.yoga/en/11-rag-4.md)

## Answers: only reveal them after the learner has answered or explicitly asks

**Question 1:** The correct answer is B.
- A: A reranker only reorders the preselection the search delivers. If the preselection is random, the right document usually isn’t in it at all.
- B, correct: So either send the questions back to OpenAI or re-embed all 5,000 documents with Qwen3-Embedding. That’s the most important rule of the chapter. Every embedding model builds its own space of meaning. A question vector from one model can’t be meaningfully compared with document vectors from the other.
- C: More random hits stay random. On top of that, the prompt gets more tokens and the answer model more ballast.

**Question 2:** The correct answer is B.
- A: The database understands nothing at all. It stores lists of numbers and looks for the ones with the smallest angle. The understanding is entirely in the embedding model.
- B, correct: You can’t tell from a vector where it came from. The same length is enough for the computation, but not for a meaningful comparison.
- C: Every model builds its own space, even with the same number of dimensions. That’s exactly why the hits are nonsense.

**Question 3:** The correct answer is A.
- A, correct: With the original text, you can re-embed at any time; with the model name, you can recognize and exclude foreign vectors. Vectors are an interchangeable intermediate product.
- B: Without the original text, nobody can re-embed. And without file name and page, the model can’t name a source.
- C: Thresholds don’t carry over from one model to another. After a switch, you’d have to set them again anyway.

**Question 4:** The correct answer is B.
- A: More numbers don’t help when question and documents come from different models. The space is still a different one.
- B, correct: Then there’s an error message, and someone looks for the cause. The same length hides the error. You have to fix it either way: with the same model for both sides.
- C: Shortening only works within one model. A shortened OpenAI vector stays in the OpenAI space and still doesn’t match Qwen3-Embedding.

**Card 1:** **False.** Every model builds its own space of meaning. The same length only means the database can compute; the hits are nonsense, without an error message. If you switch, re-embed all documents.

**Card 2:** Without the original text, nobody can re-embed with a new model, and without metadata the model can’t name a source. If the model’s name is also recorded with each vector, foreign vectors can be excluded from the comparison.
