fix(agent): make the recall reranker opt-in and use the word embedder in tests

The reference-set comparison showed the cross-encoder adds nothing to mem0's
ranking and costs about 130 ms per search.
This commit is contained in:
shumeiko.it
2026-10-24 11:57:18 +02:00
parent 10e67f37a5
commit 2d507dc457
2 changed files with 21 additions and 13 deletions

View File

@@ -78,10 +78,12 @@ export interface OrchestratorConfig {
version?: string;
skills?: string[];
/**
* W4.2: optional cross-encoder reranker injected for tests. When absent,
* a lazy in-process reranker (Xenova/ms-marco-MiniLM-L-6-v2, ~22MB ONNX)
* is created on first recall unless WAGGLE_RERANKER=0; creation failure
* soft-fails to the store's own ordering.
* W4.2: optional cross-encoder reranker injected for tests. When absent and
* WAGGLE_RERANKER=1, a lazy in-process reranker (Xenova/ms-marco-MiniLM-L-6-v2,
* ~22MB ONNX) is created on first recall; creation failure soft-fails to the
* store's own ordering. Off by default: on the reference set it did not
* improve mem0's ranking and cost about 130 ms per search
* (docs/oss/research/memory-search-quality.md).
*/
reranker?: Reranker;
/** Optional managed cache root for the lazy in-process reranker model. */
@@ -366,14 +368,14 @@ export class Orchestrator {
}
/**
* W4.2/W4.5: lazy cross-encoder reranker — default on. Kill switch:
* WAGGLE_RERANKER=0. First use downloads the ~22MB model (cached at the
* configured managed path); creation failure (offline, OOM) memoizes
* undefined: recall soft-fails to the store's ordering, never throws.
* W4.2: lazy cross-encoder reranker, opt-in with WAGGLE_RERANKER=1. First use
* downloads the ~22MB model (cached at the configured managed path); creation
* failure (offline, OOM) memoizes undefined: recall soft-fails to the store's
* ordering, never throws.
*/
private getReranker(): Promise<Reranker | undefined> {
if (this.rerankerPromise) return this.rerankerPromise;
if (process.env['WAGGLE_RERANKER'] === '0') {
if (process.env['WAGGLE_RERANKER'] !== '1') {
this.rerankerPromise = Promise.resolve(undefined);
return this.rerankerPromise;
}