Rerank Results
The expensive model that fixes the ranking
- results
- reranker
- results
This is the node that makes the pack's "two-stage retrieval" real. Rerank Results sits between a search node and your outputs and applies the second, sharper model: instead of trusting FAISS's quick vector ranking, it re-scores each candidate by reading the query and the actual image together. It's slower, it costs you a second loaded model, and on the right library it's the difference between "good enough" and "the exact shot I meant."
The mechanism is cross-attention. The embedding model compared one vector per image; the reranker compares the query text against each candidate image's pixels in a joint model, which understands nuance that a single cosine similarity can't - "the one with dramatic rim lighting, not the flat one" is a distinction vector distance handles poorly and cross-attention handles well. The README's numbers frame the trade: stage one does thousands of candidates a second, the reranker tens per second. That's why it only ever sees the top-K that stage one already pulled.
Wiring and inputs
Feed it the results from any search node plus a RERANKER_MODEL (from Load Reranker Model). The knobs:
- top_k (default 10) - results kept after reranking. This is your final result count, so set it to what your output stage wants.
- query_text - optional override of the query. Useful when your original search was by image (there's no text to rerank against) and you want to rank by a text description instead.
- min_score - reranker-score floor (default 0). The reranker's scores are its own 0–1 scale and are not directly comparable to the embedding-model scores from stage one - don't expect 0.3 to mean the same thing it did upstream.
- instruction - default
"Retrieve images relevant to the query."This is the reranker's task description; leave it alone unless you're doing something specific like"Find similar invoices".
Output: results (SEARCH_RESULTS), ready for Preview Results / Load Result Images / Get Result Paths.
Install
Pack install as usual - ComfyUI Manager (search "Semantic-Search") or git clone https://github.com/EricRollei/Semantic-Search into custom_nodes, install requirements, restart. Plus the reranker model itself: another multi-gigabyte download into your configured models path (see Load Reranker Model), which the node errors about with the exact huggingface-cli command if you haven't fetched it.
Where people get burned
- Believing reranking fixes bad indexing. Garbage in, garbage out. If your library was indexed at 256x256, the reranker is re-scoring thumbnails and can't recover detail that was never encoded. Index well first; rerank second.
- Expecting the scores to match stage one. They won't, and they don't need to. Treat the reranker's scores as their own scale; use
min_scoreafter looking at real output, not by guessing. - The classic ordering mistake. Search (top_k=20) → Rerank (top_k=10) means the reranker only ever saw 20 candidates. If you want the best final 10, ask stage one for 50–100 so the reranker has room to promote a hidden gem. Undersized stage one is the most common reason reranking feels pointless.
- Double model load on a small card. Embedding + reranker 8B models can exceed 16GB VRAM together. Drop the reranker to the 2B, or skip reranking entirely - it's an enhancement, not a requirement.
It's the pack's "turn the dial from good to precise" node, and the only one that justifies loading a second model. Wire it right and the top of your results reads like you knew exactly what you were looking for.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| results | SEARCH_RESULTS | — | |
| reranker | RERANKER_MODEL | — | |
| query_textopt | STRING | Override query text for reranking | |
| top_kopt | INT | 101–100 | — |
| min_scoreopt | FLOAT | 0.000–1 | Minimum reranker score threshold (0-1). |
| instructionopt | STRING | Retrieve images relevant to the query. | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| results | SEARCH_RESULTS | — |