feat(embed): add the Reranker trait seam + NoopReranker#123
Merged
Conversation
The crate layout (spec decision 5) names a Reranker seam alongside Embedder, but it was absent from code (audit finding #7). v1 defers a real cross-encoder, so this lands the trait + an identity default without wiring it into the search path. - `Reranker` trait (async rerank(query, candidates) -> ranked) plus `Candidate` / `Ranked` shapes. - `NoopReranker` preserves first-stage order with descending scores — a behaviour-preserving default until the EmbeddingGemma CE head lands. Test plan: - escurel-embed reranker.rs unit tests: Noop preserves input order with strictly-descending scores; empty input → empty output. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes audit finding #7 (spec→impl): the crate layout (spec
decision 5) names a
Rerankerseam inescurel-embedalongsideEmbedder, but no such trait existed. v1's cut-line defers a realcross-encoder, so this PR lands the seam + an identity default and
deliberately does not wire it into the retrieval path.
Rerankertrait —async rerank(query, &[Candidate]) -> Vec<Ranked>(descending relevance), with
Candidate { id, text }/Ranked { id, score }.NoopReranker— preserves first-stage order with strictlydescending placeholder scores, so adopting it later is
behaviour-preserving until the bundled EmbeddingGemma CE head (or the
opt-in
bge-reranker-large) is implemented.Test plan
crates/escurel-embed/src/reranker.rsunit tests —NoopRerankerpreserves input order with descending scores; empty input → empty
output.
-D warnings,cargo test --workspace --all-targets, release build.🤖 Generated with Claude Code