ycastor

ycastor

ExMemVid - Using videos as a search db

A couple weeks ago i saw the MemVid Project, and though, “Hey, this looks fun”, so i decided to implement something similar in Elixir, so here’s ExMemVid

The core idea is to treat video frames as a data storage medium. Each frame in the video contains a QR code that holds a chunk of text. A separate search index is created using text embeddings to allow for fast, semantic searching of the content stored in the video.

ExMemvid is a proof-of-concept library for storing and retrieving large amounts of text data by encoding it into a video file composed of QR code frames. It leverages modern Elixir libraries for machine learning, video processing, and vector search to provide a unique solution for data storage and semantic retrieval.

How it Works

The core idea is to treat video frames as a data storage medium. Each frame in the video contains a QR code that holds a chunk of text. A separate search index is created using text embeddings to allow for fast, semantic searching of the content stored in the video.

Encoding Process

  1. Text Chunking: The input text is divided into smaller, manageable chunks.
  2. Embedding: A sentence transformer model from Hugging Face (via Bumblebee) generates a vector embedding for each text chunk.
  3. QR Code Generation: Each text chunk is serialized (optionally with Gzip compression) and encoded into a QR code image.
  4. Video Encoding: The QR code images are compiled into a video file, where each image becomes a single frame. The library uses Xav and Evision (OpenCV bindings) for this.
  5. Index Creation: The vector embeddings are stored in an HNSWLib (Hierarchical Navigable Small World) index for efficient similarity search. This index maps the embeddings to their corresponding frame numbers in the video.
  6. Saving: The final video file and the search index are saved to disk.

Retrieval Process

  1. Search Query: The user provides a text query.
  2. Query Embedding: The query is converted into a vector embedding using the same model as the encoding process.
  3. Semantic Search: The HNSWLib index is queried to find the text chunks with embeddings most similar to the query’s embedding.
  4. Frame Identification: The search results from the index provide the frame numbers where the relevant text chunks are stored.
  5. Frame Decoding: The Retriever seeks to the specific frames in the video file, reads the QR codes, and decodes them to retrieve the original text chunks.
  6. Result Aggregation: The retrieved text chunks are returned to the user.

Features

  • Data Archiving: Store large text corpora in a compressed video format.
  • Semantic Search: Go beyond keyword matching with state-of-the-art text embeddings.
  • Configurable: Easily configure everything from the video codec and QR code version to the embedding model.
  • Concurrent: Utilizes Elixir’s concurrency to parallelize embedding and frame decoding tasks.
  • Extensible: The Embedding behaviour allows for swapping out the embedding implementation.
  • Supervised: Built-in supervisors for managing encoder and retriever processes.

https://github.com/edlontech/ex_memvid

Most Liked

mickel8

mickel8

Membrane Core Team

Glad to see that Xav was useful!

mat-hek

mat-hek

Membrane Core Team

I’m no expert on LLMs, but from a compression perspective, I don’t see how it can be efficient. Somebody explained it well in an issue, they provided benchmarks too.

urcadox

urcadox

I’m pretty sure it’s just a joke.

The amount of code and the extensive documentation makes it feel like it’s way too much work to put into a joke. But, it’s quite easy to generate this much stuff with an LLM, with… this prompt.

Last Post!

drakkhenn

drakkhenn

Add some steganography and you will get a hit ! :smiley:

Where Next?

Popular in Announcing Top

Hal9000
Here is my first stab at this. README pasted below. https://github.com/Hal9000/elixir_random Comments and critiques are welcome. Thank...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36654 110
New
Crowdhailer
Experimenting with this code. OK.try do user <- fetch_user(1) cart <- fetch_cart(1) order = checkout(cart, user) save_orde...
New
jakub-zawislak
Hi everyone, I’m coming from the Symfony (PHP) framework. I like Phoenix, but it has a one thing that was build much better in the Symfo...
New
pkrawat1
Hey guyz We at @aviabird are working on a payment library in elixir/phoenix. We are targeting March 2018 to add 56 Gateways to it. Have...
New
kevinlang
Hey all, We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3! We have successfully on-boarded the full suite of integration tests (...
New
zoltanszogyenyi
Hey everyone :waving_hand: Excited to join this forum - I am one of the founders and current project maintainers of a popular and open-s...
New

Other popular topics Top

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement