# Sparse vector embeddings

**URL:** <https://discuss.elastic.co/t/sparse-vector-embeddings/353498>\
**Category:** Elasticsearch\
**Created:** [February 17, 2024, 2:44am UTC](https://discuss.elastic.co/t/sparse-vector-embeddings/353498 "2024-02-17T02:44:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mwon/32/123208_2.png) [@mwon](https://discuss.elastic.co/u/mwon)\
**Post date:** [February 17, 2024, 2:44am UTC](https://discuss.elastic.co/t/sparse-vector-embeddings/353498/1 "2024-02-17T02:44:27Z")

</div>

Hi,  
Is there any plan to re-introduce sparse vector fields? It was depreciated and there is this [discussion](https://discuss.elastic.co/t/please-dont-deprecate-sparse-vector-fields/219063) about it.

I would like to use sparse vectors to search by [sparse vector embeddings](https://opensearch.org/blog/improving-document-retrieval-with-sparse-semantic-encoders/).

For example, I would like to use models such as [BGE-M3](https://github.com/FlagOpen/FlagEmbedding/tree/master/FlagEmbedding/BGE_M3) to index the lexical scores.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [February 17, 2024, 7:12am UTC](https://discuss.elastic.co/t/sparse-vector-embeddings/353498/3 "2024-02-17T07:12:59Z")

</div>

ELSER is Sparse Vector or more accurately text expansion.

> **[ELSER – Elastic Learned Sparse EncodeR | Machine Learning in the Elastic...](https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-elser.html)**

---

<div class="post-metadata">

**Author:** ![mwon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mwon/32/123208_2.png) [@mwon](https://discuss.elastic.co/u/mwon)\
**Post date:** [February 17, 2024, 9:02am UTC](https://discuss.elastic.co/t/sparse-vector-embeddings/353498/4 "2024-02-17T09:02:59Z")

</div>

Ok, thanks. I read about it before but was not clear to me what exactly is and why is dependent of term expansion.  
Can I use it locally? I just want a field to index my a sparse vectors (I will calculate the vectors with a finetuned version of BGE-M3) and retrieve the documents given a query vector (with a similarity score given by the sum of the product of the weights).

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [February 17, 2024, 3:02pm UTC](https://discuss.elastic.co/t/sparse-vector-embeddings/353498/5 "2024-02-17T15:02:45Z")

</div>

Sounds like you want to BYOM and create / load your own embeddings which should be doable.

Perhaps look at [Elastic Search Labs](https://www.elastic.co/search-labs/tutorials/examples) for some examples

You can load your model into Elasticsearch as well assuming it meets the requirements

> **[Deploy trained models | Machine Learning in the Elastic Stack \[8.12\] | Elastic](https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-deploy-models.html)**

---

<div class="post-metadata">

**Author:** ![xeraa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xeraa/32/48181_2.png) [@xeraa](https://discuss.elastic.co/u/xeraa)\
**Post date:** [February 18, 2024, 3:40pm UTC](https://discuss.elastic.co/t/sparse-vector-embeddings/353498/6 "2024-02-18T15:40:50Z")

</div>

Sidenote: sparse vector was added back again for ELSER (see [https://github.com/elastic/elasticsearch/pull/98996](https://github.com/elastic/elasticsearch/pull/98996)) nd will probably diverge from rank feature over time.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 17, 2024, 3:41pm UTC](https://discuss.elastic.co/t/sparse-vector-embeddings/353498/7 "2024-03-17T15:41:45Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
