Abstract
Quivr is a framework for automatically synthesizing programs to identify complex behaviors in video trajectory data from a small set of user-provided examples. By utilizing a novel "quantitative semantics" to prune the search space of real-valued parameters, Quivr achieves significant speedups and higher accuracy than deep learning baselines on small datasets. The system reaches F1 scores above 0.99 on the majority of evaluated tasks while providing a 5x speedup over state-of-the-art pruning techniques.
Introduction
Deep learning has made object tracking in video—converting raw pixels into sequences of (x, y) coordinates—a relatively standard procedure. However, the subsequent step of identifying specific patterns within those trajectories, such as "a car turning left while another car passes," remains a significant bottleneck.
These queries are difficult to manually author because real-world data is inherently "fuzzy." A programmer cannot simply define a static threshold like speed > 10; they must account for sensor noise and varied driving styles by tuning parameters (e.g., 10.5 vs 9.8). While neural networks could theoretically learn these behaviors, they typically require thousands of labeled examples, which are rarely available for niche data science tasks. Quivr addresses this by treating query generation as a program synthesis problem.
Methodology
Quivr employs a multi-faceted approach to automate query generation:
- Query Language: The framework uses a language based on regular expressions and temporal logic. Unlike standard Signal Temporal Logic (STL), Quivr’s predicates can match arbitrary subsequences, allowing for the identification of behaviors like "accelerating over a 5-second interval."
- Sketch-Based Synthesis: The system performs an enumerative search over program templates (sketches) with "holes" for real-valued parameters.
- Quantitative Semantics & Pruning: This is the core innovation. Instead of using slow binary searches to find parameter boundaries, Quivr uses a novel mathematical framework to directly compute the "distance" to the parameter boundary. This allows the system to prune entire regions of the parameter space simultaneously.
- Active Learning: To minimize user effort, Quivr identifies trajectories where current candidate queries disagree most and asks the user to label them, quickly narrowing down the correct program.
- GPU Acceleration: The quantitative semantics are implemented using matrix operations, enabling efficient execution on GPUs.
Experimental Evaluation
The authors evaluated Quivr on 17 distinct tasks across three datasets: YTStreams (real-world traffic footage), MABe22 (multi-agent mouse behavior), and Maritime Surveillance (synthetic ship movements).
Key results include:
- Accuracy: After only 10 steps of active learning, Quivr achieved an F1 score above 0.99 on 10 out of 17 tasks, consistently outperforming neural network baselines like LSTMs and Transformers on small sample sizes (10–25 examples).
- Efficiency: The use of quantitative semantics provided a 5.0x speedup over state-of-the-art binary search pruning techniques.
- Hardware Scaling: GPU-based synthesis was 7.6x faster than CPU-based execution.
Discussion and Conclusion
A primary insight of this work is that monotonicity in query semantics allows for powerful pruning. If a query is false for a specific threshold, it is guaranteed to be false for all thresholds beyond that point. By defining a scoring function for predicates, Quivr calculates boundaries in a single pass rather than through iterative search.
While currently limited to queries with a maximum of three predicates and two parameters, and assuming fixed camera positions, Quivr demonstrates that symbolic programs can generalize significantly better than neural networks for trajectory analysis when data is scarce. Future work may involve extending the language expressivity and adapting the system for moving camera platforms.
Summary updated