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) abstractmethod async

Rerank the list of chunks.

This abstract method must be implemented by subclasses to define how to rerank the list of chunks. It is expected to return a list of reranked chunks.

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
NotImplementedError

If the method is not implemented in a subclass.