A package for massive serving
Project description
Massive Serve User Guide
A scalable search and retrieval system using FAISS indices.
If you find our package helpful, please cite:
@article{shao2024scaling,
title={Scaling retrieval-based language models with a trillion-token datastore},
author={Shao, Rulin and He, Jacqueline and Asai, Akari and Shi, Weijia and Dettmers, Tim and Min, Sewon and Zettlemoyer, Luke and Koh, Pang Wei W},
journal={Advances in Neural Information Processing Systems},
volume={37},
pages={91260--91299},
year={2024}
}
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)
- 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 -m massive_serve.cli upload_data --domain_name demo
Test serving the index:
python -m massive_serve.cli serve --domain_name demo
Update package
Make sure the version in the setup.py has been updated to a different version. Then run:
rm -rf dist/ build/ massive_serve.egg-info/
pip install build twine
python -m build
python -m twine upload dist/*
Users can refresh their installed repo via:
pip install --upgrade massive-serve
Project Structure
src/indicies/: Contains different index implementationsivf_flat.py: IVF-Flat index implementationbase.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file massive_serve-0.1.2.tar.gz.
File metadata
- Download URL: massive_serve-0.1.2.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9d001e79fb1b79fb8f4d258131ca91d8d6d367ce15ee0437feccbe25e93e4b0
|
|
| MD5 |
70d25ab6dc185fdd316a11a345fe92dd
|
|
| BLAKE2b-256 |
9dc23aef085ee6d05efbc55824581fd3e83f4506d6edaba33151a6383253df1c
|
File details
Details for the file massive_serve-0.1.2-py3-none-any.whl.
File metadata
- Download URL: massive_serve-0.1.2-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e480e60713f629a42fe1a2550fe6f0461f5f4d1a9480eda7b000f11b779237e
|
|
| MD5 |
44182916f8b811bd023114197b857ec8
|
|
| BLAKE2b-256 |
7b2b1fb5f84baeef15eaac902214f275871599cde1baf58267c5be1b8f4940d1
|