pinecone_text.sparse.base_sparse_encoder
1from abc import ABC, abstractmethod 2from typing import Union, List 3 4from pinecone_text.sparse import SparseVector 5 6 7class BaseSparseEncoder(ABC): 8 @abstractmethod 9 def encode_documents( 10 self, texts: Union[str, List[str]] 11 ) -> Union[SparseVector, List[SparseVector]]: 12 """ 13 encode documents to a sparse vector (for upsert to pinecone) 14 15 Args: 16 texts: a single or list of documents to encode as a string 17 """ 18 pass # pragma: no cover 19 20 @abstractmethod 21 def encode_queries( 22 self, texts: Union[str, List[str]] 23 ) -> Union[SparseVector, List[SparseVector]]: 24 """ 25 encode queries to a sparse vector 26 27 Args: 28 texts: a single or list of queries to encode as a string 29 """ 30 pass # pragma: no cover
class
BaseSparseEncoder(abc.ABC):
8class BaseSparseEncoder(ABC): 9 @abstractmethod 10 def encode_documents( 11 self, texts: Union[str, List[str]] 12 ) -> Union[SparseVector, List[SparseVector]]: 13 """ 14 encode documents to a sparse vector (for upsert to pinecone) 15 16 Args: 17 texts: a single or list of documents to encode as a string 18 """ 19 pass # pragma: no cover 20 21 @abstractmethod 22 def encode_queries( 23 self, texts: Union[str, List[str]] 24 ) -> Union[SparseVector, List[SparseVector]]: 25 """ 26 encode queries to a sparse vector 27 28 Args: 29 texts: a single or list of queries to encode as a string 30 """ 31 pass # pragma: no cover
Helper class that provides a standard way to create an ABC using inheritance.
@abstractmethod
def
encode_documents( self, texts: Union[str, List[str]]) -> Union[Dict[str, Union[List[int], List[float]]], List[Dict[str, Union[List[int], List[float]]]]]:
9 @abstractmethod 10 def encode_documents( 11 self, texts: Union[str, List[str]] 12 ) -> Union[SparseVector, List[SparseVector]]: 13 """ 14 encode documents to a sparse vector (for upsert to pinecone) 15 16 Args: 17 texts: a single or list of documents to encode as a string 18 """ 19 pass # pragma: no cover
encode documents to a sparse vector (for upsert to pinecone)
Arguments:
- texts: a single or list of documents to encode as a string
@abstractmethod
def
encode_queries( self, texts: Union[str, List[str]]) -> Union[Dict[str, Union[List[int], List[float]]], List[Dict[str, Union[List[int], List[float]]]]]:
21 @abstractmethod 22 def encode_queries( 23 self, texts: Union[str, List[str]] 24 ) -> Union[SparseVector, List[SparseVector]]: 25 """ 26 encode queries to a sparse vector 27 28 Args: 29 texts: a single or list of queries to encode as a string 30 """ 31 pass # pragma: no cover
encode queries to a sparse vector
Arguments:
- texts: a single or list of queries to encode as a string