Skip to content

Class: LlamaRankingContext ​

Defined in: evaluator/LlamaRankingContext.ts:95

See ​

Reranking Documents tutorial

Properties ​

onDispose ​

ts
readonly onDispose: EventRelay<void>;

Defined in: evaluator/LlamaRankingContext.ts:102

Accessors ​

disposed ​

Get Signature ​

ts
get disposed(): boolean;

Defined in: evaluator/LlamaRankingContext.ts:229

Returns ​

boolean


model ​

Get Signature ​

ts
get model(): LlamaModel;

Defined in: evaluator/LlamaRankingContext.ts:233

Returns ​

LlamaModel


contextSize ​

Get Signature ​

ts
get contextSize(): number;

Defined in: evaluator/LlamaRankingContext.ts:237

Returns ​

number

Methods ​

rank() ​

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

Defined in: evaluator/LlamaRankingContext.ts:135

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[]
options?RankingOptions

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[])[], 
   options?: RankingOptions): Promise<number[]>;

Defined in: evaluator/LlamaRankingContext.ts:162

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[])[]
options?RankingOptions

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:198

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; }[]>


calculateInputLength() ​

ts
calculateInputLength(query: 
  | string
  | LlamaText
  | Token[], document: 
  | string
  | LlamaText
  | Token[]): number;

Defined in: evaluator/LlamaRankingContext.ts:214

Calculate the evaluation tokens length for a given query and document so you can determine whether it fits in the context size

Parameters ​

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

Returns ​

number


dispose() ​

ts
dispose(): Promise<void>;

Defined in: evaluator/LlamaRankingContext.ts:220

Returns ​

Promise<void>