Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfeil committed Dec 18, 2024
1 parent 1b98bf9 commit 36c7a4c
Show file tree
Hide file tree
Showing 8 changed files with 418 additions and 497 deletions.
6 changes: 4 additions & 2 deletions docs/docs/contribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ cd libs/infinity_emb
poetry install --extras all --with test
```

To ensure your contributions pass the Continuous Integration (CI) checks:
To ensure your contributions pass the Continuous Integration (CI) checks. The `libs/infinity_emb/Makefile` is a useful entrypoint for this.
```bash
cd libs/infinity_emb
make format
make lint
poetry run pytest ./tests
```
As an alternative, you can also use the following command:

As an alternative, you can also use the following command, which bundles a range of the above.
```bash
cd libs/infinity_emb
make precommit
```

## CLA
Infinity is developed as open source project.
All contributions must be made in a way to be compatible with the MIT License of this repo.
108 changes: 0 additions & 108 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
@@ -1,108 +0,0 @@
# [Infinity](https://github.com/michaelfeil/infinity)

Infinity is a high-throughput, low-latency REST API for serving vector embeddings, supporting all sentence-transformer models and frameworks. Infinity is developed under [MIT License](https://github.com/michaelfeil/infinity/blob/main/LICENSE). Infinity powers inference behind [Gradient.ai](https://gradient.ai) and other Embedding API providers.

## Why Infinity

Infinity provides the following features:

* **Deploy any model from MTEB**: deploy the model you know from [SentenceTransformers](https://github.com/UKPLab/sentence-transformers/)
* **Fast inference backends**: The inference server is built on top of [torch](https://github.com/pytorch/pytorch), [optimum(onnx/tensorrt)](https://huggingface.co/docs/optimum/index) and [CTranslate2](https://github.com/OpenNMT/CTranslate2), using FlashAttention to get the most out of **CUDA**, **ROCM**, **CPU** or **MPS** device.
* **Dynamic batching**: New embedding requests are queued while GPU is busy with the previous ones. New requests are squeezed intro your device as soon as ready. Similar max throughput on GPU as text-embeddings-inference.
* **Correct and tested implementation**: Unit and end-to-end tested. Embeddings via infinity are identical to [SentenceTransformers](https://github.com/UKPLab/sentence-transformers/) (up to numerical precision). Lets API users create embeddings till infinity and beyond.
* **Easy to use**: The API is built on top of [FastAPI](https://fastapi.tiangolo.com/), [Swagger](https://swagger.io/) makes it fully documented. API are aligned to [OpenAI's Embedding specs](https://platform.openai.com/docs/guides/embeddings/what-are-embeddings). See below on how to get started.

## Getting started

Install `infinity_emb` via pip
```bash
pip install infinity-emb[all]
```

<details>
<summary>Install from source with Poetry</summary>

Advanced:
To install via Poetry use Poetry 1.8.4, Python 3.11 on Ubuntu 22.04
```bash
git clone https://github.com/michaelfeil/infinity
cd infinity
cd libs/infinity_emb
poetry install --extras all
```
</details>

### Launch the CLI using a pre-built docker container (recommended)

```bash
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 $port
```
The cache path inside the docker container is set by the environment variable `HF_HOME`.

### or launch the cli after the pip install
After your pip install, with your venv activate, you can run the CLI directly.
Check the `--help` command to get a description for all parameters.

```bash
infinity_emb --help
```

## Launch FAQ
<details>
<summary>What are embedding models?</summary>
Embedding models can map any text to a low-dimensional dense vector which can be used for tasks like retrieval, classification, clustering, or semantic search.
And it also can be used in vector databases for LLMs.


The most know architecture are encoder-only transformers such as BERT, and most popular implementation include [SentenceTransformers](https://github.com/UKPLab/sentence-transformers/).
</details>

<details>
<summary>What models are supported?</summary>

All models of the sentence transformers org are supported https://huggingface.co/sentence-transformers / sbert.net.
LLM's like LLAMA2-7B are not intended for deployment.


With the command `--engine torch` the model must be compatible with https://github.com/UKPLab/sentence-transformers/.
- only models from Huggingface are supported.


With the command `--engine ctranslate2`
- only `BERT` models are supported.
- only models from Huggingface are supported.


For the latest trends, you might want to check out one of the following models.
https://huggingface.co/spaces/mteb/leaderboard

</details>


<details>
<summary>Using Langchain with Infinity</summary>
Now available under # Python Integrations in the side panel.
```
</details>
<details>
<summary>Question not answered here?</summary>
There is a Discussion section on the Github of Infinity:
https://github.com/michaelfeil/infinity/discussions
</details>
2 changes: 1 addition & 1 deletion libs/embed_package/embed/_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Collection, Literal, Union

from infinity_emb import EngineArgs, SyncEngineArray # type: ignore
from infinity_emb.infinity_server import AutoPadding
from infinity_emb.cli import AutoPadding

__all__ = ["BatchedInference"]

Expand Down
Loading

0 comments on commit 36c7a4c

Please sign in to comment.