rerank

Function

Abstract function, which needs to be implemented in a subclass. It is used to re-rank lists in texts and query based on similarities, placing the most similar list at the top.

Prototype

@abstractmethod
def rerank(query, texts, batch_size)

Parameters

Parameter

Data Type

Required/Optional

Description

query

String

Required

Question for re-ranking

texts

List[str]

Required

Text list to be re-ranked

batch_size

Integer

Optional

Batch size. The default value is 32. The value is determined by the device's graphics memory.

Return Value

Data Type

Description

np.array

Score array corresponding to texts