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.

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.

Where Next?

Popular in Libraries Top

achempion
Hi, I would like to tell about my initiative to further maintain and develop Waffle project which is the fork of Arc library. The progre...
New
tmbb
I’ve decided to create this topic to discuss optimization possibilities for something like Phoenix LiveView. I’ve created this topic unde...
New
RobertDober
Earmark is a pure-Elixir Markdown converter. It is intended to be used as a library (just call Earmark.as_html), but can also be used as...
239 11851 134
New
marcuslankenau
I feel kind of stuck with the absence of a proper xml library for Elixir. Currently I use SweetXML which was ok for me more or less to pa...
New
mindok
What is ContEx? A pure Elixir server-side data plotting/charting library outputting SVG. It has nice barcharts in particular and works g...
New
Crowdhailer
Raxx is an alternative to Plug and is inspired by projects such as Rack(Ruby) and Ring(Clojure). 1.0-rc.1 is now available. To use it re...
New
archan937
It is a well-know topic within the Elixir community: “To mock or not to mock? :)” Every alchemist probably has his / her own opinion con...
New
Crowdhailer
I have been updating a library that allows you to pipe between functions that use the erlang result tuple convention. Assuming you have...
New
Qqwy
Hello everyone, I wrote a small library today called MapDiff. It returns a map listing the (smallest amount of) changes to get from map...
New
ostinelli
Let’s write a database! Well not really, but I think it’s a little sad that there doesn’t seem to be a simple in-memory distributed KV da...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

Sub Categories:

We're in Beta

About us Mission Statement