MCPcopy Create free account
hub / github.com/PatrickSys/codebase-context / scorePair

Function scorePair

src/core/reranker.ts:150–166  ·  view source on GitHub ↗

* Score a single (query, passage) pair using the cross-encoder. * Returns a relevance score (higher = more relevant).

(query: string, passage: string)

Source from the content-addressed store, hash-verified

148 * Returns a relevance score (higher = more relevant).
149 */
150async function scorePair(query: string, passage: string): Promise<number> {
151 if (!cachedTokenizer || !cachedModel) {
152 throw new Error('[reranker] Model not loaded — call ensureModelLoaded() first');
153 }
154
155 const inputs = cachedTokenizer(query, passage, {
156 padding: true,
157 truncation: true,
158 max_length: 512
159 });
160
161 const output = await cachedModel(inputs);
162
163 // Cross-encoder outputs a single logit for relevance
164 const score = output.logits.data[0];
165 return score;
166}
167
168/**
169 * Detect whether the result set has ambiguous ordering.

Callers 1

rerankFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected