AI/TLDR

FlashRank

Lightweight, fast cross-encoder reranking for your search and RAG pipelines

Rerank, Search & HybridOpen source
Language
Python
License
Apache-2.0
$pip install flashrank

Overview

FlashRank is a small Python library that adds a reranking step to an existing search or retrieval pipeline. After a first-stage retriever returns a candidate list, FlashRank reorders those passages by how well they match the query, so the most relevant ones move to the top before you pass them to an LLM.

It is aimed at developers building RAG systems and search backends who want better ranking without heavy dependencies. It does not require Torch or Transformers and runs on CPU, and the default model is about 4MB, which keeps install size and cold-start times low, including on serverless platforms like AWS Lambda.

Within the rerankers and hybrid search category, FlashRank focuses on the final reranking leg of retrieval. It supports pairwise/pointwise cross-encoders (max 512 tokens) and listwise LLM-based rerankers (max 8192 tokens), letting you trade model size for ranking quality.

What it does

  • No Torch or Transformers dependency; runs on CPU
  • Default model is around 4MB, with a range of larger models for higher precision
  • Supports both pairwise/pointwise cross-encoders and listwise LLM-based rerankers
  • Includes a multilingual model (ms-marco-MultiBERT-L-12) covering 100+ languages and a dedicated Arabic reranker
  • Small package size keeps cold starts and redeploys quick on serverless setups
  • Configurable max_length to match passage size and control latency

Getting started

Install FlashRank, create a Ranker, then build a RerankRequest from your query and retrieved passages and call rerank.

Install the package

Install the default build for lightweight pairwise rerankers. For listwise LLM-based rerankers, install the optional extra instead.

bashbash
pip install flashrank

Install listwise extras (optional)

Only needed if you want the LLM-based listwise rerankers.

bashbash
pip install flashrank[listwise]

Rerank your retrieved passages

Create a Ranker with the default ~4MB model, wrap your query and passages in a RerankRequest, and call rerank. Each passage is a dict with an id, text, and optional meta; results come back ordered by score.

pythonpython
from flashrank import Ranker, RerankRequest

ranker = Ranker(max_length=128)

query = "How to speedup LLMs?"
passages = [
    {"id": 1, "text": "Introduce lookahead decoding...", "meta": {"additional": "info1"}},
    {"id": 2, "text": "LLM inference efficiency...", "meta": {"additional": "info2"}},
]

rerankrequest = RerankRequest(query=query, passages=passages)
results = ranker.rerank(rerankrequest)
print(results)

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Reordering top-k results from a vector or keyword search before sending context to an LLM in a RAG pipeline
  • Adding a low-latency reranking step to a serverless API (e.g. AWS Lambda) where package size and cold starts matter
  • Improving result ordering on CPU-only or resource-constrained hosts without installing Torch
  • Reranking multilingual search results using the 100+ language model or the dedicated Arabic reranker

How FlashRank compares

FlashRank alongside other open-source rerank, search & hybrid tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Elasticsearch★ 77.9kDistributed search and analytics engine with a built-in vector database for dense/sparse embeddings and hybrid keyword-plus-semantic retrieval.
Meilisearch Cloud★ 59.3kManaged cloud for the Meilisearch engine, combining fast full-text search with hybrid, semantic, and multimodal vector search.
Typesense Cloud★ 26.6kManaged hosting for the Typesense search engine, offering typo-tolerant keyword search plus vector and semantic search via a simple API.
Tantivy★ 16.1kA fast full-text search engine library in Rust that provides BM25 keyword search for the lexical half of hybrid retrieval.
FlagEmbedding★ 12.2kBAAI's retrieval toolkit that provides the BGE embedding and cross-encoder reranker models used widely in RAG pipelines.
Vespa★ 7.1kA search and serving engine that natively combines vector, keyword (BM25), and structured search with built-in ranking for large-scale retrieval.
RAGatouille★ 4kA wrapper that makes it easy to train and use ColBERT late-interaction retrieval inside RAG pipelines.
FlashRank★ 1kLightweight, fast cross-encoder reranking for your search and RAG pipelines