<!-- Source: https://docs.squirro.com/en/latest/technical/search/relevancy/scoring-plugins/_autosummary/squirro.lib.search.relevancy.plugins.rerank.transformer_rerankers.Reranker.html -->
# Reranker

**`class Reranker`**

reranker | **Rerank** first-stage retrieved paragraphs based on the **contextualized similarity** of query <-> paragraph.

Pass each **pair of query/paragraph** through a transformer network simultaneously. The **reranker** produces a score indicating the **contextualized similarity** per text pair.

Requires a dedicated reranker worker to be registered ([learn more](../../../how-to-guides/how-remote-models.md#search-how-integrate-remote-models)).

**`pydantic model PluginConfig`**

Fields

- `original_score_weight (float)`
- `query (str | None)`
- `rerank_score_mode (squirro.lib.search.relevancy.plugins.rerank.transformer_rerankers.RerankerScoreMode)`
- `reranker_score_weight (float)`
- `top_n_items (int)`
- `worker (str)`

**`PluginConfig.plugin_name: ClassVar[str] = 'reranker'`**

Used to register and reference the plugin within a query.

**`field PluginConfig.top_n_items: int = 10`**

Amount of fetched items that should get reranked

**`field PluginConfig.query: Optional[str] = ''`**

left side of the text-pair, as used for contexutalized scoring. Per default fetches to supplied searchbar user-terms

**`field PluginConfig.worker: str = 'bge'`**

What registered reranker worker (@transformer-service) to use.

**`field PluginConfig.rerank_score_mode: RerankerScoreMode = RerankerScoreMode.weighted_avg`**

How to combine the score from the reranker stage with the original score determined by the retriever. Supported options are weighted_avg (leveraging minmax-normalization) and reranker_only.

**`field PluginConfig.reranker_score_weight: float = 0.5`**

Weight of the rerank score in the final score calculation. Effectively computing a weighted average of normalized scores if reranker_score_weight + original_score_weight = 1.0

**`field PluginConfig.original_score_weight: float = 0.5`**

Weight of the original score in the final score calculation. Effectively computing a weighted average of normalized scores if reranker_score_weight + original_score_weight = 1.0
