FlashRank
Ultra-lite & Super-fast Python library for re-ranking search results.
Overview
FlashRank is a lightweight, fast library for enhancing existing search and retrieval systems with pairwise or listwise re-ranking techniques based on both cross-encoders and large language models (LLMs).
Capability facts
No sourced capability facts yet. Facts appear after ingest scans repo manifests (Dockerfile, package.json, MCP configs).
Categories
Tags
README
Re-rank your search results with SoTA Pairwise or Listwise rerankers before feeding into your LLMs
Ultra-lite & Super-fast Python library to add re-ranking to your existing search & retrieval pipelines. It is based on SoTA LLMs and cross-encoders, with gratitude to all the model owners.
Supports:
- Pairwise / Pointwise rerankers. (Cross encoder based, i.e.
Max tokens = 512) - Listwise LLM based rerankers. (LLM based, i.e.
Max tokens = 8192) - See below for full list of supported models.
Before you proceed. Thanks to Tiger-CRM for sponsoring my work, they source OSS developers check it out
Table of Contents
- Features
- Installation
- Making ranking faster
- Getting started
- Deployment patterns
- How to Cite?
- Papers citing flashrank
Features
-
⚡ Ultra-lite:
- No Torch or Transformers needed. Runs on CPU.
- Boasts the tiniest reranking model in the world, ~4MB.
-
⏱️ Super-fast:
- Rerank speed is a function of # of tokens in passages, query + model depth (layers)
- To give an idea, Time taken by the example (in code) using the default model is below.
- Detailed benchmarking, TBD
-
💸 $ concious:
- Lowest $ per invocation: Serverless deployments like Lambda are charged by memory & time per invocation*
- Smaller package size = shorter cold start times, quicker re-deployments for Serverless.
-
🎯 Based on SoTA Cross-encoders and other models:
- "How good are Zero-shot rerankers?" - look at the reference section.
| Model Name | Description | Size | Notes |
|---|---|---|---|
ms-marco-TinyBERT-L-2-v2 | Default model | ~4MB | Model card |
ms-marco-MiniLM-L-12-v2 | Best Cross-encoder reranker | ~34MB | Model card |
rank-T5-flan | Best non cross-encoder reranker | ~110MB | Model card |
ms-marco-MultiBERT-L-12 | Multi-lingual, supports 100+ languages | ~150MB | Supported languages |
ce-esci-MiniLM-L12-v2 | Fine-tuned on Amazon ESCI dataset | - | Model card |
rank_zephyr_7b_v1_full | 4-bit-quantised GGUF | ~4GB | Model card |
miniReranker_arabic_v1 | Only dedicated Arabic Reranker | - | Model card |
- Models in roadmap:
- InRanker
- Why sleeker models are preferred ? Reranking is the final leg of larger retrieval pipelines, idea is to avoid any extra overhead especially for user-facing scenarios. To that end models with really small footprint that doesn't need any specialised hardware and yet offer competitive performance are chosen. Feel free to raise issues to add support for a new models as you see fit.
Installation:
If you need lightweight pairwise rerankers [default]
pip install flashrank
If you need LLM based listwise rerankers
pip install flashrank[listwise]
Making ranking faster:
max_length value should be large able to accomodate your longest passage. In other words if your longest passage (100 tokens) + query (16 tokens) pair by token estimate is 116 then say setting max_length = 128 is good enough