# Vector search returns almost random results

**URL:** <https://discuss.huggingface.co/t/vector-search-returns-almost-random-results/69675>\
**Category:** Models\
**Created:** [January 18, 2024, 6:52pm UTC](https://discuss.huggingface.co/t/vector-search-returns-almost-random-results/69675 "2024-01-18T18:52:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gosforth](https://avatars.discourse-cdn.com/v4/letter/g/f08c70/32.png) [@Gosforth](https://discuss.huggingface.co/u/Gosforth)\
**Post date:** [January 18, 2024, 6:52pm UTC](https://discuss.huggingface.co/t/vector-search-returns-almost-random-results/69675/1 "2024-01-18T18:52:23Z")

</div>

Hello Dear embedding fans!

I’m starting my adventure with vector search.  
My environment is SBERT where I tried two models to create vector embeddings;

`sbert-base-cased-pl & paraphrase-multilingual-MiniLM-L12-v2`

I encode phrases that are 300 - 800 characters long. Product descriptions in Polish language.

I loaded embeddings in DB and tried to search similar products (I encode search phrase as parameter with same model).  
To my surprise search result is almost random. Looks like these models do not work at all. For instance I search for ‘Xero paper 80’ and I get similar product descriptions as… gloves (not even single word ‘paper’ or ‘xero’ there.

Is there something I should know?  
I would appreciate any suggestion.

Regards,

G.

---

<div class="post-metadata">

**Author:** ![MattiLinnanvuori](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@MattiLinnanvuori](https://discuss.huggingface.co/u/MattiLinnanvuori)\
**Post date:** [January 20, 2024, 10:16am UTC](https://discuss.huggingface.co/t/vector-search-returns-almost-random-results/69675/2 "2024-01-20T10:16:20Z")

</div>

Can you describe your setup more precisely? I, too, have experienced frequent mistakes in similarity search with embeddings. Using better models can help.

---

<div class="post-metadata">

**Author:** ![Gosforth](https://avatars.discourse-cdn.com/v4/letter/g/f08c70/32.png) [@Gosforth](https://discuss.huggingface.co/u/Gosforth)\
**Post date:** [February 10, 2024, 3:34pm UTC](https://discuss.huggingface.co/t/vector-search-returns-almost-random-results/69675/3 "2024-02-10T15:34:17Z")

</div>

Hi Matti,

simple code:

```auto
from sentence_transformers import SentenceTransformer

model = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2')
emb = model.encode('some sentence ...')

```

Then I load this embedding in database and search using vector search options.  
Parameter to search I get in exact same way:

```auto

search_param = model.encode('some similar search sentence ...')

```

I get way better result with FullText search.

For asynchronous search I tried ‘msmarco-MiniLM-L-6-v3’ model but results are also very poor.

---

<div class="post-metadata">

**Author:** ![MattiLinnanvuori](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@MattiLinnanvuori](https://discuss.huggingface.co/u/MattiLinnanvuori)\
**Post date:** [February 10, 2024, 3:48pm UTC](https://discuss.huggingface.co/t/vector-search-returns-almost-random-results/69675/4 "2024-02-10T15:48:44Z")

</div>

Full text search works better if the search parameters exactly match the text to search for. Vector search can work better if the search parameters do not match the text exactly.
