Skip to content

Class: LlamaRankingContext

Defined in: evaluator/LlamaRankingContext.ts:51

See

Reranking Documents tutorial

Properties

onDispose

ts
readonly onDispose: EventRelay<void>;

Defined in: evaluator/LlamaRankingContext.ts:56

Accessors

disposed

Get Signature

ts
get disposed(): boolean

Defined in: evaluator/LlamaRankingContext.ts:156

Returns

boolean


model

Get Signature

ts
get model(): LlamaModel

Defined in: evaluator/LlamaRankingContext.ts:160

Returns

LlamaModel

Methods

rank()

ts
rank(query: 
  | string
  | LlamaText
  | Token[], document: 
  | string
  | LlamaText
  | Token[]): Promise<number>

Defined in: evaluator/LlamaRankingContext.ts:83

Get the ranking score for a document for a query.

A ranking score is a number between 0 and 1 representing the probability that the document is relevant to the query.

Parameters

ParameterType
query| string | LlamaText | Token[]
document| string | LlamaText | Token[]

Returns

Promise<number>

a ranking score between 0 and 1 representing the probability that the document is relevant to the query.


rankAll()

ts
rankAll(query: 
  | string
  | LlamaText
  | Token[], documents: (
  | string
  | LlamaText
  | Token[])[]): Promise<number[]>

Defined in: evaluator/LlamaRankingContext.ts:106

Get the ranking scores for all the given documents for a query.

A ranking score is a number between 0 and 1 representing the probability that the document is relevant to the query.

Parameters

ParameterType
query| string | LlamaText | Token[]
documents( | string | LlamaText | Token[])[]

Returns

Promise<number[]>

an array of ranking scores between 0 and 1 representing the probability that the document is relevant to the query.


rankAndSort()

ts
rankAndSort<T>(query: 
  | string
  | LlamaText
  | Token[], documents: T[]): Promise<{
  document: T;
  score: number;
 }[]>

Defined in: evaluator/LlamaRankingContext.ts:132

Get the ranking scores for all the given documents for a query and sort them by score from highest to lowest.

A ranking score is a number between 0 and 1 representing the probability that the document is relevant to the query.

Type Parameters

Type Parameter
T extends string

Parameters

ParameterType
query| string | LlamaText | Token[]
documentsT[]

Returns

Promise<{ document: T; score: number; }[]>


dispose()

ts
dispose(): Promise<void>

Defined in: evaluator/LlamaRankingContext.ts:147

Returns

Promise<void>