FlashRank

PrithivirajDamodaran/FlashRank

Ultra-lite & Super-fast Python library for re-ranking search results.

989
Stars
70
Forks
10
Open issues
6
Watchers
6mo
Last push
Python Apache-2.0Created Dec 4, 2023

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

  1. Features
  2. Installation
  3. Making ranking faster
  4. Getting started
  5. Deployment patterns
  6. How to Cite?
  7. Papers citing flashrank

Features

  1. Ultra-lite:

    • No Torch or Transformers needed. Runs on CPU.
    • Boasts the tiniest reranking model in the world, ~4MB.
  2. ⏱️ 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
  3. 💸 $ 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.
  4. 🎯 Based on SoTA Cross-encoders and other models:

    • "How good are Zero-shot rerankers?" - look at the reference section.
Model NameDescriptionSizeNotes
ms-marco-TinyBERT-L-2-v2Default model~4MBModel card
ms-marco-MiniLM-L-12-v2Best Cross-encoder reranker~34MBModel card
rank-T5-flanBest non cross-encoder reranker~110MBModel card
ms-marco-MultiBERT-L-12Multi-lingual, supports 100+ languages~150MBSupported languages
ce-esci-MiniLM-L12-v2Fine-tuned on Amazon ESCI dataset-Model card
rank_zephyr_7b_v1_full4-bit-quantised GGUF~4GBModel card
miniReranker_arabic_v1Only 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

Command menu

Search tools or jump to a page