Skip to content

test(rag): compare hybrid and semantic ranking in the eval harness - #24

Merged
ipiton merged 2 commits into
ipiton:mainfrom
glockbender:codex/semantic-document-ranking
Nov 17, 2026
Merged

ipiton merged 2 commits into
ipiton:mainfrom
glockbender:codex/semantic-document-ranking

Conversation

@glockbender

@glockbender glockbender commented Nov 15, 2026 •

Copy link
Copy Markdown

Compare hybrid and semantic-only document ranking in the evaluation harness without adding a product search mode. This revises the original proposal following review: MCP_RAG_FUSION=semantic is removed, and release configuration retains its existing modes.

Harness.CompareRankings runs both variants against the same temporary index, encoder and QA set. It returns aggregate metrics with the hybrid fusion setting, cutoff and document cap; source text, paths and questions are not returned. make eval-compare reports the public fixture at caps 0 and 1, without rewriting or applying the hybrid baseline threshold to the experimental variant.

The evaluation search entry point is compiled only with -tags=eval. It shares normal query limits, errors and retrieval plumbing, skips keywords and recency/source/confidence boosts, and retains source filters, document diversity and trust metadata. The choice is per call, with no mutable engine mode. Missing vectors, loading vectors, provider fallback and reranker failures cannot silently substitute a different retrieval method. Normal MCP search behavior is preserved.

Validation:

  • make test vet eval passed; make eval now also runs the evaluation-only RAG regression tests
  • go test -race -tags=eval ./internal/rag ./internal/rag/eval ./internal/config passed
  • make eval-compare reproduced weighted 31/33 versus semantic 19/33 source hits at 5 with cap 0, and 31/33 versus 20/33 with cap 1
  • The committed default baseline and public question/corpus fixtures are unchanged
  • Tests cover release API exclusion, rejected product configuration value, ranking/filter/cap/tie behavior, fallback refusal, loading vectors, shared query guards, same-index comparison, cancellation and unchanged normal searches
  • Two independent code reviews and documentation consistency/quality review completed with no remaining introduced findings
  • All five GitHub checks passed on the updated head: fork CI

The fixture encoder is a deterministic 64-dimensional ASCII-token hash, so these numbers exercise ranking mechanics and do not measure multilingual embedding quality. No universal improvement or default change is claimed.

Updated against upstream 0.18.0 by merging main, preserving the published branch history. This contribution is independent of #21, #22, #23 and #25. No private documents, questions, corpus paths or generated corpus are included.

@ipiton

ipiton commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Clean implementation, and tests pass on current main once the vectorservice.go conflict with the new phase timings is resolved (keyword timing just moves inside if !semanticOnly). Before adding a user-facing ranking mode I'd like to understand the use case: the hybrid default was chosen on measured results (T124/T127), and this mode is described as a comparison tool. Could you share how semantic compares to weighted on make eval (and, if possible, aggregate numbers from your corpus — no private data needed)? If it's mainly for evaluation, an eval-harness option may fit better than a documented MCP_RAG_FUSION value.

@glockbender glockbender changed the title feat(rag): add opt-in semantic document ranking test(rag): compare hybrid and semantic ranking in the eval harness Nov 16, 2026
@glockbender

Copy link
Copy Markdown
Author

Thanks for the suggestion. I moved the comparison into the evaluation harness and updated this PR.

  • Removed semantic from the product fusion settings and configuration documentation.
  • Added Harness.CompareRankings and make eval-compare. Both variants use the same index, encoder and QA set; the result contains aggregate metrics and settings, without source text or questions.
  • The semantic search entry point exists only with -tags=eval. It uses the shared pipeline, preserves filters and the document cap, and refuses degraded fallback. Normal MCP search remains unchanged.
  • make test vet eval, evaluation-tagged race tests, and all five checks on the updated head passed in fork CI. The original baseline and fixture files are unchanged.

The current public fixture gives these results at K=5:

Document cap Ranking Expected source in top 5 MRR
0 weighted 31/33 (0.939394) 0.859596
0 semantic-only 19/33 (0.575758) 0.502525
1 weighted 31/33 (0.939394) 0.859596
1 semantic-only 20/33 (0.606061) 0.508586

make eval-compare reproduces this table. The fixture encoder hashes ASCII tokens into 64 dimensions; it checks ranking mechanics, not multilingual embedding quality. These results support retaining the weighted default.

For context, an earlier exploratory local bilingual trial with EmbeddingGemma 300M had audited source-hit@5 counts of 47/50 for weighted and 50/50 for semantic-only ranking. That small work-derived, agent-audited set predates 0.18.0; it is not an independent production benchmark, and I have not rerun it on the new base. These are source hits, not answer-quality scores. No private documents, queries or paths are included here. That observation motivated a comparison tool, rather than a general claim that semantic-only ranking is better.

The branch now includes upstream 0.18.0 without rewriting its published history, and the merge conflict is resolved.

@ipiton
ipiton merged commit 3e6fe5e into ipiton:main Nov 17, 2026
5 checks passed
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.

2 participants