# BM25SparseEmbedding

> **Class** in `langchain_milvus`

📖 [View in docs](https://reference.langchain.com/python/langchain-milvus/utils/sparse/BM25SparseEmbedding)

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
https://github.com/milvus-io/bootcamp/blob/master/bootcamp/tutorials/integration/langchain/full_text_search_with_langchain.ipynb
**

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

## Signature

```python
BM25SparseEmbedding(
    self,
    corpus: List[str],
    language: str = 'en',
)
```

## Extends

- `BaseSparseEmbedding`

## Constructors

```python
__init__(
    self,
    corpus: List[str],
    language: str = 'en',
)
```

| Name | Type |
|------|------|
| `corpus` | `List[str]` |
| `language` | `str` |


## Properties

- `analyzer`
- `bm25_ef`

## Methods

- [`embed_query()`](https://reference.langchain.com/python/langchain-milvus/utils/sparse/BM25SparseEmbedding/embed_query)
- [`embed_documents()`](https://reference.langchain.com/python/langchain-milvus/utils/sparse/BM25SparseEmbedding/embed_documents)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-milvus/blob/fe9d63e6dcae52e4c2e2ef4dafd5a6f7ee9b254c/libs/milvus/langchain_milvus/utils/sparse.py#L49)