Beyond Linear LLM Invocation: An Efficient and Effective Semantic Filter Paradigm

Nan Hou, Kangfei Zhao, Jiadong Xie, Jeffrey Xu YuarXiv 2026

TL;DR

Filtering database rows using Large Language Models (LLMs) for natural language criteria is powerful but prohibitively slow and expensive due to the necessity of a linear scan. This paper introduces Clustering-Sampling-Voting (CSV), a framework that groups semantically similar data points, samples a tiny fraction for LLM evaluation, and infers the rest via cluster-level voting. CSV breaks the linear scan barrier, slashing LLM invocation costs by up to 355× while providing rigorous theoretical error guarantees.

What Problem Does This Paper Address?

As unstructured data grows, systems increasingly rely on LLM-powered "semantic filters" to execute queries like “Find all movie reviews that are positive” or “Filter user profiles indicating computer science experience.”

Traditionally, this requires a linear scan: the system constructs a prompt for every single row (tuple), queries the LLM, and records the binary decision. For large tables, this tuple-by-tuple evaluation incurs massive latency and financial costs. Recent state-of-the-art optimizations try to mitigate this using a "model cascade"—employing a cheaper, smaller proxy LLM to filter easy rows before sending ambiguous ones to a powerful oracle LLM. However, even these cascade methods require a linear pass over the data by the proxy model, and they often degrade if the proxy's confidence scores are poorly calibrated.

Figure 1: Data Label Distributions of Lotus and Ours (CSV)

The authors address a fundamental question: Can we reduce the complexity of LLM invocations to sublinear while still providing strict error guarantees?

Methods

The authors propose the Clustering-Sampling-Voting (CSV) paradigm, which shifts the workload from expensive LLM inference to cheap vector embeddings. The framework operates in three main phases:

  1. Clustering (Offline): Text columns are converted into vector embeddings using a pretrained encoder (like E5-Large) and grouped into semantically coherent clusters using K-means. This step is query-agnostic and done once.
  2. Sampling (Online): When a user executes a filter query, CSV randomly samples a small fraction ($\xi$) of tuples from each cluster and sends only those to the LLM.
  3. Voting (Online): The remaining unsampled tuples in the cluster inherit a label based on the sampled results using one of two strategies:
  4. UniVote (Uniform Voting): A simple majority vote where all samples contribute equally.
  5. SimVote (Similarity-based Voting): Votes are weighted based on the embedding similarity between the unsampled tuple and the sampled representatives.

Adaptive Re-clustering: To guarantee accuracy, CSV checks the "purity" of a cluster's vote. If a cluster is highly ambiguous (e.g., close to a 50/50 split of True/False), the algorithm recursively splits that cluster into finer sub-clusters online. If a sub-cluster remains ambiguous at maximum depth, it safely falls back to linear LLM evaluation for just those ambiguous rows.

The entire framework is backed by a theoretical error bound derived from the Bernstein Inequality, allowing users to specify an error tolerance ($\epsilon$) to automatically determine the required sample size.

Datasets

The CSV framework was evaluated across five diverse real-world datasets:

  • IMDB-Review: 50,000 movie reviews for binary sentiment analysis.
  • Codebase: 9,378 rows of user self-introductions.
  • Airdialogue: 402,035 airline ticketing dialogue logs (deconstructed into four binary classification tasks).
  • Twitter Hate Speech (TC): 24,783 tweets annotated for hate speech or offensive language.
  • Fever: A large-scale fact-verification benchmark requiring multi-column filtering.

Key Insights and Ideas

  • Semantic Proximity Equals Output Consistency: The core intuition is that if two inputs are close in embedding space, the LLM will likely yield the same filtering decision. The authors empirically validate this (shown below), proving that as embedding distance increases, the probability of label agreement drops consistently across different queries.
Probability of label agreement across embedding distance
  • Bypassing LLM Calibration Issues: Deep learning models are notoriously overconfident, making raw logit/confidence scores unreliable for thresholding. By relying on cluster-based consensus rather than individual model confidence, CSV provides a more robust proxy for uncertainty.
  • Sublinear Complexity: By evaluating clusters as units rather than rows, the average-case complexity of LLM invocations drops from $O(|T|)$ to sublinear.

Key Results

  • Massive Efficiency Gains: CSV reduced the number of LLM calls by 1.28–200× compared to a standard linear scan (Reference) and 1.81–355× compared to the state-of-the-art cascade approach (Lotus).
  • Drastic Speedups: On the IMDB dataset (RV-Q1), CSV required only 404 LLM calls and finished in 13 seconds, whereas the baseline methods required tens of thousands of calls and took over 1,000 seconds.
  • Preserved Accuracy: Despite evaluating only a fraction of the data, both UniCSV and SimCSV maintained Accuracy and F1 scores highly comparable to a full linear scan across almost all test cases.

Limitations and Future Work

The primary limitation of CSV lies in low-selectivity queries (scenarios where positive cases are extremely rare, such as $<3\%$). If a cluster contains very few true positives, a small random sample might miss them entirely. This can lead the voting mechanism to confidently label the entire cluster as negative, hurting the F1 score.

While the authors introduced a hybrid distance metric combining BM25 (lexical search) with embeddings to help isolate rare keyword-driven positives, handling highly abstract, low-selectivity queries without increasing sample sizes remains an open area for future optimization.

Summary updated

BibTeX
@misc{hou2026beyond,
  author = {Nan Hou and Kangfei Zhao and Jiadong Xie and Jeffrey Xu Yu},
  title = {{Beyond Linear LLM Invocation: An Efficient and Effective Semantic Filter Paradigm}},
  year = {2026},
  eprint = {2603.04799},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.04799},
}
Figure