Sign inSign up

zandervdm/flashrank-api

By zandervdm

•Updated almost 2 years ago

Simple container to use FlashRank as an API.

Image
0

405

zandervdm/flashrank-api repository overview

⁠FlashRank-API

FlashRank-API is a FastAPI-based REST service that provides text reranking capabilities using the FlashRank library. It allows you to rerank a list of passages based on their relevance to a given query using various BERT-based models.

⁠Features

  • Fast and efficient text reranking
  • Support for multiple BERT models
  • Configurable maximum sequence length
  • Built-in model caching
  • Health check endpoint
  • RESTful API interface

⁠Quick Start

docker pull flashrank-api:latest
docker run -p 8000:8000 flashrank-api:latest

The API will be available at http://localhost:8000.

⁠API Endpoints

⁠POST /rerank

Reranks a list of passages based on their relevance to a query.

⁠Request Body
{
  "query": "your search query",
  "passages": [
    {
      "id": "1",
      "text": "passage content",
      "meta": {
        "optional_key": "optional_value"
      }
    }
  ],
  "max_length": 128,
  "model": "ms-marco-MultiBERT-L-12"
}

Parameters:

  • query (required): The search query to rank passages against
  • passages (required): Array of passages to rank
    • id: Unique identifier for the passage (any type)
    • text: The passage content
    • meta: Optional metadata object
  • max_length (optional): Maximum sequence length for the model (default: 128)
  • model (optional): Name of the BERT model to use (default: "ms-marco-MultiBERT-L-12")
⁠Response
{
  "results": [
    {
      "id": "1",
      "score": 0.95,
      "text": "passage content",
      "meta": {
        "optional_key": "optional_value"
      }
    }
  ]
}
⁠GET /health

Health check endpoint to verify service status.

⁠Response
{
  "status": "healthy"
}

⁠Technical Details

  • Base image: python:3.9-slim
  • Working directory: /app
  • Exposed port: 8000
  • Model cache directory: /opt/flashrank_cache
  • Server: uvicorn

⁠License

This project is licensed under the MIT License - see the LICENSE file for details.

Tag summary

Content type

Image

Digest

sha256:5cdc0d158…

Size

106.5 MB

Last updated

almost 2 years ago

docker pull zandervdm/flashrank-api