Skip to content

feat(recall): nomic embedder + cross-encoder rerank#5

Merged
nickroci merged 1 commit into
mainfrom
feat/recall
May 26, 2026
Merged

feat(recall): nomic embedder + cross-encoder rerank#5
nickroci merged 1 commit into
mainfrom
feat/recall

Conversation

@nickroci

Copy link
Copy Markdown
Owner

Summary

  • Replace all-MiniLM-L6-v2 (2021) with nomic-ai/nomic-embed-text-v1.5 — asymmetric query/document prompts, Matryoshka 768→128 dims, 8192-token context capped at 1024 for MPS stability.
  • Add cross-encoder rerank stage (cross-encoder/ms-marco-MiniLM-L-12-v2) between RRF fusion and the reinforcement/scope boost. Three-stage retrieval: BM25 + embeddings → RRF → cross-encoder.
  • Eager-load both models + run a full-pipeline warmup before the priming RPC socket opens, so the first hook request hits warm MPS kernels instead of a 6.8 s graph-compile cliff.
  • Hook budget 200 ms → 2000 ms (warm steady-state ~300-500 ms); server-side timeout 1.0 s → 1.8 s.
  • Recalibrated noise floors for the new embedder distribution: EMBEDDING_NOISE_FLOOR 0.25 → 0.50; new _RERANK_SCORE_FLOOR = -3.0 filters outright non-matches.
  • Cross-encoder load failures propagate (no silent degradation).
  • Logging setup pins httpcore / httpx / transformers / sentence_transformers et al. at WARNING so -v doesn't drown the daemon log in HF wire traffic.
  • einops added as runtime dep (nomic's custom RoPE module).
  • README updated with HF download expectations, ~25 s boot time, ~2.5 GB resident footprint, and corrected Tier-1 description.

Test plan

  • cd tools/search && uv run pytest — 174/174 pass (includes new test_reranker.py)
  • cd daemon && uv run pytest — 439/439 pass (3 priming tests updated to reflect the new "quality > quantity" rerank contract)
  • cd src && uv run pytest hooks/test_priming_client.py hooks/test_user_prompt_submit*.py — 68/68 pass
  • Pre-push hook (ruff + pyright + pytest with 90% coverage gate) — passed
  • End-to-end: started daemon, sent five priming RPC requests over Unix socket. Warm latencies 300-500 ms, top-1 results semantically on-target (e.g. "design a forgetting mechanism" → forgetting-ltd-decay-design).

🤖 Generated with Claude Code

…coder rerank

Replace the 2021-era all-MiniLM-L6-v2 embedder with nomic-embed-text-v1.5
(asymmetric query/document prompts, Matryoshka 768→128, 1024-token seq cap)
and add a cross-encoder rerank stage (ms-marco-MiniLM-L-12-v2) between RRF
fusion and the boost step. Three-stage retrieval — recall (BM25 +
embeddings) → fusion (RRF) → precision (cross-encoder) — gives the priming
snippet meaningful precision lift on a 169-entry library.

Daemon eagerly loads both models + runs a full-pipeline warmup before the
priming RPC socket opens, so the first hook request hits hot MPS kernels
instead of a 6.8s graph-compile cliff. Steady-state latency ~300-500ms,
within the bumped 2s hook budget (500ms accommodates slower hardware).

Calibrations for the new embedder distribution:
  - EMBEDDING_NOISE_FLOOR raised 0.25 → 0.50 (nomic's cosine sits higher)
  - _RERANK_SCORE_FLOOR at -3.0 catches weak-but-real matches; the
    embedding floor handles outright gibberish at the source.

Other adjustments:
  - Cross-encoder load failures now propagate (no silent degradation)
  - Hook budget 200ms → 2000ms; server-side request timeout 1.0s → 1.8s
  - Logging setup pins httpcore/httpx/transformers/sentence_transformers
    et al. at WARNING so -v doesn't drown the daemon log in HF wire traffic
  - einops added as runtime dep (required by nomic's custom RoPE module)

README updated with HF model download expectations, ~25s boot time, ~2.5GB
resident footprint, and a corrected Tier-1 description.

Tests: 681 passing (439 daemon + 174 search + 68 hooks). Three existing
tests updated to reflect the new "quality > quantity" rerank contract.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@nickroci nickroci merged commit d4ed0cb into main May 26, 2026
3 checks passed
nickroci added a commit that referenced this pull request May 27, 2026
- Quick start: replaced "Phase 4 work" (internal jargon) with
  "auto-supervision not yet implemented" — readers landing here
  shouldn't need to know our phase numbering.
- "Where your memories live" table: added the ``cost.json`` row
  (was already in the deeper Storage-on-disk tree but missing from
  the user-facing quickstart summary).
- Layout section: "177 pytest tests" → pointer to the Status
  section's current count, so this stops drifting every time we
  add tests.
- Cost section: ambient priming overhead was listed as "~500
  chars / ~150 tokens" with "BM25 + embeddings" pipeline. Updated
  to "~1500 chars / ~400 tokens" (matches the actual Tier-1
  budget) and added the cross-encoder rerank to the pipeline
  description (matches the Tier-1 table and what PR #5 actually
  shipped).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant