Skip to main content

A package for massive serving

Project description

Massive Serve User Guide

A scalable search and retrieval system using FAISS indices.

Installation

Installation

pip install massive-serve

Usage

Serve index

To serve a wikipedia datastore:

massive-serve dpr-wiki

Send Requests

If the API has been served, you can either send single or bulk query requests to it.

Bash Examples.

# single-query request
curl -X POST <user>@<address>:<port>/search -H "Content-Type: application/json" -d '{"query": "Where was Marie Curie born?", "n_docs": 1, "domains": "MassiveDS"}'

# multi-query request
curl -X POST <user>@<address>:<port>/search -H "Content-Type: application/json" -d '{"query": ["Where was Marie Curie born?", "What is the capital of France?", "Who invented the telephone?"], "n_docs": 2, "domains": "MassiveDS"}'

Example output of a multi-query request:

{
  "message": "Search completed for '['Where was Marie Curie born?', 'What is the capital of France?', 'Who invented the telephone?']' from MassiveDS",
  "n_docs": 2,
  "query": [
    "Where was Marie Curie born?",
    "What is the capital of France?",
    "Who invented the telephone?"
  ],
  "results": {
    "n_docs": 2,
    "query": [
      "Where was Marie Curie born?",
      "What is the capital of France?",
      "Who invented the telephone?"
    ],
    "results": {
      "IDs": [
        [
          [3, 3893807],
          [17, 11728753]
        ],
        [
          [14, 12939685],
          [22, 1070951]
        ],
        [
          [28, 18823956],
          [22, 10406782]
        ]
      ],
      "passages": [
        [
          "Marie Skłodowska Curie (November 7, 1867 – July 4, 1934) was a physicist and chemist of Polish upbringing and, subsequently, French citizenship. ...",
          "=> Maria Skłodowska, better known as Marie Curie, was born on 7 November in Warsaw, Poland. ..."
        ],
        [
          "Paris is the capital and most populous city in France, as well as the administrative capital of the region of Île-de-France. ...",
          "[paʁi] ( listen)) is the capital and largest city of France. ..."
        ],
        [
          "Antonio Meucci (Florence, April 13, 1808 – October 18, 1889) was an Italian inventor. ...",
          "The telephone or phone is a telecommunications device that transmits speech by means of electric signals. ..."
        ]
      ],
      "scores": [
        [
          1.8422218561172485,
          1.8394594192504883
        ],
        [
          1.5528039932250977,
          1.5502511262893677
        ],
        [
          1.714379906654358,
          1.706493854522705
        ]
      ]
    }
  }
}

Massive Serve Developer Guide

Environment Setup

Using Conda (Recommended for GPU support)

  1. Create a new conda environment:
git clone https://github.com/RulinShao/massive-serve.git
cd massive-serve
conda env create -f conda-env.yml
conda activate massive-serve

To update the existing environment:

conda env update -n massive-serve -f conda-env.yml

Upload new index

python cli.py upload-data

Test serving the index:

python cli.py dpr-wiki

Project Structure

  • src/indicies/: Contains different index implementations
    • ivf_flat.py: IVF-Flat index implementation
    • base.py: Base indexer class
    • Other index implementations

Usage

The system supports multiple types of indices:

  • Flat index
  • IVF-Flat index
  • IVF-PQ index

Example usage:

from src.indicies.base import Indexer

# Initialize the indexer with your configuration
indexer = Indexer(cfg)

# Search for similar passages
scores, passages, db_ids = indexer.search(query_embeddings, k=5)

Requirements

  • Python 3.8+
  • CUDA support (optional, for GPU acceleration)
  • See requirements.txt for full list of dependencies

License

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

massive_serve-0.1.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

massive_serve-0.1.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file massive_serve-0.1.0.tar.gz.

File metadata

  • Download URL: massive_serve-0.1.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for massive_serve-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f6e206b8f1ac3d92fbdd08d4c4a2215ceb11250b2661e39599951c53e2940297
MD5 e4e42ceb43ba216ca75c602a8eef0322
BLAKE2b-256 1ef0e20e524e180556196811b1744350061e75663b75e53f5f545c0fbc45246b

See more details on using hashes here.

File details

Details for the file massive_serve-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: massive_serve-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for massive_serve-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 181ea0317a203913a9a8be0b54c0984ea034b4afff60c969b0b9b993c4c51432
MD5 387f7caf7bb9cba3d47f38356cb43df3
BLAKE2b-256 2c978b60a9105fa1be9b87f8cca54a8940db7161751faaca4760ee6f1ca60754

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page