BM25SparseEmbedding#

class langchain_milvus.utils.sparse.BM25SparseEmbedding(corpus: List[str], language: str = 'en')[source]#

Sparse embedding model based on BM25.

**Note: We recommend using the Milvus built-in BM25 function to implement sparse embedding in your application. This class is more of a reference because it requires the user to manage the corpus,

which is not practical. The Milvus built-in function solves this problem and makes the BM25 sparse process easier and less frustrating for users.

For more information, please refer to: https://milvus.io/docs/full-text-search.md#Full-Text-Search and milvus-io/bootcamp **

This class uses the BM25 model in Milvus model to implement sparse vector embedding. This model requires pymilvus[model] to be installed. pip install pymilvus[model] For more information please refer to: https://milvus.io/docs/embed-with-bm25.md

Methods

__init__(corpus[,Β language])

embed_documents(texts)

Embed search docs.

embed_query(text)

Embed query text.

Parameters:
  • corpus (List[str])

  • language (str)

__init__(corpus: List[str], language: str = 'en')[source]#
Parameters:
  • corpus (List[str])

  • language (str)

embed_documents(texts: List[str]) β†’ List[Dict[int, float]][source]#

Embed search docs.

Parameters:

texts (List[str])

Return type:

List[Dict[int, float]]

embed_query(text: str) β†’ Dict[int, float][source]#

Embed query text.

Parameters:

text (str)

Return type:

Dict[int, float]