Reranker
-
interface
RerankerInterface -
- Fully qualified name
-
\Netresearch\Nr Llm\ Service\ Rerank\ Reranker Interface
Neutral cross-encoder reranking protocol (ADR-075: Neutral cross-encoder reranker protocol): scores retrieval candidates against a query. Candidates go in as plain
id/textshapes and scores come back as plainid/scoreshapes — no consumer DTOs cross the boundary. Consumers own DTO mapping, the ordering merge, the degradation policy on failure, and any score-threshold gate.The container service is factory-built from the extension configuration: an empty
rerankerresolves toEndpoint Null, a configured endpoint toReranker Http.Reranker rerank(string $query, array $candidates): array-
Score each (query, candidate text) pair. Returns one entry per scored candidate in input order; an entry the backend failed to score may be omitted — merge by
id.- param string $query
-
The query the candidates are scored against
- param array $candidates
-
list<array{id: string, text: string}> - throws
-
Rerankerwhen the reranker backend is unreachable or answers outside the protocolException
- Returns
-
list<array{id: string, score: float}>
-
class
HttpReranker -
- Fully qualified name
-
\Netresearch\Nr Llm\ Service\ Rerank\ Http Reranker
Speaks the cross-encoder sidecar contract (
Build/):reranker POSTwith{endpoint}/ rerank {"query", "documents"}, scores returned in input order. Pools above the sidecar's batch cap (128 documents) are split into sequential requests. The score scale is model-specific (defaultBAAI/).bge- reranker- v2- m3
-
class
NullReranker -
- Fully qualified name
-
\Netresearch\Nr Llm\ Service\ Rerank\ Null Reranker
Selected when no sidecar endpoint is configured. Returns one entry per candidate in input order with a uniform score of
0.— no ranking signal, shape-identical to0 Http.Reranker
-
class
RerankerException -
- Fully qualified name
-
\Netresearch\Nr Llm\ Service\ Rerank\ Exception\ Reranker Exception
Typed failure of the reranker backend: unreachable endpoint (code
1784750001), non-200 status (1784750002), invalid JSON (1784750003), or a response missing thescoresarray (1784750004). ImplementsNr(ADR-053); the caller decides how to degrade — nr_llm never silently falls back.Llm Exception Interface
Configuration
Extension configuration keys (nr_):
reranker— base URL of the cross-encoder sidecar, e.g.Endpoint http://. Empty (default) disables reranking.reranker: 8081 reranker— request timeout in seconds (default 30; a CPU cross-encoder can be slow for a wide candidate pool).Timeout
See Build/ for running the sidecar.