Prune First, Optimize Globally: Scalable Semantic Query Processing with UniBays
Wang et al. in Inference & systems
How can semantic joins scale to a billion candidates?
Prune First, Optimize Globally: Scalable Semantic Query Processing with UniBays
Why fast models still hit a database-scale wall
Relational operators run in nanoseconds to microseconds; even batched decision-model inference trails them by roughly three orders of magnitude.
Use typed, non-generative decision models, but prune structurally unsupported tuples first; then reuse semantic clues and coordinate the remaining calls across the whole query.
A cheap call still costs too much if it never mattered.
First, remove tuples the query can never use
- 1
Split exact structure
Drop semantic edges; supported relational inner equijoins form connected components.
- 2
Propagate key support
Exact semijoins run to a fixpoint, removing rows with no matching-key support before semantic inference.
- 3
Keep it exact
For acyclic inner-join components, Yannakakis-style reduction is fully reducing without materializing the multiway join.
The output depends on more than one predicate

A₁ tests whether a plan applies to a report; B₁ and B₂ test whether sites can execute it. Output o₁ is A₁ AND (B₁ OR B₂), so A₁=false makes both site checks irrelevant.
Then reuse record-level evidence across pairs
- 1
State necessary conditions
UniBays extends its earlier Semantic Bloom Filter idea: each plan has necessary report requirements, each an OR-set; all must hold for a match.
- 2
Reuse proposition scores
Decision models score record-level clues like humid storage; cached scores serve many plans and queries.
- 3
Reject only with evidence
Only a fully scored, below-threshold requirement can reject a pair; missing scores cannot. Passing is not proof of a match.
- 4
Evaluate survivors
Survivors go to the global optimizer for full-predicate evaluation and selective LLM escalation.
Finally, optimize costly decisions over the whole query
- 1
Calibrate scores
Random LLM labels estimate positive rates by score bin; raw decision-model scores need calibration.
- 2
Trace output dependencies
The decision model provisionally labels each remaining predicate; Boolean lineage shows which output rows each judgment can change.
- 3
Choose impactful batches
It ranks uncertain, high-impact calls and sizes parallel rounds to balance LLM cost against waiting time.
- 4
Stop on query quality
After each round, it estimates whether the result meets precision and recall targets with required confidence, against all-LLM judgments on survivors.
Selective escalation restores quality, but costs more

With semantic indexes enabled, nine Maintenance XS queries average 0.5806 F1 in UniBays-Flash and 0.9332 after selective LLM escalation. Versus LLM-only execution, UniBays cuts total time 31.4% and model cost 8.8%.
Fastest on every SemBench query
21 mostly modest-scale queries; Jev has no LLM escalation; baselines use gpt-6-luna. Values: mean quality, USD and seconds. Ratio vs SEMA.
An index trims pairs, but is not lossless
Across all 27 Shelob queries, execution without semantic indexes averaged 0.9092 F1.
Mean F1 rose to 0.9201; execution was 2.77× faster and cost 74.3% less. On nine Maintenance XS queries, indexes pruned 76.51% of candidate pairs while retaining 99.16% of ground-truth matches.
Reuse helps, but index builds are upfront and screening can still lose true matches.
Shelob makes the scaling claim concrete
Maintenance S reaches 1.02B candidate tuples. Across 27 instances, LOTUS completed 15, SEMA 11 and Palimpzest 7 within the per-query limit.
With semantic indexes and selective LLM escalation, UniBays completed all 27 in 5.8–209.4 s; F1 ranged from 0.77 to 1.00, with mean 0.9201. Its targets are 0.90 precision/recall against all-LLM judgments on survivors.
Global optimization trades some F1 for speed

At the same 0.90 precision/recall target, with indexes on Maintenance XS, global optimization is faster on 8/9 queries and cuts total time 31.9% and cost 7.6%; mean F1 is 0.9332 vs 0.9378 for operator cascades.
Where the quality estimate and pruning can fail
Approximate screening
Requirements and proposition scores can be wrong, so semantic screening may discard true matches.
Conditional confidence
The estimator assumes decisions in a score bin share a positive rate and are conditionally independent given that rate.
Targets begin after pruning
Targets are checked against all-LLM judgments on survivors; earlier index errors can still lower final F1.
Upfront cost and scope
Cold index builds need amortization; exact relational reduction supports inner equijoins, while semantic-edge interleaving is future work.
Why it matters
- Scale comes from shrinking candidates before inference, then spending LLM calls only where judgments can still change query outputs.
- Reuse cached proposition scores when records and model settings match; prioritize LLM calls by potential effect on query precision or recall.
- The open question is whether relational and semantic reductions can be interleaved cheaply as new model judgments arrive.
2 likes 13 slides, 3 min
2 days ago