Skip to content

API Reference parrot.rerankers.llm

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

parrot.rerankers.llm

View source

LLM-based debug reranker implementation.

This module provides LLMReranker, a debug/fallback reranker that uses any AbstractClient to score (query, document) pairs via a structured-output prompt.

NOT intended for production hot-path use. It exists so engineers can sanity-check LocalCrossEncoderReranker rankings against a strong reference LLM (e.g. GPT-4, Claude) without external reranking services.

Throughput characteristics:

  • Scores each document independently using the LLM's invoke() method.
  • Uses asyncio.gather() to score documents concurrently.
  • No batching, no caching — this is a debug tool only.

Alias AbstractClient

Re-exported from parrot.clients.base.AbstractClient.

Alias AbstractReranker

Re-exported from parrot.rerankers.abstract.AbstractReranker.

Class LLMReranker

Debug reranker that uses an LLM to score query-passage pairs.

This reranker calls the LLM once per document to obtain a relevance score in the range [0.0, 1.0]. Documents are scored concurrently via asyncio.gather(). Results are sorted in descending order by score.

On any failure (LLM error, parse error), the reranker logs a WARNING and returns the original ordering with rerank_score=float('nan').

Parameter Type Default Description
client Optional[AbstractClient] Any concrete AbstractClient subclass (OpenAI, Anthropic, etc.).
model_name str 'llm-reranker' Optional display name for rerank_model in the output. Defaults to "llm-reranker".
**kwargs {} Reserved for future extension.

Method LLMReranker.rerank

Score (query, document) pairs via LLM and return sorted results.

Each document is scored independently with a single LLM call. All calls are issued concurrently via asyncio.gather().

rerank(query: str, documents: list[SearchResult], top_n: Optional[int] = None) -> list[RerankedDocument]

Parameter Type Default Description
query str User query text.
documents list[SearchResult] Candidate documents from upstream retrieval.
top_n Optional[int] None If set, return only the top N results. None returns all.

Returns: list[RerankedDocument] — RerankedDocument list sorted by descending rerank_score. On failure, returns the original ordering with rerank_score=NaN.

Alias RerankedDocument

Re-exported from parrot.rerankers.models.RerankedDocument.

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