Skip to content

Commit cca4cdc

Browse files
author
Erick Friis
authored
remove scipy dep for sparse embed (#3)
1 parent c7bfb53 commit cca4cdc

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

libs/milvus/langchain_milvus/utils/sparse.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from abc import ABC, abstractmethod
2-
from typing import Dict, List
3-
4-
from scipy.sparse import csr_array # type: ignore
2+
from typing import Any, Dict, List
53

64

75
class BaseSparseEmbedding(ABC):
@@ -46,7 +44,7 @@ def embed_documents(self, texts: List[str]) -> List[Dict[int, float]]:
4644
sparse_arrays = self.bm25_ef.encode_documents(texts)
4745
return [self._sparse_to_dict(sparse_array) for sparse_array in sparse_arrays]
4846

49-
def _sparse_to_dict(self, sparse_array: csr_array) -> Dict[int, float]:
47+
def _sparse_to_dict(self, sparse_array: Any) -> Dict[int, float]:
5048
row_indices, col_indices = sparse_array.nonzero()
5149
non_zero_values = sparse_array.data
5250
result_dict = {}

0 commit comments

Comments
 (0)