Skip to content

feat(bench): HyDE + RRF query expansion for low-recall categories - #213

Open
sebbsssss wants to merge 4 commits into
stagingfrom
feat/rrf-hyde-recall
Open

feat(bench): HyDE + RRF query expansion for low-recall categories#213
sebbsssss wants to merge 4 commits into
stagingfrom
feat/rrf-hyde-recall

Conversation

@sebbsssss

Copy link
Copy Markdown
Owner

Summary

Adds opt-in HyDE (Hypothetical Document Embeddings) + Reciprocal Rank Fusion to the LongMemEval benchmark recall step. Targets the ~15 no-recall misses we identified in SS-Pref and SS-User on the fresh-data baseline.

How it works

When --rrf-variants N is set (default off), and the question's category matches --rrf-categories (default single-session-preference,single-session-user):

  1. Generate N hypothetical first-person statements via Sonnet 4.5 that would directly answer the question if a user had said them in a past conversation
  2. Run cortex.recall() for each variant + the original question
  3. Merge the N+1 ranked lists via Reciprocal Rank Fusion (Cormack et al. 2009, k=60)
  4. Pass the merged top-K to the existing rerank + reader pipeline

Refs: HyDE (Gao et al.), RRF (Cormack et al. 2009).

Why

Vector search struggles when the question ("Where did I redeem the coupon?") and the answer-bearing memory ("I used the coupon at Target last Tuesday") have very different surface forms. Hypothetical-answer queries close that distribution gap.

Default categories chosen because they have the lowest evidence-hit rates on the current main:

  • SS-Pref: 76.7% (7/30 evidence-misses)
  • SS-User: 94.3% (4/70 evidence-misses)

Cost

Per question with --rrf-variants 2: +1 LLM call for HyDE generation + 2 extra recall calls + 2 extra embedding calls. Roughly +30-40% cost on the targeted categories only. No effect on other categories.

Test plan

  • Syntax-checks clean (npx tsx --help)
  • No-op when flag is unset (default benchmark behavior unchanged)
  • SS-Pref + SS-User subset test (~100 questions, ~$15) — in progress
  • Full LongMemEval-S run if subset is positive
  • Board verifies at cludebot-test-preview.up.railway.app (script-only change)

🤖 Generated with Claude Code

sebbsssss and others added 4 commits May 27, 2026 01:03
release: promote LongMemEval 77.2% milestone — fragments + chunked + rerank
staging → main: LongMemEval-S 82.4% via Opus reader on hard cats
PMP encryption control plane → production (revoke + re-delegate)
Add --rrf-variants N flag that generates N hypothetical first-person answer
statements via Sonnet 4.5 and uses each as an additional retrieval query.
Result lists from all N+1 queries (original + variants) are merged via
Reciprocal Rank Fusion (Cormack et al. 2009, k=60).

Default-targeted categories (--rrf-categories) are SS-Pref and SS-User,
which have the lowest evidence-hit rates (76.7% and 94.3% on fresh data).
Closes the question-vs-document distribution gap that vector search often
hits on benchmarks asking "what did I do?" where the answer-bearing memory
phrases the fact directly rather than echoing the question.

No effect when --rrf-variants is unset; this is opt-in for benchmarking.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel

vercel Bot commented May 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cluude Ready Ready Preview, Comment May 30, 2026 1:23pm

Request Review

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