Skip to content

feat: add opt-in TwelveLabs (Marengo/Pegasus) embedding_lib for video-aware RAG#65

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

feat: add opt-in TwelveLabs (Marengo/Pegasus) embedding_lib for video-aware RAG#65
mohit-twelvelabs wants to merge 1 commit into
jolibrain: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 extends Colette's multimodal RAG with video by adding an opt-in twelvelabs embedding library to the langchain text-RAG backend.

What it adds

  • MarengoEmbeddings (src/colette/backends/langchain/rag/twelvelabs_embeddings.py): TwelveLabs' Marengo model exposed through the LangChain Embeddings interface (512-dim multimodal vectors shared across text/image/audio/video). It's a drop-in alternative to HuggingFaceEmbeddings in the existing Chroma vector store.
  • embedding_lib: "twelvelabs" wired into RAGObj (apidata.py) and the RAGTxt.init dispatch, alongside the existing huggingface/colbert/vllm options. embedding_model is optional and defaults to marengo3.0.
  • analyze_video() Pegasus helper: turns a video (public URL, uploaded asset id, or indexed video id) into text you can chunk and index like any other document — so video content becomes searchable next to your PDFs. Because Marengo embeds text and video into the same space, retrieval stays coherent.

Why it helps Colette

Colette is already a multimodal/V-RAG system; this lets users bring video into the same RAG pipeline without leaving the existing config/registry conventions, using a hosted API (no extra GPU/VRAM needed for the embedder).

Opt-in / non-breaking

Defaults are unchanged. The twelvelabs SDK is imported lazily (only when selected), and the API key is read from TWELVELABS_API_KEY and never logged. Existing huggingface/colbert/vllm paths are untouched.

How it was tested

  • ruff format + ruff check clean on the new files (pre-existing repo lint untouched).
  • A no-network unit test (@pytest.mark.smoke) verifying the LangChain Embeddings wiring with a mocked client, plus argument validation for analyze_video.
  • A TWELVELABS_API_KEY-gated live integration test (follows the repo's COLETTE_RUN_INTEGRATION=1 convention) that confirms Marengo returns a real 512-dim text embedding. I ran it against the live API and it passes.

The dependency is added to the trag (text-RAG) optional extra in pyproject.toml, and docs/source/users/configuration.md documents the new option.

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

…-aware RAG

Add 'twelvelabs' as a new embedding_lib for the langchain text-RAG backend.
MarengoEmbeddings implements the LangChain Embeddings interface (512-dim
multimodal vectors) so it is a drop-in alternative to HuggingFaceEmbeddings
in the existing Chroma vector store. A Pegasus analyze_video() helper turns
videos (URL/asset/video_id) into text that can be indexed like any document.

Opt-in and non-breaking: defaults are unchanged, the SDK is imported lazily,
and the key is read from TWELVELABS_API_KEY (never logged). Includes a
no-network unit test and a TWELVELABS_API_KEY-gated live test.
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