semantic_router.encoders.base
DenseEncoder Objects
set_score_threshold
Set the score threshold. If None, the score threshold is not used.
Arguments:
v
(float | None
): The score threshold.
Returns:
float | None
: The score threshold.
__call__
Encode a list of documents. Documents can be any type, but the encoder must
be built to handle that data type. Typically, these types are strings or arrays representing images.
Arguments:
docs
(List[Any]
): The documents to encode.
Returns:
List[List[float]]
: The encoded documents.
acall
Encode a list of documents asynchronously. Documents can be any type, but the
encoder must be built to handle that data type. Typically, these types are strings or arrays representing images.
Arguments:
docs
(List[Any]
): The documents to encode.
Returns:
List[List[float]]
: The encoded documents.
SparseEncoder Objects
An encoder that encodes documents into a sparse format.
__call__
Sparsely encode a list of documents. Documents can be any type, but the encoder must
be built to handle that data type. Typically, these types are strings or arrays representing images.
Arguments:
docs
(List[Any]
): The documents to encode.
Returns:
List[SparseEmbedding]
: The encoded documents.
acall
Encode a list of documents asynchronously. Documents can be any type, but the
encoder must be built to handle that data type. Typically, these types are strings or arrays representing images.
Arguments:
docs
(List[Any]
): The documents to encode.
Returns:
List[SparseEmbedding]
: The encoded documents.
AsymmetricDenseMixin Objects
encode_queries
Convert query texts to dense embeddings optimized for querying
encode_documents
Convert document texts to dense embeddings optimized for storage
aencode_queries
Async version of encode_queries
aencode_documents
Async version of encode_documents
AsymmetricSparseMixin Objects
encode_queries
Convert query texts to dense embeddings optimized for querying
encode_documents
Convert document texts to dense embeddings optimized for storage
aencode_queries
Async version of encode_queries
aencode_documents
Async version of encode_documents