Ireranker

Classes

class arshai.core.interfaces.ireranker.IRerankInput(**data)[source]

Bases: IDTO

Represents the input for reranking.

query

The search query

documents

List of documents to rerank

config

Optional configuration for the reranking process

query: str
documents: List[Document]
model_config: ClassVar[ConfigDict] = {'allow_mutation': False, 'arbitrary_types_allowed': True, 'smart_union': True, 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class arshai.core.interfaces.ireranker.IReranker(*args, **kwargs)[source]

Bases: Protocol

Interface defining the contract for rerankers. Any reranker implementation must conform to this interface.

rerank(input)[source]

Rerank the documents based on their relevance to the query.

Parameters:

input (IRerankInput) – IRerankInput containing query, documents and optional config

Return type:

List[Document]

Returns:

List of reranked Document objects

async arerank(input)[source]

Asynchronously rerank the documents based on their relevance to the query.

Parameters:

input (IRerankInput) – IRerankInput containing query, documents and optional config

Return type:

List[Document]

Returns:

List of reranked Document objects

__init__(*args, **kwargs)