Sonar-TS: Search-Then-Verify Natural Language Querying for Time Series Databases
Authors: Zhao Tan, Yiji Zhao, Shiyu Wang, Chang Xu, Yuxuan Liang, Xiping Liu, Shirui Pan, Ming Jin
Organizations: Jiangxi University of Finance and Economics · Griffith University · Yunnan University · Microsoft Research Asia · The Hong Kong University of Science and Technology (Guangzhou)
Natural Language Querying for Time Series Databases (NLQ4TSDB) aims to assist non-expert users retrieve meaningful events, intervals, and summaries from massive temporal records. However, existing Text-to-SQL methods are not designed for continuous morphological intents such as shapes or anomalies, while time series models struggle to handle ultra-long histories. To address these challenges, we propose Sonar-TS, a neuro-symbolic framework that tackles NLQ4TSDB via a Search-Then-Verify pipeline. Analogous to active sonar, it utilizes a feature index to ping candidate windows via SQL, followed by generated Python programs to lock on and verify candidates against raw signals. To enable effective evaluation, we introduce NLQTSBench, the first large-scale benchmark designed for NLQ over TSDB-scale histories. Our experiments highlight the unique challenges within this domain and demonstrate that Sonar-TS effectively navigates complex temporal queries where traditional methods fail. This work presents the first systematic study of NLQ4TSDB, offering a general framework and evaluation standard to facilitate future research.
Figures & tables
Figure 1: Comparison of querying paradigms. While Text-to-SQL fails to express morphological intents and Time Series Models are limited by context length, Sonar-TS adopts a “Search-Then-Verify” pipeline: it uses SQL to search a symbolic index for candidates and Python to verify them on raw data.
Paradigm / Method
MP
MS
NLG
Text-to-SQL
✗
✓
✓
TSQA Models
✓
✗
✓
TS Similarity Search
✓
✓
✗
Sonar-TS (Ours)
✓
✓
✓
Table 1: Capability comparison of existing paradigms against the fundamental requirements of NLQ4TSDB. Abbreviations: MP (Morphological Primitives), MS (Massive Scalability), NLG (Natural Language Grounding).
Figure 2: The hierarchical taxonomy of tasks in NLQTSBench. The benchmark ranges from Level 1 (Basic Operations) which tests numerical filtering, to Level 2 (Pattern Recognition) for morphological grounding, Level 3 (Semantic Reasoning) for logical composition, and finally Level 4 (Insight Synthesis) for narrative reporting.
Level
Task Sub-Type
Count
Avg. Length
L1: Basic Operations
Atomic Retrieval
216
∼ 2k
Sliding Window
58
L2: Pattern Recognition
Shape Identification
129
∼ 0.6k
Periodicity Detection
120
Subsequence Matching
111
L3: Semantic Reasoning
Composite Trend
220
∼ 30k
Table 2: Statistics of NLQTSBench. The dataset comprises 1153 queries spanning four complexity levels.
Figure 3: The overview of the Sonar-TS framework. The workflow is organized into three stages: (1) Offline Data Processing constructs compact multi-scale Feature Tables to serve as a queryable index; (2) Online Querying , where the Task Planner and Code Generator synthesize SQL for rapid candidate search and Python for exact verification, guided by domain heuristics distilled from an offline Prompt Cold Start mechanism; and (3) Post-processing translates execution artifacts into a user-friendly interface.
Operator Signature
Mathematical Grounding
detect_period
Autocorrelation Function (ACF) for cyclic behaviors.
find_best_match
Dynamic Time Warping (DTW) for subsequence matching.
detect_changepoints
PELT algorithm for structural segmentation.
calc_trend_slope
Theil-Sen estimator + local slope distribution.
calc_correlation
Pearson correlation for causal links.
Table 3: Representative verification primitives in the operator library.
Figure 4: Snapshot of representative Injected Experiences.
Category
Method
L1: Basic Ops
L2: Pattern Rec.
L3: Semantic Reasoning
L4
Avg.
AR
SW
SI
PD
SM
CT
CxA
CsA
IS
Performance on NLQTSBench-Lite (Short Context)
Time Series Models
ChatTS-14B
-
-
0.1768
-
-
0.2431
-
0.1229
-
0.1818
ITFormer-7B
-
-
0.0736
-
-
0.1500
-
0.1953
-
0.1529
Time-R1
-
-
0.0320
-
-
0.1395
-
0.1878
-
0.1374
Ours
Sonar-TS
-
-
0.2491
-
-
0.2680
-
0.3615
-
0.3016
Table 4: Main experimental results on NLQTSBench. Abbreviations: AR (Atomic Retrieval), SW (Sliding Window), SI (Shape Ident.), PD (Periodicity Det.), SM (Subseq. Matching), CT (Composite Trend), CxA (Contextual Anomaly), CsA (Causal Anomaly), IS (Insight Synthesis). Best results are bolded , and the best baseline results are underlined .
Variant
L1: Basic
L2: Pattern
L3: Reasoning
L4
Avg.
AR
SW
SI
PD
SM
CT
CxA
CsA
IS
Sonar-TS
0.8609
0.7827
0.3336
0.8625
0.9439
0.2988
0.4767
0.3841
0.7395
0.6144
w/o Self-Correction
0.8302
0.7250
0.3056
0.8618
0.9217
0.2919
0.4813
0.3326
0.7139
0.5930
w/o Feature Tables
0.8658
0.6923
0.1561
0.8804
0.9309
0.0422
0.4968
0.3918
0.7163
0.5430
w/o Experiences
0.8426
0.5591
0.1186
0.8311
0.9138
0.0677
0.2501
0.3612
0.3415
0.4686
w/o Verification
0.8294
0.1870
0.2992
0.0154
0.0396
0.2826
0.0818
0.0592
0.0261
0.2721
Table 5: Ablation study on component contributions. We analyze the impact of removing the Feature Table, Experiences, and the Verification phase. Abbreviations follow Table 4 . Cells highlighted in blue indicate tasks most significantly impacted by the ablation.
Figure 5: Case Study. Text-to-SQL (Left) lacks morphological expressivity, and TS Models (Right) fail the logical constraint. Sonar-TS (Middle) succeeds via Search-Then-Verify.
Appendix figures & tables8 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 6: The human verification interface. Annotators inspect both the global context (top) and the local detail view (bottom, where the injected signal in orange is overlaid on the raw data in blue) to validate the ground truth.
Level
Subtask
Metric
L1
Atomic Retrieval (Global Aggregation)
Relative Accuracy
L1
Atomic Retrieval (Temporal Localization)
Hit Rate
L1
Atomic Retrieval (Interval Discovery)
IoU
L1
Sliding Window
IoU
L2
Shape Identification
IoU
L2
Periodicity Detection
Relative Accuracy
Appendix
Table 6: Task-to-metric lookup for NLQTSBench.
Level
Subtask
#Instances
L2
Shape Identification (SI)
100
L3
Composite Trend (CT)
200
L3
Causal Anomaly (CsA)
200
Total
500
Appendix
Table 7: Task composition of NLQTSBench-Lite (500 instances in total).
Figure 7: Visualization of Multi-Scale SAX Representations. The framework discretizes time series data across hierarchical granularities to support pattern matching at different resolutions: (Top) The Daily View captures high-frequency local fluctuations; (Middle) The Monthly View summarizes intermediate trends; (Bottom) The Yearly View abstracts long-term seasonality. The colored horizontal bars represent the assigned SAX symbols (from level a to e ) overlaid on the raw data (gray line).
Backbone Model
Avg. Score
Qwen3.5-9B
0.3598
Qwen3.5-27B
0.4817
Qwen3.5-35B
0.5359
DeepSeek-V3 (Default)
0.6144
Appendix
Table 8: Sensitivity of Sonar-TS to the LLM backbone.
Alphabet Size ( α )
L2: SI
L3: CT
α=3
0.1927
0.2318
α=5 (Default)
0.3336
0.2988
α=7
0.2896
0.2675
Appendix
Table 9: Sensitivity of morphology tasks to the SAX alphabet size α .
Task Category
Avg. Candidates
Recall
L2: Shape Identification
9.3
0.5482
L3: Composite Trend
5.8
0.4713
Appendix
Table 10: Internal evaluation of the Search stage, reporting average candidates retrieved and recall. Absolute candidate counts depend on benchmark construction details (e.g., the number of injected positives per query and the temporal scope of each instance).
Efficiency Metric
MAC-SQL
Sonar-TS
Offline Construction Time
N/A
∼ 83 s
Online Querying Latency
∼ 15 s
∼ 22 s
Average Token Cost
∼ 8k
∼ 11k
Storage Overhead
N/A
11%
Appendix
Table 11: System overhead and computational cost of Sonar-TS. Time is in seconds (s), token cost is the per-query average, and storage overhead is relative to the raw data size. Reported figures reflect a representative deployment on our experimental setup; concrete values depend on hardware, API latency, and code version.
Large language models (LLMs) have significantly advanced natural language querying over relational databases, yet their ability to query time-series databases (TSDBs) remains largely unassessed. Existing benchmarks fail to adequately capture the non-unified query syntaxes, diverse application domains, and unique time-specific query intents inherent to TSDBs. To address this gap, we introduce TQTS-BENCH, a multi-syntax benchmark for evaluating text-to-query capabilities over TSDBs. TQTS-BENCH contains 6,125 high-quality question-answering (QA) pairs spanning 97 TSDBs, 23 distinct query syntaxes, 22 application domains, and 4 types of time-specific query intents. It is constructed through a human-centric AI-assisted workflow, where all QA pairs are carefully reviewed and revised by domain experts to ensure quality and correctness. Extensive evaluations of advanced LLMs and state-of-the-art text-to-query methods reveal challenges in querying TSDBs. Even the best-performing model evaluated, Claude-Opus-5, achieves only 48.98% execution accuracy, while humans reach 87.34%. Error analysis reveals that this performance gap mainly stems from the heterogeneous query syntaxes across different TSDBs, misinterpretation of time-specific intents, and incorrect schema linking. These findings highlight new opportunities to narrow the gap between current LLM capabilities and the requirements of TSDB queries in real-world applications. The benchmark is available at: https://anonymous.4open.science/r/TQTS-Bench-00CD.
Fei Lyu, Zhiyi Peng, Jiaming Liu +5
College of Computer Science and Electronic Engineering, Hunan University
Natural language querying for time series databases aims to let users find what they need in long histories of data by asking in plain language. Shape queries ask how a series moves. They are the main challenge of this task. Recent work makes them feasible by using symbolization as a bridge between the query and the long history. However, existing symbolizations were designed for compression, similarity indexing, or classification. What a symbolization should provide for natural language querying has not been systematically studied. We therefore examine the definitions of six classical symbolizations against this task and identify three limitations. (1) Direction is missing from the string, (2) direction is measured at too small a scale, and (3) the letters are arbitrary. Three design principles follow. We follow these principles and make a minimal redesign of SAX called TT-SAX (two-track SAX). The level letters stay. Each segment gains a trend letter. It is measured across neighboring segments rather than inside one, and graded to match the adjectives that queries use. We conduct extensive experiments on the public NLQTSBench benchmark, comparing TT-SAX with the six classical symbolizations across six LLMs. TT-SAX outperforms all six on shape queries, and ablations trace its gains back to the three limitations one by one. This paper is the first systematic study of time series symbolization with natural language querying as the design goal. It provides a foundation for future research on this task. Our code is available at https://github.com/Atlamtiz/tt-sax.
Text offers intuitive access to information. This can, in particular, complement the density of numerical time series, thereby enabling improved interactions with time series models to enhance accessibility and decision-making. While the creation of question-answering datasets and models has recently seen remarkable growth, most research focuses on question answering (QA) on vision and text, with time series receiving minute attention. To bridge this gap, we propose a challenging novel time series QA (TSQA) dataset, QuAnTS, for Question Answering on Time Series data. Specifically, we pose a wide variety of questions and answers about human motion in the form of tracked skeleton trajectories. We verify that the large-scale QuAnTS dataset is well-formed and comprehensive through extensive experiments. Thoroughly evaluating existing and newly proposed baselines then lays the groundwork for a deeper exploration of TSQA using QuAnTS. Additionally, we provide human performances as a key reference for gauging the practical usability of such models. We hope to encourage future research on interacting with time series models through text, enabling better decision-making and more transparent systems.
Felix Divo, Maurice Kraus, Anh Q. Nguyen +5
AI & ML Lab, TU Darmstadt · University of New South Wales · MBZUAI, Abu Dhabi +4