Skip to content

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 the LABEL_0/LABEL_1 convention, then to the max probability - parity with extractPairScores).

Parameters

ParameterType
dataArrayLike<number>
dimsreadonly number[]
id2labelReadonly<Record&lt;string, string&gt;> | undefined
pairCountnumber

Returns

number[]