Skip to content

feat: add TwelveLabs (Marengo + Pegasus) support#42

Open
mohit-twelvelabs wants to merge 1 commit into
HKUDS:mainfrom
mohit-twelvelabs:feat/twelvelabs-integration
Open

feat: add TwelveLabs (Marengo + Pegasus) support#42
mohit-twelvelabs wants to merge 1 commit into
HKUDS:mainfrom
mohit-twelvelabs:feat/twelvelabs-integration

Conversation

@mohit-twelvelabs

Copy link
Copy Markdown

Hi! I'm Mohit, I work at TwelveLabs (@mohit-twelvelabs).

This PR adds optional, opt-in support for TwelveLabs cloud video understanding to the VideoRAG pipeline, alongside the existing Ollama / DeepSeek / OpenAI options.

What it adds

  • Marengo embeddings as a drop-in visual retrieval index. TwelveLabsVideoSegmentStorage (in videorag/_storage/vdb_twelvelabs.py) mirrors NanoVectorDBVideoSegmentStorage exactly, but embeds video segments and text queries into Marengo's shared 512-d space. Video clips and queries are still compared with plain cosine similarity over nano-vectordb, so nothing downstream changes — it just removes the local GPU / ImageBind checkpoint requirement for visual retrieval.
  • Pegasus for clip-level captioning / QA. tl_segment_caption (in videorag/_videoutil/caption.py) reads the video directly and returns a natural-language caption, a cloud alternative to the local MiniCPM-V caption model. Output post-processing matches the existing captions.

Why it helps

VideoRAG already supports swapping the LLM/embedding backend per provider; this extends the same idea to the visual layer, letting users run the visual index and captioning without a local 24GB GPU / ImageBind + MiniCPM-V checkpoints.

Opt-in / non-breaking

Defaults are completely unchanged. You only touch TwelveLabs by passing vs_vector_db_storage_cls=TwelveLabsVideoSegmentStorage (and video_embedding_dim=512) or calling tl_segment_caption explicitly. The twelvelabs SDK is imported lazily inside the storage class, so import videorag still works with the SDK absent.

How it was tested

  • tests/test_twelvelabs.py: no-network unit tests (fake client) asserting the Marengo video/query embedding shapes and Pegasus caption cleanup, plus a live test gated on TWELVELABS_API_KEY.
  • Verified the live Marengo text-embedding call returns a 512-d vector. All 4 tests pass.

Docs / deps

Added a "TwelveLabs Support" section to VideoRAG-algorithm/README.md and listed twelvelabs>=1.2.8 as an optional dependency.

Note: this targets the canonical VideoRAG-algorithm/videorag package; I left the vendored Vimo-desktop/python_backend copy untouched to keep the diff focused — happy to mirror it there too if you'd like.

You can grab a free API key at https://twelvelabs.io — there's a generous free tier.

Optional, opt-in cloud video understanding:
- Marengo 512-d embeddings as a drop-in visual retrieval index
  (TwelveLabsVideoSegmentStorage), replacing the local ImageBind path.
- Pegasus clip-level captioning/QA (tl_segment_caption), replacing the
  local MiniCPM-V caption model.

Defaults are unchanged; the TwelveLabs SDK is imported lazily so existing
imports keep working without it. Adds focused tests (live test gated on
TWELVELABS_API_KEY) and README docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant