Skip to main content

Embed anything at lightning speed

Project description

Downloads gpu Open in Colab roadmap MkDocs

Inference, Ingestion, and Indexing in Rust 🦀
Python docs »
Rust docs »
Benchmarks · FAQ · Adapters . Collaborations

EmbedAnything is a minimalist, yet highly performant, lightning-fast, lightweight, multisource, multimodal, and local embedding pipeline built in Rust. Whether you're working with text, images, audio, PDFs, websites, or other media, EmbedAnything streamlines the process of generating embeddings from various sources and seamlessly streaming (memory-efficient-indexing) them to a vector database. It supports dense, sparse, ONNX, model2vec and late-interaction embeddings, offering flexibility for a wide range of use cases.

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. How to add custom model and chunk size

🚀 Key Features

  • Candle Backend : Supports BERT, Jina, ColPali, Splade, ModernBERT
  • ONNX Backend: Supports BERT, Jina, ColPali, ColBERT Splade, Reranker, ModernBERT
  • Cloud Embedding Models:: Supports OpenAI and Cohere.
  • MultiModality : Works with text sources like PDFs, txt, md, Images JPG and Audio, .WAV
  • Rust : All the file processing is done in rust for speed and efficiency
  • GPU support : We have taken care of hardware acceleration on GPU as well.
  • Python Interface: Packaged as a Python library for seamless integration into your existing projects.
  • Vector Streaming: Continuously create and stream embeddings if you have low resource.
  • No Dependency on Pytorch Easy to deploy on cloud, as it comes with low memory footprint.

💡What is Vector Streaming

Vector Streaming enables you to process and generate embeddings for files and stream them, so if you have 10 GB of file, it can continuously generate embeddings Chunk by Chunk, that you can segment semantically, and store them in the vector database of your choice, Thus it eliminates bulk embeddings storage on RAM at once.

The embedding process happens separetly from the main process, so as to maintain high performance enabled by rust MPSC, and no memory leak as embeddings are directly saved to vector database. Find our blog.

EmbedAnythingXWeaviate

🦀 Why Embed Anything

➡️Faster execution.
➡️No Pytorch Dependency, thus low-memory footprint and easy to deploy on cloud.
➡️Memory Management: Rust enforces memory management simultaneously, preventing memory leaks and crashes that can plague other languages
➡️True multithreading
➡️Running embedding models locally and efficiently
➡️Candle allows inferences on CUDA-enabled GPUs right out of the box.
➡️Decrease the memory usage.
➡️Supports range of models, Dense, Sparse, Late-interaction, ReRanker, ModernBert.

🍓 Our Past Collaborations:

We have collaborated with reputed enterprise like Elastic, Weaviate, SingleStore Milvus and Analytics Vidya Datahours

You can get in touch with us for further collaborations.

Benchmarks

Only measures embedding model inference speed, on onnx-runtime. Code

⭐ Supported Models

We support any hugging-face models on Candle. And We also support ONNX runtime for BERT and ColPali.

How to add custom model on candle: from_pretrained_hf

model = EmbeddingModel.from_pretrained_hf(
    WhichModel.Bert, model_id="model link from huggingface"
)
config = TextEmbedConfig(chunk_size=1000, batch_size=32)
data = embed_anything.embed_file("file_address", embedder=model, config=config)
Model HF link
Jina Jina Models
Bert All Bert based models
CLIP openai/clip-*
Whisper OpenAI Whisper models
ColPali starlight-ai/colpali-v1.2-merged-onnx
Colbert answerdotai/answerai-colbert-small-v1, jinaai/jina-colbert-v2 and more
Splade Splade Models and other Splade like models
Reranker Jina Reranker Models, Xenova/bge-reranker
Model2Vec model2vec, minishlab/potion-base-8M
Qwen3-Embedding Qwen/Qwen3-Embedding-0.6B

Splade Models:

model = EmbeddingModel.from_pretrained_hf(
    WhichModel.SparseBert, "prithivida/Splade_PP_en_v1"
)

ONNX-Runtime: from_pretrained_onnx

BERT

model = EmbeddingModel.from_pretrained_onnx(
  WhichModel.Bert, model_id="onnx_model_link"
)

ColPali

model: ColpaliModel = ColpaliModel.from_pretrained_onnx("starlight-ai/colpali-v1.2-merged-onnx", None)

Colbert

sentences = [
"The quick brown fox jumps over the lazy dog", 
"The cat is sleeping on the mat", "The dog is barking at the moon", 
"I love pizza", 
"The dog is sitting in the park"]

model = ColbertModel.from_pretrained_onnx("jinaai/jina-colbert-v2", path_in_repo="onnx/model.onnx")
embeddings = model.embed(sentences, batch_size=2)

ModernBERT

model = EmbeddingModel.from_pretrained_onnx(
    WhichModel.Bert, ONNXModel.ModernBERTBase, dtype = Dtype.Q4F16
)

ReRankers

reranker = Reranker.from_pretrained("jinaai/jina-reranker-v1-turbo-en", dtype=Dtype.F16)

results: list[RerankerResult] = reranker.rerank(["What is the capital of France?"], ["France is a country in Europe.", "Paris is the capital of France."], 2)

Embed 4

# Initialize the model once
model: EmbeddingModel = EmbeddingModel.from_pretrained_cloud(
    WhichModel.CohereVision, model_id="embed-v4.0"
)

Qwen 3 - Embedding

# Initialize the model once
model:EmbeddingModel = EmbeddingModel.from_pretrained_hf(
    WhichModel.Qwen3, model_id="Qwen/Qwen3-Embedding-0.6B"
)

For Semantic Chunking

model = EmbeddingModel.from_pretrained_hf(
    WhichModel.Bert, model_id="sentence-transformers/all-MiniLM-L12-v2"
)

# with semantic encoder
semantic_encoder = EmbeddingModel.from_pretrained_hf(WhichModel.Jina, model_id = "jinaai/jina-embeddings-v2-small-en")
config = TextEmbedConfig(chunk_size=1000, batch_size=32, splitting_strategy = "semantic", semantic_encoder=semantic_encoder)

For late-chunking

config = TextEmbedConfig(
    chunk_size=1000,
    batch_size=8,
    splitting_strategy="sentence",
    late_chunking=True,
)

# Embed a single file
data: list[EmbedData] = model.embed_file("test_files/attention.pdf", config=config)

🧑‍🚀 Getting Started

💚 Installation

pip install embed-anything

For GPUs and using special models like ColPali

pip install embed-anything-gpu

🚧❌ If it shows cuda error while running on windowns, run the following command:

os.add_dll_directory("C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6/bin")

Usage

➡️ Usage For 0.3 and later version

To use local embedding: we support Bert and Jina

model = EmbeddingModel.from_pretrained_local(
    WhichModel.Bert, model_id="Hugging_face_link"
)
data = embed_anything.embed_file("test_files/test.pdf", embedder=model)

For multimodal embedding: we support CLIP

Requirements Directory with pictures you want to search for example we have test_files with images of cat, dogs etc

import embed_anything
from embed_anything import EmbedData
model = embed_anything.EmbeddingModel.from_pretrained_local(
    embed_anything.WhichModel.Clip,
    model_id="openai/clip-vit-base-patch16",
    # revision="refs/pr/15",
)
data: list[EmbedData] = embed_anything.embed_image_directory("test_files", embedder=model)
embeddings = np.array([data.embedding for data in data])
query = ["Photo of a monkey?"]
query_embedding = np.array(
    embed_anything.embed_query(query, embedder=model)[0].embedding
)
similarities = np.dot(embeddings, query_embedding)
max_index = np.argmax(similarities)
Image.open(data[max_index].text).show()

Using ONNX Models

To use ONNX models, you can either use the ONNXModel enum or the model_id from the Hugging Face model.

model = EmbeddingModel.from_pretrained_onnx(
  WhichModel.Bert, model_name = ONNXModel.AllMiniLML6V2Q
)

For some models, you can also specify the dtype to use for the model.

model = EmbeddingModel.from_pretrained_onnx(
    WhichModel.Bert, ONNXModel.ModernBERTBase, dtype = Dtype.Q4F16
)

Using the above method is best to ensure that the model works correctly as these models are tested. But if you want to use other models, like finetuned models, you can use the hf_model_id and path_in_repo to load the model like below.

model = EmbeddingModel.from_pretrained_onnx(
  WhichModel.Jina, hf_model_id = "jinaai/jina-embeddings-v2-small-en", path_in_repo="model.onnx"
)

To see all the ONNX models supported with model_name, see here

⁉️FAQ

Do I need to know rust to use or contribute to embedanything?

The answer is No. EmbedAnything provides you pyo3 bindings, so you can run any function in python without any issues. To contibute you should check out our guidelines and python folder example of adapters.

How is it different from fastembed?

We provide both backends, candle and onnx. On top of it we also give an end-to-end pipeline, that is you can ingest different data-types and index to any vector database, and inference any model. Fastembed is just an onnx-wrapper.

We've received quite a few questions about why we're using Candle.

One of the main reasons is that Candle doesn't require any specific ONNX format models, which means it can work seamlessly with any Hugging Face model. This flexibility has been a key factor for us. However, we also recognize that we’ve been compromising a bit on speed in favor of that flexibility.

🚧 Contributing to EmbedAnything

First of all, thank you for taking the time to contribute to this project. We truly appreciate your contributions, whether it's bug reports, feature suggestions, or pull requests. Your time and effort are highly valued in this project. 🚀

