Large language models (LLMs) are increasingly used for semantic query processing over large corpora. A set of semantic operators derived from relational algebra has been proposed to provide a unified interface for expressing such queries, among which the semantic filter operator serves as a cornerstone. Given a table T with a natural language predicate e, for each tuple in the relation, the execution of a semantic filter proceeds by constructing an input prompt that combines the predicate e with its content, querying the LLM, and obtaining the binary decision. However, this tuple-by-tuple evaluation necessitates a complete linear scan of the table, incurring prohibitive latency and token costs. Although recent work has attempted to optimize semantic filtering, it still does not break the linear LLM invocation barriers. To address this, we propose Clustering-Sampling-Voting (CSV), a new framework that reduces LLM invocations to sublinear complexity while providing error guarantees. CSV embeds tuples into semantic clusters, samples a small subset for LLM evaluation, and infers cluster-level labels via two proposed voting strategies: UniVote, which aggregates labels uniformly, and SimVote, which weights votes by semantic similarity. Moreover, CSV triggers re-clustering on ambiguous clusters to ensure robustness across diverse datasets. The results conducted on real-world datasets demonstrate that CSV reduces the number of LLM calls by 1.28-355x compared to the state-of-the-art approaches, while maintaining comparable effectiveness in terms of Accuracy and F1 score.
Figures & tables
Figure 1. Data Label Distributions of Lotus and Ours (CSV)
Figure 2. Probability Distribution Across Distance
Figure 3. An Running Example of Clustering-Sampling-Voting (CSV) with UniVote on IMDB-Review Dataset
Dataset
Query
Query Type
Predicate
Ground-truth
IMDB-Review
RV-Q1
semantic filter
The { review } is positive.
available
RV-Q2
semantic filter
The { review } explicitly recommends that others watch the movie.
GPT-4o
RV-Q3
semantic filter
The { review } focuses on factual descriptions like technical details.
GPT-4o
Codebase
CB-Q1
semantic filter
The { AboutMe } contains a link to social media.
GPT-4o
CB-Q2
semantic filter
The { AboutMe } text suggests that the user has either experience in computer science or expresses an interest in the field of computer science.
GPT-4o
CB-Q3
semantic filter
The { AboutMe } focuses on factual identification details.
GPT-4o
Table 1. Profile of Test Semantic Queries
Method
RV-Q1
RV-Q2
RV-Q3
CB-Q1
CB-Q2
CB-Q3
AD-Q1
AD-Q2
AD-Q3
AD-Q4
TC
Fever
Acc.
Reference
0.9480
0.8229
0.9097
0.9731
0.7782
0.7033
0.8972
0.9139
0.8112
0.8737
0.7203
0.8258
Lotus
0.9480
0.8679
0.9948
0.9595
0.6853
0.6996
0.8938
0.9066
0.9192
0.8690
0.5196
0.7396
BARGAIN
0.9186
0.7881
0.9948
0.9681
0.5308
0.6493
0.7423
0.8972
0.3885
0.9563
0.7872
0.5177
UniCSV
0.9307
0.7723
0.9527
0.9673
0.7810
0.7090
0.8948
0.9193
0.8723
0.8975
0.7477
0.7526
SimCSV
0.9305
0.7718
0.9398
0.9671
0.7813
0.7376
0.8968
0.9193
0.8722
0.8977
0.7799
0.7524
F1
Reference
0.9489
0.7633
0.0880
0.6344
0.7557
0.6374
0.9056
0.8165
0.7002
0.1841
0.8060
0.8947
Table 2. The Accuracy and F1 Score of Semantic Filter Queries
Figure 4. Comparisons of Query Time, # LLM Calls and Token Usage for Semantic Filter
Parameter
Value
RV-Q1
CB-Q2
AD-Q2
RV
CB-Q2
AD-Q2
Acc.
F1
Acc.
F1
Acc.
F1
Acc.
F1
Acc.
F1
Acc.
F1
UniCSV
SimCSV
# clusters
2
0.9079
0.9138
0.7780
0.7492
0.9168
0.8210
0.9082
0.9140
0.7739
0.7450
0.9168
0.8209
4
0.9307
0.9336
0.7852
0.7601
0.9192
0.8248
0.9305
0.9335
0.7803
0.7539
0.9193
0.8249
8
0.9367
0.9367
0.7829
0.7597
0.9202
0.8264
0.9388
0.9384
0.7774
0.7534
0.9202
0.8264
16
0.9424
0.9438
0.7815
0.7564
0.9200
0.8262
0.9379
0.9396
0.7788
0.7546
0.9199
0.8260
Table 3. Hyper-parameter Effects on the Performance of UniCSV and SimCSV
Figure 5. Hyper-parameter Effects on Query Time, # LLM Calls and Token Usage for Semantic Filter
Method
RV-Q1
RV-Q3
CB-Q1
CB-Q2
CB-Q3
AD-Q2
Acc.
UniCSV (w/o RC)
0.9229
0.9939
0.9677
0.7475
0.6403
0.9243
SimCSV (w/o RC)
0.9230
0.9939
0.9677
0.7469
0.6403
0.9240
UniCSV (w/ RC)
0.9301
0.9527
0.9673
0.7813
0.7090
0.9193
SimCSV (w/ RC)
0.9305
0.9398
0.9671
0.7813
0.7376
0.9193
F1
UniCSV (w/o RC)
0.9272
0
0.0619
0.7010
0.5302
0.8347
SimCSV (w/o RC)
0.9273
0
0.0619
0.7003
0.5302
0.8345
Table 4. Ablation Study of Re-clustering
ϵ
UniCSV
SimCSV
Est.
Err.
ξ(\textperthousand)
Est.
Err.
ξ(\textperthousand)
0.10
0.9991
0.0628
13.0
0.9980
0.0622
26.4
0.15
0.9997
0.0633
6.4
0.9997
0.0635
12.7
0.20
0.9997
0.0636
3.9
0.9997
0.0637
7.8
0.25
0.9999
0.0637
2.7
0.9999
0.0635
5.4
0.30
0.9999
0.0635
2.0
0.9999
0.0637
4.0
Table 5. Gap between Theory and Practice
Figure 6. UniCSV and SimCSV on Synthetic Queries
Appendix figures & tables4 assets
Supplementary material from the paper’s appendix.
Appendix
Algo.
Model
RV-Q1
CB-Q2
AD-Q2
Acc.
F1
Acc.
F1
Acc.
F1
UniCSV
LlaMa-8B
0.9307
0.9336
0.7799
0.7517
0.9190
0.8248
LlaMa-70B
0.9520
0.9523
0.7715
0.8079
0.9194
0.8251
GPT-4o
0.9306
0.9335
0.8870
0.8814
0.9194
0.8250
SimCSV
LlaMa-8B
0.9305
0.9335
0.7803
0.6988
0.9193
0.8249
LlaMa-70B
0.9521
0.9524
0.7701
0.8068
0.9194
0.8251
Appendix
Table 6. Semantic Filter with Different LLM Backbones
Figure 7. Comparisons on Different LLM Backbones
Algo.
Model
RV-Q1
CB-Q2
AD-Q2
Acc.
F1
Acc.
F1
Acc.
F1
UniCSV
E5
0.9307
0.9336
0.7852
0.7601
0.9192
0.8248
BGE
0.9527
0.9531
0.7827
0.7594
0.9122
0.8036
Qwen
0.9227
0.9235
0.7777
0.7540
0.9172
0.8192
SimCSV
E5
0.9305
0.9335
0.7815
0.7555
0.9193
0.8249
BGE
0.9520
0.9524
0.7806
0.7587
0.8947
0.7755
Appendix
Table 7. Semantic Filter with Different Embedding Models
Figure 8. Comparisons of Using Different Embedding Models
LLM inference acceleration develops algorithms and systems that reduce language-model latency, memory use, and serving cost while preserving output quality.