# Confusede result from multilingual-e5-small

**URL:** https://discuss.elastic.co/t/confusede-result-from-multilingual-e5-small/364398
**Category:** Elasticsearch
**Tags:** elastic-stack-machine-learning
**Created:** [August 5, 2024, 2:25pm UTC](https://discuss.elastic.co/t/confusede-result-from-multilingual-e5-small/364398 "2024-08-05T14:25:44Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Shell\_Dias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shell_dias/32/136785_2.png) [@Shell\_Dias](https://discuss.elastic.co/u/Shell_Dias)
#### Post date: [August 5, 2024, 2:25pm UTC](https://discuss.elastic.co/t/confusede-result-from-multilingual-e5-small/364398/1 "2024-08-05T14:25:44Z")

</div>

I am currently working with multilingual-e5-small and using semantic search. However, when retrieving search results, they seem inconclusive compared to the search query.

My actual question is how to evaluate the model more accurately with indexed embeddings. How is the search done with the tokens?

When comparing embeddings from training with those from indexing via the pipeline, they interestingly differ with the same text.

With elser\_v2, there is an interesting explanation on this topic for some raised issues, [Improving text expansion performance using token pruning — Search Labs (elastic.co)](https://www.elastic.co/search-labs/blog/text-expansion-pruning) but for other models, it's somewhat unclear.

I currently don't work with the proposed language for elser\_v2

---

<div class="post-metadata">

### Author: ![Shell\_Dias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shell_dias/32/136785_2.png) [@Shell\_Dias](https://discuss.elastic.co/u/Shell_Dias)
#### Post date: [August 15, 2024, 2:53am UTC](https://discuss.elastic.co/t/confusede-result-from-multilingual-e5-small/364398/2 "2024-08-15T02:53:09Z")

</div>

abra cadabra?

---

<div class="post-metadata">

### Author: ![dkyle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dkyle/32/59114_2.png) [@dkyle](https://discuss.elastic.co/u/dkyle)
#### Post date: [August 15, 2024, 8:35am UTC](https://discuss.elastic.co/t/confusede-result-from-multilingual-e5-small/364398/3 "2024-08-15T08:35:33Z")

</div>

> [@Shell\_Dias](#):
>
> When comparing embeddings from training with those from indexing via the pipeline, they interestingly differ with the same text.

Inputs to the E5 family of models should be prefixed with either `query: ` or `passage: ` this is how the model was trained (see the [FAQ](https://huggingface.co/intfloat/multilingual-e5-small#faq) on HuggingFace).

Elasticsearch automatically adds the `passage: ` prefix to inputs as they are ingested and `query: ` to search inputs. This would explains the different embedding values you are seeing.

> How is the search done with the tokens?

Search is performed in the vector database. The query text is converted to an embedding then the vector database is used to find other embeddings that are close to the search embedding.

---

<div class="post-metadata">

### Author: ![Shell\_Dias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shell_dias/32/136785_2.png) [@Shell\_Dias](https://discuss.elastic.co/u/Shell_Dias)
#### Post date: [August 15, 2024, 1:09pm UTC](https://discuss.elastic.co/t/confusede-result-from-multilingual-e5-small/364398/4 "2024-08-15T13:09:16Z")

</div>

Regarding the use of the 'query' and 'passage' prefixes, I wasn't aware that Elasticsearch already adds these automatically—perhaps I missed that part of the documentation.

Now, about the issue with vectors converted by Elasticsearch for search, I have a specific scenario in mind. Taking a demonstrated example of products:

When searching for "shirts," it sometimes returns "sneakers"—terms that have no relation to the search. I believe this is related to the FAQ:

> **2. Why are my reproduced results slightly different from reported in the model card?**  
> Different versions of `transformers` and `pytorch` could cause negligible but **non-zero** performance differences

Given that it will return 'random' information like this...

For textual search, Elasticsearch handles search relevance using approaches like TF-IDF, which makes it easy to identify the relevance of a document.

But with vectors, how does it calculate the score so that "sneakers" don't appear in my search for "shirts"?

How can Elasticsearch resolve this in its semantic search?

---

<div class="post-metadata">

### Author: ![Shell\_Dias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shell_dias/32/136785_2.png) [@Shell\_Dias](https://discuss.elastic.co/u/Shell_Dias)
#### Post date: [October 28, 2024, 4:18am UTC](https://discuss.elastic.co/t/confusede-result-from-multilingual-e5-small/364398/5 "2024-10-28T04:18:29Z")

</div>

healthy?
