Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MAVIP β€” Multi-Agent Video Insight Pipeline

Agentic multimodal AI system for contextual video event understanding and retrieval

Python PyTorch HuggingFace LangChain License


Overview

MAVIP is a production-grade, multi-agent pipeline that processes egocentric video at scale, classifies temporal events using a custom PyTorch transformer, and enables lightning-fast semantic search via a Retrieval-Augmented Generation (RAG) architecture.

Metric Value
Multimodal event frames processed 15,000+
Contextual retrieval latency reduction 42 % via LLM orchestration
Classification backbone PyTorch ViT Transformer
Vector store backends FAISS Β· ChromaDB

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    MAVIP β€” Multi-Agent Pipeline                         β”‚
β”‚                                                                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                     OrchestratorAgent                            β”‚  β”‚
β”‚  β”‚            (LLM orchestration Β· workflow routing)                β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚          β”‚                   β”‚                   β”‚                      β”‚
β”‚          β–Ό                   β–Ό                   β–Ό                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚IngestionAgent β”‚  β”‚Classification  β”‚  β”‚   RetrievalAgent        β”‚    β”‚
β”‚  β”‚               β”‚  β”‚    Agent       β”‚  β”‚                        β”‚    β”‚
β”‚  β”‚ β€’ OpenCV      β”‚  β”‚ β€’ ViT backbone β”‚  β”‚ β€’ FAISS / ChromaDB     β”‚    β”‚
β”‚  β”‚   frame decodeβ”‚  β”‚ β€’ Temporal     β”‚  β”‚ β€’ SentenceTransformers β”‚    β”‚
β”‚  β”‚ β€’ 15 K+ framesβ”‚  β”‚   Transformer  β”‚  β”‚ β€’ ANN search (top-k)   β”‚    β”‚
β”‚  β”‚ β€’ 224Γ—224 RGB β”‚  β”‚ β€’ 9 labels     β”‚  β”‚ β€’ Cosine similarity    β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚         β”‚                  β”‚                      β”‚                     β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β”‚
β”‚                            β”‚                                            β”‚
β”‚                            β–Ό                                            β”‚
β”‚          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                       β”‚
β”‚          β”‚          VideoRAGPipeline            β”‚                       β”‚
β”‚          β”‚                                     β”‚                       β”‚
β”‚          β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚                       β”‚
β”‚          β”‚  β”‚  VectorStore  β”‚  β”‚  LLM Chain  β”‚  β”‚                       β”‚
β”‚          β”‚  β”‚  (FAISS/     β”‚  β”‚ (LangChain/ β”‚  β”‚                       β”‚
β”‚          β”‚  β”‚   ChromaDB)  β”‚  β”‚  LlamaIndex)β”‚  β”‚                       β”‚
β”‚          β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚                       β”‚
β”‚          β”‚                                     β”‚                       β”‚
β”‚          β”‚  Query ──► Embed ──► Retrieve ──►   β”‚                       β”‚
β”‚          β”‚            Synthesise ──► Answer     β”‚                       β”‚
β”‚          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                       β”‚
β”‚                            β”‚                                            β”‚
β”‚                            β–Ό                                            β”‚
β”‚          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                       β”‚
β”‚          β”‚       FastAPI HTTP Server            β”‚                       β”‚
β”‚          β”‚  POST /ingest  POST /query  GET /health                     β”‚
β”‚          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Temporal Classification Model

Frame Embeddings (T Γ— B Γ— 768)
         β”‚
         β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  Linear Proj β”‚  768 β†’ 512
  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ Temporal Pos. Encoding   β”‚  sinusoidal, max_len=15 000
  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   Γ—6 layers
  β”‚  TransformerEncoderLayer β”‚
  β”‚  d_model=512  nhead=8   β”‚
  β”‚  FFN dim=2048  GELU     β”‚
  β”‚  Pre-LN  dropout=0.1   β”‚
  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚   MLP Head   β”‚  512 β†’ 256 β†’ 9 classes
  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
  Per-frame logits (T Γ— B Γ— 9)

Project Structure

multi_agent_video_insight_pipeline/
β”‚
β”œβ”€β”€ src/
β”‚   └── mavip/                          # Main Python package
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ cli.py                      # CLI entry points
β”‚       β”‚
β”‚       β”œβ”€β”€ agents/                     # Specialised sub-agents
β”‚       β”‚   β”œβ”€β”€ orchestrator.py         # Top-level LLM orchestrator
β”‚       β”‚   β”œβ”€β”€ ingestion_agent.py      # Frame decode & multimodal chunking
β”‚       β”‚   β”œβ”€β”€ classification_agent.py # Temporal event labelling
β”‚       β”‚   └── retrieval_agent.py      # Semantic ANN search
β”‚       β”‚
β”‚       β”œβ”€β”€ models/
β”‚       β”‚   └── temporal_transformer.py # PyTorch ViT-based classifier
β”‚       β”‚
β”‚       β”œβ”€β”€ pipelines/
β”‚       β”‚   β”œβ”€β”€ rag_pipeline.py         # LangChain RAG pipeline
β”‚       β”‚   └── serve.py                # FastAPI HTTP server
β”‚       β”‚
β”‚       β”œβ”€β”€ retrieval/                  # (vector store adapters β€” extend here)
β”‚       └── utils/                      # Shared helpers
β”‚
β”œβ”€β”€ tests/
β”‚   └── test_pipeline.py                # Pytest unit tests
β”‚
β”œβ”€β”€ configs/
β”‚   └── default.yaml                    # Hydra / OmegaConf config
β”‚
β”œβ”€β”€ notebooks/                          # Jupyter exploration notebooks
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ raw/                            # Input videos (git-ignored)
β”‚   └── processed/                      # Processed event frames (git-ignored)
β”‚
β”œβ”€β”€ docs/
β”œβ”€β”€ pyproject.toml                      # PEP 517 package definition
β”œβ”€β”€ requirements.txt                    # Pinned dependencies
β”œβ”€β”€ LICENSE
└── README.md

Quickstart

1 β€” Install

# Clone
git clone https://github.com/your-org/multi-agent-video-insight-pipeline.git
cd multi-agent-video-insight-pipeline

# Create virtual environment
python -m venv .venv && source .venv/bin/activate   # Windows: .venv\Scripts\activate

# Install (CPU build)
pip install -e ".[dev,notebooks]"

# GPU build (CUDA 12.x)
pip install -e ".[dev,gpu]"

2 β€” Ingest a video

mavip-ingest path/to/egocentric_video.mp4 --fps 2

3 β€” Semantic search

mavip-retrieve path/to/video.mp4 "When does the person pick up the phone?" --top-k 10

4 β€” Run the API server

mavip-serve --host 0.0.0.0 --port 8000
# Ingest via HTTP
curl -X POST http://localhost:8000/ingest -F "video=@my_video.mp4"

# Query via HTTP
curl -X POST http://localhost:8000/query \
  -H "Content-Type: application/json" \
  -d '{"query": "phone interaction", "top_k": 5}'

5 β€” Run tests

pytest

Key Design Decisions

Decision Rationale
Async agent interface asyncio-native throughout β€” keeps the event loop free during heavy I/O (frame decode, embedding) by offloading to a thread pool executor
Pre-LN Transformer Training-stability improvement over post-LN; critical at 6+ layers on long temporal sequences
FAISS flat inner product Zero-configuration, exact retrieval < 5 ms for 15 K vectors; swap to IVF for 100 K+
ChromaDB fallback Persistent, distributed alternative when FAISS RAM budget is exceeded
Hydra config Supports CLI override, multi-run sweeps, and reproducible experiment configs without code changes
Stub-first architecture Every agent has a working stub that returns realistic shapes β€” CI passes without GPU or API keys

Configuration

All settings are controlled via configs/default.yaml and can be overridden from the CLI:

# Override ingestion FPS and retrieval top-k
mavip-ingest video.mp4 ingestion.fps=4 retrieval.top_k=20

Key config sections:

ingestion:
  fps: 1            # Frames per second to sample
  max_frames: 15000

classification:
  model_name: google/vit-base-patch16-224
  device: cpu       # Set to "cuda" for GPU

retrieval:
  backend: faiss    # "faiss" | "chroma"
  top_k: 10

rag:
  llm_model: gpt-4o
  vector_store_backend: faiss

Extending MAVIP

Add a new activity label

# src/mavip/agents/classification_agent.py
EGOCENTRIC_LABELS: list[str] = [
    ...
    "your_new_label",   # ← add here
]

Swap to a production LLM

# src/mavip/pipelines/rag_pipeline.py  β†’  query()
from langchain_openai import ChatOpenAI
from langchain.chains import RetrievalQA

self._llm = ChatOpenAI(model=self.llm_model, temperature=0)
retriever = self._vector_store.as_retriever(search_kwargs={"k": self.top_k})
chain = RetrievalQA.from_chain_type(llm=self._llm, retriever=retriever, return_source_documents=True)

Plug in a real frame encoder

# src/mavip/agents/classification_agent.py  β†’  _infer_batch()
from transformers import AutoImageProcessor, AutoModelForImageClassification
import torch

processor = AutoImageProcessor.from_pretrained(self.model_name)
inputs = processor(images=[e["frame_array"] for e in batch], return_tensors="pt").to(self.device)
with torch.no_grad():
    logits = self._model(**inputs).logits
return torch.softmax(logits, dim=-1).cpu().numpy()

Dependencies

Library Purpose
torch Β· torchvision TemporalEventClassifier, visual feature extraction
transformers Β· accelerate ViT backbone, HuggingFace model hub
langchain Β· llama-index LLM orchestration, RAG chain construction
faiss-cpu Β· chromadb Dense vector indexing and retrieval
opencv-python Β· decord Video decode and frame sampling
fastapi Β· uvicorn HTTP serving layer
hydra-core Β· omegaconf Hierarchical configuration management
loguru Β· rich Structured logging and terminal output

Full pinned list: requirements.txt


License

MIT Β© 2025 MAVIP Authors

About

Agentic multimodal AI system for contextual video event understanding and retrieval

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages