Graphorin API reference v0.8.0
Graphorin API reference / @graphorin/reranker-transformersjs / / scoresFromLogits
Function: scoresFromLogits()
ts
function scoresFromLogits(
data,
dims,
id2label,
pairCount): number[];Defined in: packages/reranker-transformersjs/src/cross-encoder.ts:303
Internal
Convert a raw [pairCount, numLabels] logits tensor into relevance scores aligned with the input pair order:
- single-logit heads (the default bge reranker exports) → sigmoid, preserving the model's discrimination instead of softmaxing the lone logit to a constant
1.0; - multi-logit heads → softmax over the row, reading the POSITIVE label's probability via
config.id2label(falling back to index 1 for unlabeled binary heads per theLABEL_0/LABEL_1convention, then to the max probability - parity with extractPairScores).
Parameters
| Parameter | Type |
|---|---|
data | ArrayLike<number> |
dims | readonly number[] |
id2label | Readonly<Record<string, string>> | undefined |
pairCount | number |
Returns
number[]