RetrievalConfig#

class scikitplot.corpus.RetrievalConfig(top_k=10, match_mode='semantic', semantic_threshold=0.0, keyword_threshold=0.0, hybrid_alpha=0.5, rrf_k=60, use_normalized_text=True, case_sensitive=False, backend='auto', index_kwargs=<factory>, annoy_n_trees=10, annoy_metric='angular', annoy_search_k=-1, annoy_impl='auto', annoy_dtype=None, annoy_index_dtype=None, allow_fallback=True)[source]#

Configuration for similarity search.

Parameters:
top_kint

Maximum results to return.

match_modestr

One of "strict", "keyword", "semantic", "hybrid".

semantic_thresholdfloat

Minimum cosine similarity for SEMANTIC results.

keyword_thresholdfloat

Minimum keyword overlap for KEYWORD results.

hybrid_alphafloat

Dense share in HYBRID mode, shorthand for the two leg weights {lexical: 1 - alpha, dense: alpha} of FusionPolicy (R2-1): 0 returns the lexical leg alone and 1 the dense leg alone, exactly. Default 0.5.

rrf_kint

Reciprocal rank fusion constant, an int of at least 1. Default 60 (standard).

use_normalized_textbool

Use normalized_text for matching when available.

case_sensitivebool

Case-sensitive matching in STRICT mode.

backendstr or VectorIndexBackend subclass

Dense ANN backend selector for SEMANTIC/HYBRID modes. Built-in string names include "auto", "annoy", "faiss", "voyager" and "bruteforce". A custom VectorIndexBackend subclass may be supplied directly for an application-local backend without adding backend-specific fields to this dataclass.

index_kwargsmapping, optional

Generic constructor keyword arguments for the selected vector-index backend. Prefer this for new backend-specific tuning, for example index_kwargs={"n_trees": 20, "metric": "angular"} with Annoy. Existing annoy_* fields remain supported for compatibility.

annoy_n_treesint

Annoy tree count (accuracy/size trade-off) when the Annoy backend is used. Higher is more accurate and larger. Default 10.

annoy_metricstr

Annoy distance metric. Default "angular" (cosine-like); scores are always reported as cosine similarity regardless of metric.

annoy_search_kint

Annoy query-time node budget. -1 (default) lets Annoy choose.

annoy_implstr

Which Annoy index class to use: "auto" (default; a class that accepts every requested option, the high-level scikitplot.annoy.Index first, else the Cython scikitplot.annoy._annoy.Index), "highlevel", or "cython".

annoy_dtypestr or None

Embedding precision for the Cython Annoy class (e.g. "float32", "float64"); annoy_impl="auto" picks that class when it is set. The high-level class cannot honour it (see allow_fallback). Default None.

annoy_index_dtypestr or None

Item-id integer width for the Cython Annoy class (e.g. "int32", "uint64") for very large corpora. Default None.

allow_fallbackbool

What happens when the dense backend cannot run as configured (R2-5): under backend="auto" an installed backend that fails to load is skipped, and an Annoy option the running binding cannot honour is dropped, both reported on the dense leg (requested_backend, fallback_reason) and in RetrievalIndex.backend_provenance (True, default); False raises at build instead.

Parameters:
  • top_k (int)

  • match_mode (str)

  • semantic_threshold (float)

  • keyword_threshold (float)

  • hybrid_alpha (float)

  • rrf_k (int)

  • use_normalized_text (bool)

  • case_sensitive (bool)

  • backend (Any)

  • index_kwargs (Mapping[str, Any])

  • annoy_n_trees (int)

  • annoy_metric (str)

  • annoy_search_k (int)

  • annoy_impl (str)

  • annoy_dtype (str | None)

  • annoy_index_dtype (str | None)

  • allow_fallback (bool)

Notes

User note: For RAG pipelines, match_mode="hybrid" with default settings provides a good balance. For exact citation matching, use match_mode="strict". To force a specific ANN library, set e.g. backend="annoy" and tune annoy_n_trees.

allow_fallback: bool = True#
annoy_dtype: str | None = None#
annoy_impl: str = 'auto'#
annoy_index_dtype: str | None = None#
annoy_metric: str = 'angular'#
annoy_n_trees: int = 10#
annoy_search_k: int = -1#
backend: Any = 'auto'#
case_sensitive: bool = False#
hybrid_alpha: float = 0.5#
index_kwargs: Mapping[str, Any][source]#
keyword_threshold: float = 0.0#
match_mode: str = 'semantic'#
rrf_k: int = 60#
semantic_threshold: float = 0.0#
top_k: int = 10#
use_normalized_text: bool = True#