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

tmbb
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps: bureaucrat - which contains a bunch ...
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
danschultzer
In short Plug n’ play OAuth 2.0 provider library. Just set up a resource owner schema with Ecto (your user schema), install the dependen...
New
asiniy
Hey there! I wrote a download elixir package which does exactly what its name about - an easy way to download files. I saw solutions ...
New
benlime
LiveMotion enables high performance animations declared on the server and run on the client. As a follow up to my previous thread A libr...
New
tmbb
PhoenixWS - Websockets over Phoenix Channels Source code on Github here: https://github.com/tmbb/phoenix_ws Phoenix channels are a great...
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
Eiji
ExApi is a library that I’m developing now and hope release soon This library will allow to: list all apis list all api implementation...
New
Azolo
Hey everyone, I just released WebSockex which is a Elixir WebSocket client. WebSockex strives to work as a OTP special process, be RFC6...
New

Other popular topics Top

William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
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
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

Sub Categories:

We're in Beta

About us Mission Statement