This document provides guidelines and best practices to help you to contribute effectively. These are meant to serve as guidelines, not strict rules. We encourage you to use your best judgment and feel comfortable proposing changes to this document through a pull request.

  • Roadmap
  • Quick Start
  • Guidelines
  • 🏎️ RoadMap

    Accomplishments

    One of the aims of EmbedAnything is to allow AI engineers to easily use state of the art embedding models on typical files and documents. A lot has already been accomplished here and these are the formats that we support right now and a few more have to be done.

    Adding Fine-tuning

    One of the major goals of this year is to add finetuning these models on your data. Like a simple sentence transformer does.

    🖼️ Modalities and Source

    We’re excited to share that we've expanded our platform to support multiple modalities, including:

    • Audio files

    • Markdowns

    • Websites

    • Images

    • Videos

    • Graph

    This gives you the flexibility to work with various data types all in one place! 🌐

    ⚙️ Performance

    We now support both candle and Onnx backend
    ➡️ Support for GGUF models

    🫐Embeddings:

    We had multimodality from day one for our infrastructure. We have already included it for websites, images and audios but we want to expand it further to.

    ➡️ Graph embedding -- build deepwalks embeddings depth first and word to vec
    ➡️ Video Embedding
    ➡️ Yolo Clip

    🌊Expansion to other Vector Adapters

    We currently support a wide range of vector databases for streaming embeddings, including:

    • Elastic: thanks to amazing and active Elastic team for the contribution
    • Weaviate
    • Pinecone
    • Qdrant
    • Milvus
    • Chroma

    How to add an adpters: https://starlight-search.com/blog/2024/02/25/adapter-development-guide.md

    💥 Create WASM demos to integrate embedanything directly to the browser.

    💜 Add support for ingestion from remote sources

    ➡️ Support for S3 bucket
    ➡️ Support for azure storage
    ➡️ Support for google drive/dropbox

    But we're not stopping there! We're actively working to expand this list.

    Want to Contribute? If you’d like to add support for your favorite vector database, we’d love to have your help! Check out our contribution.md for guidelines, or feel free to reach out directly starlight-search@proton.me. Let's build something amazing together! 💡

    A big Thank you to all our StarGazers

    Star History

    Star History Chart

    Project details


    Download files

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

    Source Distributions

    No source distribution files available for this release.See tutorial on generating distribution archives.

    Built Distributions

    embed_anything_gpu-0.6.4-cp312-cp312-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl (18.5 MB view details)

    Uploaded CPython 3.12manylinux: glibc 2.31+ x86-64manylinux: glibc 2.34+ x86-64

    embed_anything_gpu-0.6.4-cp311-cp311-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl (18.5 MB view details)

    Uploaded CPython 3.11manylinux: glibc 2.31+ x86-64manylinux: glibc 2.34+ x86-64

    embed_anything_gpu-0.6.4-cp310-cp310-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl (18.5 MB view details)

    Uploaded CPython 3.10manylinux: glibc 2.31+ x86-64manylinux: glibc 2.34+ x86-64

    embed_anything_gpu-0.6.4-cp39-cp39-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl (18.5 MB view details)

    Uploaded CPython 3.9manylinux: glibc 2.31+ x86-64manylinux: glibc 2.34+ x86-64

    embed_anything_gpu-0.6.4-cp38-cp38-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl (18.5 MB view details)

    Uploaded CPython 3.8manylinux: glibc 2.31+ x86-64manylinux: glibc 2.34+ x86-64

    File details

    Details for the file embed_anything_gpu-0.6.4-cp312-cp312-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl.

    File metadata

    File hashes

    Hashes for embed_anything_gpu-0.6.4-cp312-cp312-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl
    Algorithm Hash digest
    SHA256 f8931f2c308be1f8560ccc54c7f7eaef80ffcf695756db420d84017491a140bd
    MD5 7b2aaecb9689e939279f1b7f90e86366
    BLAKE2b-256 eafcbf97a1d8f5636974394b1fcccd148cbd289ccb8b004ab2954da0b9bf4b33

    See more details on using hashes here.

    File details

    Details for the file embed_anything_gpu-0.6.4-cp311-cp311-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl.

    File metadata

    File hashes

    Hashes for embed_anything_gpu-0.6.4-cp311-cp311-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl
    Algorithm Hash digest
    SHA256 811ad1b49561a620bdecf847724b23177c99da36442aed01acb33ae7601b4733
    MD5 5c27cf62cabe6a91ba89786693e9d1ad
    BLAKE2b-256 56249db4f48c7d2e1ac1393b7c0e181c3875a567360febf35612a02a1081fec7

    See more details on using hashes here.

    File details

    Details for the file embed_anything_gpu-0.6.4-cp310-cp310-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl.

    File metadata

    File hashes

    Hashes for embed_anything_gpu-0.6.4-cp310-cp310-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl
    Algorithm Hash digest
    SHA256 eaa5ed7da9de467f5519d55d4fbf2b6ac8ab5bd2c78b83259137d259bfb012ef
    MD5 c9d7f3f19f1e43d9c5d08a2f53b3ea7b
    BLAKE2b-256 b0918d514fd1a4faa0c7c9636b62648321fc8963d2c0af4a41bd7c5afafb3fd9

    See more details on using hashes here.

    File details

    Details for the file embed_anything_gpu-0.6.4-cp39-cp39-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl.

    File metadata

    File hashes

    Hashes for embed_anything_gpu-0.6.4-cp39-cp39-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl
    Algorithm Hash digest
    SHA256 dc8c009b87e7fbeef3196a6442bec1a48535920e7e920e9e18d66c5f1321891d
    MD5 17d5e67d5cc88ff800afae807f0d24f5
    BLAKE2b-256 65af8966b69925de831a3b0660368a75f5448d748a4d00c8851553e8aab4df3b

    See more details on using hashes here.

    File details

    Details for the file embed_anything_gpu-0.6.4-cp38-cp38-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl.

    File metadata

    File hashes

    Hashes for embed_anything_gpu-0.6.4-cp38-cp38-manylinux_2_31_x86_64.manylinux_2_34_x86_64.whl
    Algorithm Hash digest
    SHA256 c68f7fafff865e485668c7ae2c5e109f3bec0bf80fde4b7196d4bd94131ff282
    MD5 bd09d8fc0328b825620947b8e7cf26ea
    BLAKE2b-256 a2fdbaccb69a8d5a40e0f4f39e7465e768b279131c20ee02868c805d314ed91e

    See more details on using hashes here.

    Supported by

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