# Prune First, Optimize Globally: Scalable Semantic Query Processing with UniBays

> UniBays combines exact relational pruning, reusable proposition screens, and query-wide scheduling of uncertain judgments. UniBays-Flash with Jev was fastest on all 21 SemBench queries; full UniBays completed all 27 Shelob instances in 5.8–209.4 seconds, with mean F1 0.9201 (range 0.77–1.00).

- arXiv: https://arxiv.org/abs/2612.02918
- Authors: Zhengle Wang, Hanxu Yan, Weizheng Wang, Kyoungmin Kim, Fuheng Zhao, Chunwei Liu
- Published: 2026-12-03
- Topic: Inference & systems
- Visual carousel: https://instaxiv.com/p/2612.02918
- Explanation by InstaXiv, a secondary educational summary. Cite the original paper for exact results. InstaXiv is not affiliated with or endorsed by arXiv or Cornell University.

## How can semantic joins scale to a billion candidates?

**27/27** completed Shelob queries (out of 27)

## Why fast models still hit a database-scale wall

**A huge time-scale gap:** Relational operators run in nanoseconds to microseconds; even batched decision-model inference trails them by roughly three orders of magnitude.

**UniBays's answer:** 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

![Figure 2](https://cdn.instaxiv.com/figures/2612.02918/figure2.webp)

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. (Figure 2)

## 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

![Figure 3](https://cdn.instaxiv.com/figures/2612.02918/figure3.webp)

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%. (Figure 3)

## Fastest on every SemBench query

| Method | Mean quality | Model cost ($) | Latency (s) |
| --- | --- | --- | --- |
| Palimpzest | 0.8185 | 9.4899 | 3379.44 |
| LOTUS | 0.7006 | 4.7675 | 3096.57 |
| SEMA | 0.7304 | 3.8824 | 2330.11 |
| **UniBays-Flash (Jev) (56.8× faster)** | **0.8580** | **1.1951** | **40.99** |

_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

**Without indexes:** Across all 27 Shelob queries, execution without semantic indexes averaged 0.9092 F1.

**With prebuilt indexes:** 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

**Baselines, 2,000-second limit:** Maintenance S reaches 1.02B candidate tuples. Across 27 instances, LOTUS completed 15, SEMA 11 and Palimpzest 7 within the per-query limit.

**UniBays, indexed:** 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

![Figure 4](https://cdn.instaxiv.com/figures/2612.02918/figure4.webp)

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. (Figure 4)

## 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.

Best used when: Best when relational keys or reusable record-level clues shrink candidates, and repeated queries can amortize index construction.

## Key takeaways

- 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.

## Links

- arXiv: https://arxiv.org/abs/2612.02918
- PDF: https://arxiv.org/pdf/2612.02918

## Citation

```bibtex
@article{wang2026prune,
  title   = {Prune First, Optimize Globally: Scalable Semantic Query Processing with UniBays},
  author  = {Wang, Zhengle and Yan, Hanxu and Wang, Weizheng and Kim, Kyoungmin and Zhao, Fuheng and Liu, Chunwei},
  journal = {arXiv preprint arXiv:2612.02918},
  year    = {2026},
  url     = {https://arxiv.org/abs/2612.02918}
}
```
