An Efficient Content-based Time Series Retrieval System

Chin-Chia Michael Yeh, Huiyuan Chen, Xin Dai, Yan Zheng, Junpeng Wang, Vivian Lai, Yujie Fan, Audrey Der, Zhongfang Zhuang, Liang Wang, Wei Zhang, Jeff M. Phillips

Abstract

Content-based Time Series Retrieval (CTSR) is essential for identifying patterns in large-scale temporal data, yet existing methods often struggle to balance retrieval accuracy with computational efficiency. This paper presents RN2Dw/T (Residual Network 2D with Template Learning), a novel architecture that utilizes learned templates and 2D Residual Networks to generate high-quality embeddings. By decoupling the feature extraction process from the database search, RN2Dw/T achieves a 1,700x speedup over state-of-the-art alignment-based models while maintaining superior accuracy on benchmark datasets.

1. Introduction

The proliferation of time-series data across domains—ranging from financial markets and power grids to wearable health monitors—has increased the demand for efficient Content-based Time Series Retrieval (CTSR). The objective of CTSR is to find sequences in a database that are structurally similar to a given query, effectively acting as a search engine for data sequences.

Historically, practitioners have faced a stark trade-off. Simple metrics like Euclidean Distance (ED) offer high speed but fail to account for temporal shifts or "warping." Conversely, sophisticated methods such as Dynamic Time Warping (DTW) or 2D Residual Networks (RN2D) provide high accuracy by analyzing point-to-point alignments, but their computational cost is prohibitive for real-time applications. Because these models must compare the query against every database entry at runtime, latency scales linearly with database size, rendering them impractical for large-scale systems.

2. Methodology: RN2Dw/T

To address these limitations, we introduce RN2Dw/T. This model builds upon the structural pattern recognition capabilities of 2D ResNets but introduces a "template learning" mechanism to enable pre-computation.

2.1 Template Learning and Feature Extraction

The core innovation of RN2Dw/T is the use of a fixed set of learned templates—reference sequences optimized during the training phase. Instead of performing a joint comparison between a query and every database item, the model compares the input sequence to 32 learned templates. This comparison generates a pairwise distance matrix (a 2D grid showing distances between every point in the query and the templates), which is then processed by a 2D ResNet to produce a compact, fixed-length feature vector (embedding).

2.2 Decoupling and Pre-computation

By utilizing fixed templates, the model functions as a pure feature extractor. This allows for a fundamental shift in system architecture:

  1. Offline Phase: Feature vectors for all items in the database are pre-calculated and stored in an index.
  2. Online Phase: When a query is received, the model runs exactly once to generate a query embedding. The system then performs a rapid Euclidean search against the pre-computed index.

This approach reduces the online computational complexity from $O(N \times \text{Model})$ to $O(1 \times \text{Model} + N \times \text{Distance})$, where $N$ is the number of items in the database.

3. Experimental Evaluation

The system was evaluated on two primary benchmarks:

  • UCR Archive: A gold-standard collection of 128 datasets covering diverse domains such as motion capture and sensor data. This was formatted into a retrieval task involving over 136,000 training sequences.
  • Transaction Time Series: A real-world dataset from Visa containing merchant transaction "signatures," where the goal is to retrieve merchants of the same business category based on temporal transaction patterns.

4. Results

The experimental results demonstrate that RN2Dw/T successfully bridges the gap between efficiency and performance.

4.1 Retrieval Accuracy

On the UCR benchmark, RN2Dw/T achieved an NDCG@10 of 0.9336. This performance not only exceeds standard baselines like LSTMs, GRUs, and Transformers but also slightly outperforms the original, computationally expensive RN2D model. This suggests that comparing sequences to representative learned templates captures sufficient structural information for high-fidelity retrieval.

4.2 Computational Efficiency and Scalability

The most significant gain is observed in system latency. In a head-to-head comparison, the original RN2D required approximately 32 seconds to process a single query against the database. In contrast, RN2Dw/T completed the same task in 0.018 seconds—representing a 1,700x speedup. Furthermore, when integrated with Hierarchical Navigable Small World (HNSW) graphs for approximate search, the system achieved an additional 43x throughput increase with zero loss in retrieval accuracy.

5. Discussion and Future Work

While RN2Dw/T represents a significant advancement in CTSR, several avenues for future research remain. The current implementation focuses on univariate time series; extending the template learning mechanism to multivariate data is a priority. Additionally, the model currently requires labeled data for training. Exploring unsupervised pre-training could broaden the system's applicability to unlabeled datasets. Finally, for trillion-scale databases, incorporating low-bit representations (hashing or quantization) could further optimize storage and search speed.

6. Conclusion

RN2Dw/T provides a scalable solution for real-time time series retrieval. By combining the accuracy of 2D convolutional alignment with the efficiency of template-based embedding, the system enables high-performance search across massive temporal datasets without the traditional latency penalties associated with complex alignment models.

Summary updated

BibTeX
@inproceedings{yeh2023efficient,
  author = {Chin-Chia Michael Yeh and Huiyuan Chen and Xin Dai and Yan Zheng and Junpeng Wang and Vivian Lai and Yujie Fan and Audrey Der and Zhongfang Zhuang and Liang Wang and Wei Zhang and Jeff M. Phillips},
  title = {{An Efficient Content-based Time Series Retrieval System}},
  booktitle = {ACM International Conference on Information and Knowledge Management},
  year = {2023},
  url = {https://openreview.net/forum?id=vJ-9IL_ddY},
}
Figure