RetrievalHit#
- class scikitplot.corpus.RetrievalHit(doc, score, match_mode, backend=None, index_generation=None, native_score=None, native_metric=None, contributions=(), rank=None)[source]#
A single search result.
- Parameters:
- docCorpusDocument
The matched document.
- scorefloat
Relevance score (higher is better). Scale depends on match mode:
STRICT: 1.0 if match, 0.0 otherwise
KEYWORD: Jaccard similarity [0, 1] or BM25 score
SEMANTIC: cosine similarity [-1, 1]
HYBRID: reciprocal rank fusion score
- match_modestr
The mode that produced this result.
- backendstr or None
Name of the dense ANN backend that produced this result (SEMANTIC/HYBRID), or
Nonefor STRICT/KEYWORD. Provenance only: excluded from equality and hashing.- index_generationIndexGeneration or None
The
RetrievalIndexbuild generation that produced this result. Increments on everyRetrievalIndex.build, so a caller can detect results computed against a since-rebuilt index. Provenance only: excluded from equality and hashing.
- Parameters:
Notes
Developer note:
backendandindex_generationdescribe how the result was produced, not what it is, so they usecompare=False— two results for the same document/score/mode remain equal regardless of provenance. Embedding-model identity is out of scope here (it travels with the document embeddings; see the embedding-cache identity contract).- contributions: tuple = ()#
Per-leg provenance for a fused hit, empty for a single-leg hit.
Each entry records which leg found this document, at what rank, and with what native score and metric. A hit that ranked #1 in both legs and one that ranked #1 and #40 used to be indistinguishable – very different confidence signals collapsed into one fused float (finding F-R09-02).
- native_metric: str | None = None#
Scale of
native_score, e.g."cosine_similarity".§19 forbids comparing cosine, Euclidean, inner-product and backend-specific relevance scores as though they shared one scale. A hit that records its own scale lets a consumer verify no such comparison happened.
- native_score: float | None = None#
The score the backend actually returned, before any fusion.
scoreis the value this hit was ranked by, which for a fused result is not any backend’s output. Keeping them separate is what makes a fused score explainable rather than merely a number (finding F-R07-03).