Skip to content

orcalib.memoryset.reranker#

RerankResult dataclass #

RerankResult(scores, indices)

scores instance-attribute #

scores

The scores of the reranked memories.

indices instance-attribute #

indices

The indices of the reranked memories in the original list.

Reranker #

Bases: ABC

A reranker is a model that reranks a list of memories for a given query.

rerank abstractmethod #

rerank(query, memories, top_k=None)

Rerank the memories for the given query.

Parameters:

  • query (str) –

    The query with which the memories were retrieved.

  • memories (list[str]) –

    The texts of the memories to rerank.

  • top_k (int | None, default: None ) –

    The number of memories to return. If None, all memories are returned.

Returns:

  • RerankResult

    The reranked memories in the order of their scores.

finetune abstractmethod #

1
2
3
4
5
finetune(
    dataset,
    output_dir="./temp/reranker",
    training_args=None,
)

Fit the reranker to the given memories and labels.