Skip to main content

Embed anything at lightning speed

Project description

Downloads Open in Colab license package discord

Generate and stream your embeddings with minimalist and lightning fast framework built in rust 🦀
Explore the docs »

View Demo · Examples · Vector Streaming Adapters . Search in Audio Space

EmbedAnything is a minimalist yet highly performant, lightweight, lightening fast, multisource, multimodal and local embedding pipeline, built in rust. Whether you're working with text, images, audio, PDFs, websites, or other media, EmbedAnything simplifies the process of generating embeddings from various sources and streaming them to a vector database.

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

  • Local Embedding : Works with local embedding models like BERT and JINA
  • Cloud Embedding Models:: Supports OpenAI. Mistral and Cohere Support coming soon.
  • 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
  • Candle : We have taken care of hardware acceleration as well, with Candle.
  • Python Interface: Packaged as a Python library for seamless integration into your existing projects.
  • Scalable: Store embeddings in a vector database for easy retrieval and scalability.
  • Vector Streaming: Continuously create and stream embeddings if you have low resource.

💡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 file by file (Or chunk by chunk in future) and store them in the vector database of your choice, Thus it eliminates bulk embeddings storage on RAM at once.

EmbedAnythingXWeaviate

🦀 Why Embed Anything

➡️Faster execution.
➡️Memory Management: Rust enforces memory management simultaneously, preventing memory leaks and crashes that can plague other languages
➡️True multithreading
➡️Running language models or embedding models locally and efficiently
➡️Candle allows inferences on CUDA-enabled GPUs right out of the box.
➡️Decrease the memory usage of EmbedAnything.

⭐ Supported Models

We support a range of models, that can be supported by Candle, We have given a set of tested models but if you have specific usecase do mention it in the issue.

How to add custom model and Chunk Size.

model = EmbeddingModel.from_pretrained_hf(
    WhichModel.Bert, model_id="model link from huggingface"
)
config = TextEmbedConfig(chunk_size=200, batch_size=32)
data = embed_anything.embed_file("file_address", embeder=model, config=config)
Model Custom link
Jina jinaai/jina-embeddings-v2-base-en
jinaai/jina-embeddings-v2-small-en
Bert sentence-transformers/all-MiniLM-L6-v2
sentence-transformers/all-MiniLM-L12-v2
sentence-transformers/paraphrase-MiniLM-L6-v2
Clip openai/clip-vit-base-patch32
Whisper Most OpenAI Whisper from huggingface supported.

🧑‍🚀 Getting Started

💚 Installation

pip install embed-anything

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", embeder=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_directory("test_files", embeder=model)
embeddings = np.array([data.embedding for data in data])
query = ["Photo of a monkey?"]
query_embedding = np.array(
    embed_anything.embed_query(query, embeder=model)[0].embedding
)
similarities = np.dot(embeddings, query_embedding)
max_index = np.argmax(similarities)
Image.open(data[max_index].text).show()

Audio Embedding using Whisper

requirements: Audio .wav files.

import embed_anything
from embed_anything import (
    AudioDecoderModel,
    EmbeddingModel,
    embed_audio_file,
    TextEmbedConfig,
)
# choose any whisper or distilwhisper model from https://huggingface.co/distil-whisper or https://huggingface.co/collections/openai/whisper-release-6501bba2cf999715fd953013
audio_decoder = AudioDecoderModel.from_pretrained_hf(
    "openai/whisper-tiny.en", revision="main", model_type="tiny-en", quantized=False
)
embeder = EmbeddingModel.from_pretrained_hf(
    embed_anything.WhichModel.Bert,
    model_id="sentence-transformers/all-MiniLM-L6-v2",
    revision="main",
)
config = TextEmbedConfig(chunk_size=200, batch_size=32)
data = embed_anything.embed_audio_file(
    "test_files/audio/samples_hp0.wav",
    audio_decoder=audio_decoder,
    embeder=embeder,
    text_embed_config=config,
)
print(data[0].metadata)

➡️ Usage For 0.2

To use local embedding: we support Bert and Jina

import embed_anything
data = embed_anything.embed_file("file_path.pdf", embeder= "Bert")
embeddings = np.array([data.embedding for data in data])

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
data = embed_anything.embed_directory("directory_path", embeder= "Clip")
embeddings = np.array([data.embedding for data in data])

query = ["photo of a dog"]
query_embedding = np.array(embed_anything.embed_query(query, embeder= "Clip")[0].embedding)
similarities = np.dot(embeddings, query_embedding)
max_index = np.argmax(similarities)
Image.open(data[max_index].text).show()

Audio Embedding using Whisper

requirements: Audio .wav files.

import embed_anything
from embed_anything import JinaConfig, EmbedConfig, AudioDecoderConfig
import time

start_time = time.time()

