Skip to content

feat(rag): evaluate a local cross-encoder/cosine rerank stage alongside BM25 #4368

Description

@JSONbored

Part of #4325.

Context

src/review/rag.ts:507/src/review/rag-wire.ts:191-201 rerank RAG retrieval candidates with lexical BM25 only (reranker: "bm25") — already shipped and working (#1124). There is no embedding-based or cross-encoder rerank stage, despite the query's own bge-m3 embedding already being computed at retrieval time (rag.ts:435) and sitting idle after the initial cosine search. Unlike the other items in this batch, this is explicitly NOT a known bottleneck — it's an evaluation, not a guaranteed win.

Requirements

  • This is a MEASURE-FIRST issue, not a build-first one. Before writing a reranker: establish whether BM25 is actually leaving retrieval quality on the table for real review queries — e.g. sample a set of past reviews, compare BM25-reranked top-K against a cosine-only or cross-encoder-reranked top-K, and see if the ordering meaningfully differs in a way that would change what gets injected into the review prompt.
  • If the evaluation shows a real gap: the cheapest local option is reranking top-K by cosine similarity against the ALREADY-COMPUTED query embedding (no new model, no new GPU call) before falling back to a dedicated small cross-encoder model — note Ollama has no native /rerank endpoint, so a real cross-encoder would need a sidecar (text-embeddings-inference/infinity), a real infrastructure addition, not a config flip.
  • If the evaluation does NOT show a meaningful gap: close this issue with the evaluation recorded rather than shipping a reranker for a problem that doesn't exist. Mirrors Stretch: evaluate spare GPU headroom for a local vision-language model in visual-review #4335's own "a complete, successful outcome for this issue, not a failure" framing for a negative result.

Deliverables

Expected outcome

A data-backed answer on whether RAG retrieval quality is actually reranker-limited, avoiding speculative infrastructure for an unproven gain — or a concrete, justified improvement if the data says otherwise.

Effort

S (evaluation) / M (if a build is justified)

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions