feat: add TwelveLabs (Marengo + Pegasus) support#42
Open
mohit-twelvelabs wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
TwelveLabsVideoSegmentStorage(invideorag/_storage/vdb_twelvelabs.py) mirrorsNanoVectorDBVideoSegmentStorageexactly, 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 overnano-vectordb, so nothing downstream changes — it just removes the local GPU / ImageBind checkpoint requirement for visual retrieval.tl_segment_caption(invideorag/_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(andvideo_embedding_dim=512) or callingtl_segment_captionexplicitly. ThetwelvelabsSDK is imported lazily inside the storage class, soimport videoragstill 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 onTWELVELABS_API_KEY.Docs / deps
Added a "TwelveLabs Support" section to
VideoRAG-algorithm/README.mdand listedtwelvelabs>=1.2.8as an optional dependency.Note: this targets the canonical
VideoRAG-algorithm/videoragpackage; I left the vendoredVimo-desktop/python_backendcopy 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.