Views
No views yet
pip install infinity_emb[all]device="cuda", engine="torch" with flash attention on gpu, and device="cpu", engine="optimum" for onnx inference.1import asyncio
2from infinity_emb import AsyncEmbeddingEngine, EngineArgs
3
4sentences = ["Embed this is sentence via Infinity.", "Paris is in France."]
5engine = AsyncEmbeddingEngine.from_args(
6 EngineArgs(
7 model_name_or_path = "michaelfeil/bge-small-en-v1.5",
8 device="cuda",
9 # or device="cpu"
10 engine="torch",
11 # or engine="optimum"
12 compile=True # enable torch.compile
13))
14
15async def main():
16 async with engine:
17 embeddings, usage = await engine.embed(sentences=sentences)
18asyncio.run(main())1pip install infinity_emb
2infinity_emb --model-name-or-path michaelfeil/bge-small-en-v1.5 --port 7997@software{Feil_Infinity_2023,
author = {Feil, Michael},
month = oct,
title = {{Infinity - To Embeddings and Beyond}},
url = {https://github.com/michaelfeil/infinity},
year = {2023}
}