Skip to content

RAG hybrid retrieval: BM25 + knn with RRF, integration test, prompt fix (#79) - #92

Merged
reekitconcept merged 1 commit into
feature-ai-ragfrom
kid/460/hybrid-rrf-tests
Jul 28, 2026
Merged

RAG hybrid retrieval: BM25 + knn with RRF, integration test, prompt fix (#79)#92
reekitconcept merged 1 commit into
feature-ai-ragfrom
kid/460/hybrid-rrf-tests

Conversation

@reekitconcept

Copy link
Copy Markdown
Member

Post-MVP step P1 (ticket: distribution-kitconcept-intranet#460, part of #79), pulled forward: hybrid retrieval — keyword and vector search have complementary failure modes (exact names/codes vs. paraphrase).

What's included

  • P1.1 Hybrid retrieval in the query pipeline: parent-level Reciprocal Rank Fusion (k=60) of the knn chunk ranking (collapsed to parents) and the classic keyword (BM25) parent ranking; keyword-only parents get their leading chunks fetched for prompt context. Hybrid is the default; KITCONCEPT_SOLR_RAG_RETRIEVAL=knn switches back to pure knn (for corpus evaluation). Client-side fusion is drop-in replaceable by Solr's native RRF when 9.11/10.1 ships.
  • BM25 parity: the keyword side is an exact copy of the @solr main query — same fields and boosts including searchwords^1000 (the editorial "pin a document for a keyword" mechanism) and the -showinsearch:False exclusion; both must behave identically in the AI search. Field notes and refactoring criteria documented in the module.
  • P1.2 CI-runnable integration test: real docker Solr with a deterministic mock LLM (topic-axis unit vectors), no network needed.
  • Prompt fix: context chunks labeled by document title instead of bracketed numbers — models reliably leaked "[1]"-style references into answers; with title labels the leak disappears (verified: zero bracketed references across all golden answers).
  • Docs: Step P1 design decisions in IMPLEMENTATION-79; the facet/tab scoping question recorded as the remaining open point in SPECIFICATION-79 §8 (to be discussed in the review).

Verification

Against the bundled German demo corpus (#89): golden questions 19/19 retrieval hits, 2/2 declines, zero answers with bracketed references; RAG test suite 128 passed (integration tests verified against a clean docker Solr).

…ix (#79)

Post-MVP step P1 (#460), pulled forward: hybrid retrieval is the
industry default because keyword and vector search have complementary
failure modes (exact names/codes vs. paraphrase).

- P1.1 hybrid retrieval in the query pipeline: parent-level Reciprocal
  Rank Fusion (k=60) of the knn chunk ranking (collapsed to parents)
  and the classic keyword (BM25) parent ranking; keyword-only parents
  get their leading chunks fetched for the prompt context. Hybrid is
  the default; KITCONCEPT_SOLR_RAG_RETRIEVAL=knn switches back to pure
  knn (for corpus evaluation). Client-side fusion is drop-in
  replaceable by Solr's native RRF when 9.11/10.1 ships.
- The BM25 side is an exact copy of the @solr main query: same fields
  and boosts including searchwords^1000 (the editorial "pin a document
  for a keyword" mechanism) and the -showinsearch:False exclusion -
  both must behave identically in the AI search. Field notes and the
  refactoring criteria are documented in the module.
- P1.2 CI-runnable integration test: real docker Solr with a
  deterministic mock LLM (topic-axis unit vectors), no network needed.
- Prompt: context chunks are labeled with their document title instead
  of bracketed numbers - models reliably leaked "[1]"-style references
  into answers (complied with the no-references instruction only about
  half the time); with title labels the leak disappears.
- Docs: Step P1 design decisions in IMPLEMENTATION-79.md; the facet/tab
  scoping question recorded as the remaining open point in
  SPECIFICATION-79.md §8 (to be discussed with Dante and Timo).

Verified against the bundled German demo corpus: golden questions 19/19
retrieval hits, 2/2 declines, zero answers containing bracketed
references; RAG test suite 128 passed.
@reekitconcept
reekitconcept force-pushed the kid/460/hybrid-rrf-tests branch from 6471fc8 to 3197b91 Compare July 28, 2026 14:59
@reekitconcept
reekitconcept merged commit 49f87a0 into feature-ai-rag Jul 28, 2026
17 checks passed
@reekitconcept
reekitconcept deleted the kid/460/hybrid-rrf-tests branch July 28, 2026 15:41
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