Infinity is a high-throughput, low-latency serving engine for text-embeddings, reranking models, clip, clap and colpali
Infinity is a high-throughput, low-latency serving engine for text-embeddings, reranking models, clip, clap and colpali
[![Contributors][contributors-shield]][contributors-url] [![Forks][forks-shield]][forks-url] [![Stargazers][stars-shield]][stars-url] [![Issues][issues-shield]][issues-url] [![MIT License][license-shield]][license-url]
[![codecov][codecov-shield]][codecov-url] [![ci][ci-shield]][ci-url] [![Downloads][pepa-shield]][pepa-url]
Infinity is a high-throughput, low-latency REST API for serving text-embeddings, reranking models, clip, clap and colpali. Infinity is developed under MIT License.
pip install infinity_clientv2 cli, including --api-keypip install infinity-emb[all]After your pip install, with your venv active, you can run the CLI directly.
infinity_emb v2 --model-id BAAI/bge-small-en-v1.5Check the v2 --help command to get a description for all parameters.
infinity_emb v2 --helpInstead of installing the CLI via pip, you may also use docker to run michaelf34/infinity.
Make sure you mount your accelerator ( i.e. install nvidia-docker and activate with --gpus all).
port=7997
model1=michaelfeil/bge-small-en-v1.5
model2=mixedbread-ai/mxbai-rerank-xsmall-v1
volume=$PWD/data
docker run -it --gpus all \
-v $volume:/app/.cache \
-p $port:$port \
michaelf34/infinity:latest \
v2 \
--model-id $model1 \
--model-id $model2 \
--port $portThe cache path inside the docker container is set by the environment variable HF_HOME.
docker run -it \
-v $volume:/app/.cache \
-p $port:$port \
michaelf34/infinity:latest-cpu \
v2 \
--engine optimum \
--model-id $model1 \
--model-id $model2 \
--port $portVisit Docs for more info.
Docker Container for Onnx-GPU, Cuda Extensions, TensorRT Use the `latest-trt-onnx` image or `x.x.x-trt-onnx` for nvidia compatible inference. **This image is currently not build via CI/CD (to large), consider pinning to exact version.**This image has support for:
pip install flash-attn package when using Pytorch.docker run -it \
-v $volume:/app/.cache \
-p $port:$port \
michaelf34/infinity:latest-trt-onnx \
v2 \
--engine optimum \
--device cuda \
--model-id $model1 \
--port $portIn order to deploy a local model with a docker container, you need to mount the model inside the container and specify the path in the container to the launch command.
Example:
git lfs install
cd /tmp
mkdir models && cd models && git clone https://huggingface.co/BAAI/bge-small-en-v1.5
docker run -it -v /tmp/models:/models -p 8081:8081 michaelf34/infinity:latest v2 --model-id "/models/bge-small-en-v1.5" --port 8081 Since infinity_emb>=0.0.34, you can use cli v2 method to launch multiple models at the same time.
Checkout infinity_emb v2 --help for all args and validation.
Multiple Model CLI Playbook:
v2 --model-id model/id1 --model-id model/id2 --batch-size 8 --batch-size 4. This will create two models model/id1 and model/id2;: INFINITY_MODEL_ID="model/id1;model/id2;" && INFINITY_BATCH_SIZE="8;4;"--model-id length, v2 --model-id model/id1 --model-id/id2 --batch-size 8 making both models have batch-size 8.--model-id + API requests are routed to the --served-model-name/--model-id Environment variables start with INFINITY_{UPPER_CASE_SNAKE_CASE} and often match the --{lower-case-kebab-case} cli arguments.
The following two are equivalent:
infinity_emb v2 --model-id BAAI/bge-base-en-v1.5export INFINITY_MODEL_ID="BAAI/bge-base-en-v1.5" && infinity_emb v2 Multiple arguments can be used via ; syntax: INFINITY_MODEL_ID="model/id1;model/id2;"
With the command --engine torch the model must be compatible with https://github.com/UKPLab/sentence-transformers/ and AutoModel
With the command --engine optimum, there must be an onnx file. Models from https://huggingface.co/Xenova are recommended.
With the command --engine ctranslate2
- only BERT models are supported.
See which telemetry is collected: https://michaelfeil.eu/infinity/main/telemetry/
# Disable
export INFINITY_ANONYMOUS_USAGE_STATS="0"Infinity aims to be the inference server supporting most functionality for embeddings, reranking and related RAG tasks. The following Infinity tests 15+ architectures and all of the below cases in the Github CI. Click on the sections below to find tasks and validated example models.
Text EmbeddingsText embeddings measure the relatedness of text strings. Embeddings are used for search, clustering, recommendations. Think about a private deployed version of openai's text embeddings. https://platform.openai.com/docs/guides/embeddings
Tested embedding models:
Other models:
No open issues yet, or sync has not completed.