Skip to content

Reranker

Defines a base class for rerankers used in Gen AI applications.

Authors

Anggara Setiawan (anggara.t.setiawan@gdplabs.id)

References

NONE

BaseReranker

Bases: Component, ABC

An abstract base class for the rerankers used in Gen AI applications.

rerank(chunks, query=None) async

Rerank the list of chunks.

This method validates the input and calls the abstract _rerank method.

Parameters:

Name Type Description Default
chunks list[Chunk]

The list of chunks to be reranked.

required
query str | None

The query to be used for reranking. Defaults to None.

None

Returns:

Type Description
list[Chunk]

list[Chunk]: A list of reranked chunks.

Raises:

Type Description
ValueError

If chunks (and query in some subclasses) is empty or invalid.