Skip to content

rrfScore

rrfScore(rank, k): number

Defined in: packages/core/src/vector-store/rrf.ts:37

Calculates the RRF score for a given rank position.

Formula: score = 1 / (k + rank)

The rank is 1-indexed (first result has rank 1, not 0).

number

The 1-indexed rank position of the document

number = RRF_K

The RRF constant (default: 60)

number

The RRF score for that rank

rrfScore(1); // 0.01639... (rank 1)
rrfScore(2); // 0.01613... (rank 2)
rrfScore(10); // 0.01429... (rank 10)