DenseEncoder Objects

class DenseEncoder(BaseModel)

set_score_threshold

@field_validator("score_threshold")
def set_score_threshold(cls, v: float | None) -> float | None

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__

def __call__(docs: List[Any]) -> List[List[float]]

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

def acall(docs: List[Any]) -> Coroutine[Any, Any, List[List[float]]]

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

class SparseEncoder(BaseModel)

An encoder that encodes documents into a sparse format.

__call__

def __call__(docs: List[str]) -> List[SparseEmbedding]

Encode a list of documents. Documents must be strings, sparse encoders do not

support other types.

Arguments:

  • docs (List[str]): The documents to encode.

Returns:

List[SparseEmbedding]: The encoded documents.

acall

async def acall(docs: List[str]) -> list[SparseEmbedding]

Encode a list of documents. Documents must be strings, sparse encoders do not

support other types.

Arguments:

  • docs (List[str]): The documents to encode.

Returns:

List[SparseEmbedding]: The encoded documents.