Skip to content

API Reference parrot.rerankers.models

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.rerankers.models

View source

Pydantic data models for the reranker subsystem.

This module defines the data structures used by all reranker implementations:

  • RerankedDocument: a SearchResult enriched with reranker scoring metadata.
  • RerankerConfig: construction configuration for LocalCrossEncoderReranker.

Class RerankedDocument

A SearchResult enriched with reranker scoring.

The original SearchResult is preserved via composition (not inheritance) so that downstream context-building code can extract document and continue with the existing pipeline unchanged.

Fields:

Field Type Default Description
document SearchResult The original retrieval hit from the vector store.
rerank_score float Raw reranker logit / relevance score (higher = more relevant). May be float('nan') when the reranker failed and returned the original ordering as a fallback.
rerank_rank int 0-based rank after reranking (0 = most relevant).
original_rank int 0-based rank in the upstream retrieval result (before rerank).
rerank_model str HuggingFace model ID used for scoring.
rerank_latency_ms Optional[float] None End-to-end latency for the full batch, in milliseconds. Populated by the reranker for telemetry; None if not measured.

Class RerankerConfig

Construction configuration for LocalCrossEncoderReranker.

Fields:

Field Type Default Description
model_name str 'BAAI/bge-reranker-v2-m3' HuggingFace model ID to load. Default: "BAAI/bge-reranker-v2-m3" (production, multilingual). Alternatives: - "jinaai/jina-reranker-v2-base-multilingual" (requires trust_remote_code=True). - "cross-encoder/ms-marco-MiniLM-L-12-v2" (dev/CI fast path).
device str 'auto' Target device. "auto" resolves to "cuda" if a GPU is available, otherwise "cpu".
precision str 'auto' Numeric precision. "auto" resolves to FP16 on CUDA and INT8 (PyTorch dynamic quantization) on CPU. Explicit values: "fp32", "fp16", "int8".
max_length int 512 Maximum token length for tokenisation. Inputs longer than this value are truncated.
batch_size int 32 Number of (query, passage) pairs processed per forward pass when the document list exceeds this value.
trust_remote_code bool False Required True for Jina v2 models that use a custom HuggingFace architecture class. Default False for security.
warmup bool True When True, a dummy forward pass is executed at construction time to trigger CUDA kernel JIT and weight materialisation so that the first real request does not pay cold-start latency.

Alias SearchResult

Re-exported from parrot.models.stores.SearchResult.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally