Introduction
Modern video analytics increasingly demands the ability to query "compositional events"—complex scenarios defined by intricate spatial, temporal, and semantic interactions. For instance, a traffic management system might need to identify a "car swerving then colliding," or a healthcare monitor might track a "doctor holding a scalpel and then placing it on a table."
Current approaches to these queries generally fall into two categories: direct inference using frontier Vision-Language Models (VLMs) like GPT-4o, or modular workflow-oriented systems. However, both have significant drawbacks. Direct VLM inference is prohibitively expensive at scale and often struggles with precise spatial or temporal reasoning. Workflow systems, while more efficient, suffer from a "cold start" problem: they cannot execute queries containing concepts (e.g., "silver" or "near") for which they lack pre-defined modules.
The VOCAL-UDF Framework
To address these limitations, we present VOCAL-UDF, a self-enhancing video database management system. VOCAL-UDF leverages Large Language Models (LLMs) not just to answer queries, but to build the necessary tools—User-Defined Functions (UDFs)—to answer them. This allows the system to automatically expand its capabilities when encountering unknown predicates.
The system follows a five-step pipeline:
- Parsing: An LLM translates natural language queries into a Domain Specific Language (DSL) based on Datalog.
- UDF Proposal: If the query includes unrecognized predicates, the system prompts the LLM to propose names and descriptions for new UDFs.
- Hybrid UDF Generation: The system generates candidate UDFs using two distinct methods: program-based logic (e.g., geometric calculations for "behind") and distilled-model UDFs (e.g., training a lightweight MLP on CLIP features for visual attributes like "silver").
- Active Learning Selection: To ensure accuracy and handle ambiguity, the system generates multiple UDF candidates and uses active learning to verify the best version with minimal user or VLM feedback.
- Execution: Finalized UDFs are integrated into the query, compiled into optimized SQL, and executed via DuckDB.
System Architecture
The architecture of VOCAL-UDF is designed for persistence and efficiency. Once a UDF is verified, it is cached in a Storage Manager, making the system progressively "smarter" with each query.
The UDF Generator is the engine of self-enhancement, creating both Python-based logic and distilled machine learning models. The Storage Manager maintains relational data, the library of UDFs, and raw video assets, ensuring that the system can scale across diverse domains without redundant computation.
Hybrid UDF Generation and Selection
A core innovation of VOCAL-UDF is its hybrid approach to UDF creation. For concepts that can be defined geometrically, such as "behind" or "near," the system generates Program-based UDFs. These are Python functions that operate on object bounding boxes. For nuanced visual concepts like "silver color" or "SUV," the system employs Distilled-model UDFs. It uses a heavy VLM to label a small sample of frames and then distills this knowledge into a lightweight Multi-Layer Perceptron (MLP). This model is significantly faster and cheaper to run than the original VLM while maintaining high accuracy.
Experimental Evaluation
VOCAL-UDF was evaluated across three diverse datasets: CLEVRER (synthetic spatiotemporal reasoning), CityFlow-NL (real-world traffic surveillance), and Charades (indoor human activities).
Key Results
- Accuracy: The system achieved near-perfect (F1 ≥ 0.98) NL-to-DSL parsing accuracy on the CLEVRER dataset. Unlike baseline systems, VOCAL-UDF maintained high performance even when multiple required UDFs were initially missing.
- Cost-Effectiveness: The efficiency gains are substantial. Executing a complex query over the CLEVRER test set using GPT-4o directly would cost approximately $207. VOCAL-UDF achieved superior accuracy for only $0.40—a reduction of over 500x.
- Efficiency: While initial UDF generation requires a few minutes of training/distillation, subsequent executions are highly optimized, typically completing in under 100 seconds.
Conclusion
VOCAL-UDF represents a significant step forward in video data management. By using LLMs as "tool-makers" rather than simple "answer-engines," the system overcomes the cold-start problem and provides a cost-effective, scalable solution for querying complex compositional events. Future work will focus on improving the system's handling of temporal state changes and allowing for personalized, subjective definitions of spatial relationships.
Summary updated