Skip to content

Graphorin API reference v0.12.1


Graphorin API reference / @graphorin/reranker-transformersjs / / extractPairScores

Function: extractPairScores()

ts
function extractPairScores(raw, pairCount): number[];

Defined in: packages/reranker-transformersjs/src/cross-encoder.ts:258

Internal

Normalises the raw pipeline output to a flat score[] aligned with the input pair order. Cross-encoder classifiers return either a single-best {label, score} per pair (the default single-logit bge exports) or an array of topk entries. For the array shape we read the POSITIVE label's confidence - NOT the max of any label (PS-16): an irrelevant pair's most confident class is the negative one, so taking the max would invert the ranking for any 2-label classifier. When no label looks positive (single-logit or unrecognised labels) we fall back to the top score.

Parameters

ParameterType
raw| readonly ClassifierResult[] | readonly readonly ClassifierResult[][]
pairCountnumber

Returns

number[]