# choose any whisper or distilwhisper model from https://huggingface.co/distil-whisper or https://huggingface.co/collections/openai/whisper-release-6501bba2cf999715fd953013
audio_decoder_config = AudioDecoderConfig(
    decoder_model_id="openai/whisper-tiny.en",
    decoder_revision="main",
    model_type="tiny-en",
    quantized=False,
)
jina_config = JinaConfig(
    model_id="jinaai/jina-embeddings-v2-small-en", revision="main", chunk_size=100
)

config = EmbedConfig(jina=jina_config, audio_decoder=audio_decoder_config)
data = embed_anything.embed_file(
    "test_files/audio/samples_hp0.wav", embeder="Audio", config=config
)
print(data[0].metadata)
end_time = time.time()
print("Time taken: ", end_time - start_time)

🚧 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

    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.
    ✅ Markdown, PDFs, and Website
    ✅ WAV File
    ✅ JPG, PNG, webp
    ✅Add whisper for audio embeddings
    ✅Custom model upload, anything that is available in candle
    ✅Custom chunk size
    ✅Pinecone Adapter, to directly save it on it.
    ✅Zero-shot application
    ✅Vector database integration via streaming adapters
    ✅Refactoring for intuitive functions

    Yet to do be done
    ☑️Introducing chunkwise streaming instead of file
    ☑️Graph embedding -- build deepwalks embeddings depth first and word to vec
    ☑️Video Embedding ☑️ Yolo Clip ☑️ Add more Vector Database Adapters

    Project details


    Download files

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

    Source Distribution

    embed_anything_gpu-0.4.4.tar.gz (919.9 kB view details)

    Uploaded Source

    Built Distributions

    embed_anything_gpu-0.4.4-cp312-none-win_amd64.whl (9.8 MB view details)

    Uploaded CPython 3.12 Windows x86-64

    embed_anything_gpu-0.4.4-cp312-cp312-manylinux_2_34_x86_64.whl (13.6 MB view details)

    Uploaded CPython 3.12 manylinux: glibc 2.34+ x86-64

    embed_anything_gpu-0.4.4-cp311-none-win_amd64.whl (9.8 MB view details)

    Uploaded CPython 3.11 Windows x86-64

    embed_anything_gpu-0.4.4-cp311-cp311-manylinux_2_34_x86_64.whl (13.6 MB view details)

    Uploaded CPython 3.11 manylinux: glibc 2.34+ x86-64

    embed_anything_gpu-0.4.4-cp310-none-win_amd64.whl (9.8 MB view details)

    Uploaded CPython 3.10 Windows x86-64

    embed_anything_gpu-0.4.4-cp310-cp310-manylinux_2_34_x86_64.whl (13.6 MB view details)

    Uploaded CPython 3.10 manylinux: glibc 2.34+ x86-64

    embed_anything_gpu-0.4.4-cp39-none-win_amd64.whl (9.8 MB view details)

    Uploaded CPython 3.9 Windows x86-64

    embed_anything_gpu-0.4.4-cp39-cp39-manylinux_2_34_x86_64.whl (13.6 MB view details)

    Uploaded CPython 3.9 manylinux: glibc 2.34+ x86-64

    embed_anything_gpu-0.4.4-cp38-none-win_amd64.whl (9.8 MB view details)

    Uploaded CPython 3.8 Windows x86-64

    File details

    Details for the file embed_anything_gpu-0.4.4.tar.gz.

    File metadata

    • Download URL: embed_anything_gpu-0.4.4.tar.gz
    • Upload date:
    • Size: 919.9 kB
    • Tags: Source
    • Uploaded using Trusted Publishing? No
    • Uploaded via: maturin/1.7.1

    File hashes

    Hashes for embed_anything_gpu-0.4.4.tar.gz
    Algorithm Hash digest
    SHA256 75e271917dcfaca0533a80c1867525d33a9fd0c7192f5ace87ac44b8a54d05d9
    MD5 775546de392504b7ec0aae619145d4bf
    BLAKE2b-256 a4d5d00855f8fa519d94f81b962b2224aa87d06b70d1912113672b6153e53002

    See more details on using hashes here.

    File details

    Details for the file embed_anything_gpu-0.4.4-cp312-none-win_amd64.whl.

    File metadata

    File hashes

    Hashes for embed_anything_gpu-0.4.4-cp312-none-win_amd64.whl
    Algorithm Hash digest
    SHA256 017f4fbb8184f8b9b5ce0c07a8ba5c98e4419e191c6c38b585fd3b4912795284
    MD5 ed4d2206309c29b1b5a308145adb6711
    BLAKE2b-256 890e7deac2f3616f7c47641344ad0a6f38ea8a69b09c07bf2dea79d458401a78

    See more details on using hashes here.

    File details

    Details for the file embed_anything_gpu-0.4.4-cp312-cp312-manylinux_2_34_x86_64.whl.

    File metadata

    File hashes

    Hashes for embed_anything_gpu-0.4.4-cp312-cp312-manylinux_2_34_x86_64.whl
    Algorithm Hash digest
    SHA256 2315f7b7b2fa983aca8dcff720af2d93b76edc482d22d75385ba4a870aa87e0a
    MD5 b76d89680a57b048b4bf138b97be5219
    BLAKE2b-256 e4b4f25c665748e65e467b0fc0a493e3e4e8f7c15b3edf8db3c76eecafd8d356

    See more details on using hashes here.

    File details

    Details for the file embed_anything_gpu-0.4.4-cp311-none-win_amd64.whl.

    File metadata

    File hashes

    Hashes for embed_anything_gpu-0.4.4-cp311-none-win_amd64.whl
    Algorithm Hash digest
    SHA256 313991c69b05d7bd796f8e5cb0f3357d0d83a79a88170745419cc5b7f4e9058a
    MD5 d713134b62714af0dd558cc2fa5302f9
    BLAKE2b-256 af2c5bcf31f53a7f7a6497c11e29f372da8e97049695b831e5d87d8cd5e0bebe

    See more details on using hashes here.

    File details

    Details for the file embed_anything_gpu-0.4.4-cp311-cp311-manylinux_2_34_x86_64.whl.

    File metadata

    File hashes

    Hashes for embed_anything_gpu-0.4.4-cp311-cp311-manylinux_2_34_x86_64.whl
    Algorithm Hash digest
    SHA256 30d8248b07d1ee0ac5f079c3a9586092911bad6ece8b6653391c6595649f1df3
    MD5 7810e26326d695e72cfe142e51c0f7b0
    BLAKE2b-256 3c05792607b5268ff6220df6d018ff56efcf4d22c846f7570542028494e6eef8

    See more details on using hashes here.

    File details

    Details for the file embed_anything_gpu-0.4.4-cp310-none-win_amd64.whl.

    File metadata

    File hashes

    Hashes for embed_anything_gpu-0.4.4-cp310-none-win_amd64.whl
    Algorithm Hash digest
    SHA256 28724dc3389aa877290acbc820896be9c20cb43401509f8ea5222cc33de75dcf
    MD5 af2c3924e58eda8f88e56d4673fe80f4
    BLAKE2b-256 891affbddd6dd70acc2484f79b2e928bf5ac5a382edc2179c2363ddd9232b3ab

    See more details on using hashes here.

    File details

    Details for the file embed_anything_gpu-0.4.4-cp310-cp310-manylinux_2_34_x86_64.whl.

    File metadata

    File hashes

    Hashes for embed_anything_gpu-0.4.4-cp310-cp310-manylinux_2_34_x86_64.whl
    Algorithm Hash digest
    SHA256 75e94afb35252ba9939ec84239a135593c5d1e7ef761dcd2a2861c98b41b472e
    MD5 2455febff644fb4aff711c1356065c27
    BLAKE2b-256 0d8e69d3157b230e42162a7482a4c467e8102e037266e0fd9c9587970b496281

    See more details on using hashes here.

    File details

    Details for the file embed_anything_gpu-0.4.4-cp39-none-win_amd64.whl.

    File metadata

    File hashes

    Hashes for embed_anything_gpu-0.4.4-cp39-none-win_amd64.whl
    Algorithm Hash digest
    SHA256 59504956bebeb15c9aeef6c0331a57e27447f5515f5139542daa35c5b38694e4
    MD5 291a8040435bad14a91fded3594e924d
    BLAKE2b-256 8c0e7a6b540fd8fc188534a2f6c604324ddb2973d3a8a5ce1a25942e98901300

    See more details on using hashes here.

    File details

    Details for the file embed_anything_gpu-0.4.4-cp39-cp39-manylinux_2_34_x86_64.whl.

    File metadata

    File hashes

    Hashes for embed_anything_gpu-0.4.4-cp39-cp39-manylinux_2_34_x86_64.whl
    Algorithm Hash digest
    SHA256 a03326f56eca644484653946028efa554453ff3684b6c1abd9a69f4bb1a316ed
    MD5 3161ee5af700b0fbb303caefccbacf8a
    BLAKE2b-256 3e80e8fdb87c9402692543335991b78f077b9964d27be40cb832de92db4c8374

    See more details on using hashes here.

    File details

    Details for the file embed_anything_gpu-0.4.4-cp38-none-win_amd64.whl.

    File metadata

    File hashes

    Hashes for embed_anything_gpu-0.4.4-cp38-none-win_amd64.whl
    Algorithm Hash digest
    SHA256 80f34fb3555a332f537827347cfb49e3b70875c6c1b99462b128c92a3ed85d2a
    MD5 c0554e64698184023b608a6ec3c6a79d
    BLAKE2b-256 e2cc1d15166131048251045d1ac5a17c132ad416fa2d829f419f75001b61590a

    See more details on using hashes here.

    Supported by

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