The `rerankers` library employs a robust, extensible architecture designed for diverse reranking needs. At its heart, the `Reranker Core Interface` serves as a central facade, providing a unified entry point for all reranking operations. This interface intelligently dispatches requests to specialized strategy components: `API Reranker Clients` for seamless integration with external reranking services, `LLM-Based Reranker Strategies` for advanced reranking powered by large language models, and `Transformer-Based Reranker Strategies` for efficient local inference using various transformer models. All these specialized components consistently interact with a `Utility Services` module, which provides essential helper functions and common data structures, ensuring a clean separation of concerns and promoting code reusability. This design allows for easy expansion with new reranking models and APIs while maintaining a consistent and intuitive user experience.
Components
Reranker Core Interface
The central entry point and factory for the entire library, providing a unified Reranker function. It dynamically selects and instantiates the correct reranker strategy.
Referenced Source Code
API Reranker Clients
Handles interactions with external reranking APIs (e.g., Cohere, Jina, MixedBread, Pinecone, Isaacus, OpenAI, Voyage AI, HuggingFace TEI), managing request formatting and response parsing.
Referenced Source Code
LLM-Based Reranker Strategies
Implements reranking logic leveraging Large Language Models (LLMs), including techniques like layer-wise ranking, relevance filtering, and permutation-based ranking (e.g., RankGPT, RankLLM).
Referenced Source Code
Transformer-Based Reranker Strategies
Implements reranking logic based on various transformer architectures (e.g., CrossEncoder, ColBERT, MonoVLM, T5, MXBAI V2, UPR), handling model loading, tokenization, and inference.
Referenced Source Code
Utility Services
Provides common helper functions and utilities used across different reranker implementations, such as verbose output, data preprocessing, and common data structures.