# SABER: A SQL-Compatible Semantic Document Processing System Based on Extended Relational Algebra

SABER adds a SQL-compatible semantic algebra to existing document processing systems

Changjae Lee, Zhuoyue Zhao, Jinjun Xiong · arXiv · 2025-8-29

- **Problem** Existing semantic data processing systems lack a shared algebra, so multi-step queries over documents are hard to compose, reason about, and optimize. Their operators are described in system-specific terms rather than unified rules.
- **Method** SABER extends relational algebra with LLM-backed semantic operators and runs them from SQL. It swaps each data transformation or comparison for an LLM-based one, and it dispatches semantic calls to runtime handlers instead of changing the SQL parser.
- **Results** The authors find that none of LOTUS, DocETL or Palimpzest supports semantic difference or intersection directly. SABER implements both with embedding-based similarity.

## Why existing semantic systems are hard to compose

Semantic data processing systems let language models run filtering, extraction, joining and clustering over documents. LOTUS, DocETL and Palimpzest are the three systems this section compares, and each exposes natural-language APIs for unstructured documents. Their operator semantics are described in system-specific terms rather than in unified algebraic rules.

Pipelines that mix joins, filters, grouping and set or bag difference become hard to compose, reason about and optimize. SQL systems avoid this problem because standard relational algebra gives a foundation for correct composition and optimization. The existing SDPSs share no formal semantics, so there is no common basis for testing whether two pipelines are equivalent.

Core primitives such as difference, intersection and deduplication are often missing or only partially implemented.

Table 2 shows that all three systems support semantic selection and projection, reflecting their core role in filtering and transformation. Semantic join is supported in LOTUS and DocETL but not in Palimpzest, which shows divergence in pipeline composability. None of the three systems supports semantic difference or intersection directly.

The authors can build intersection only by projecting all attributes into one attribute and then applying a semantic join. They state that semantic difference cannot be expressed in these systems at all.

Production systems often mix structured, semi-structured and unstructured data, which document-focused tools don't handle well. Apache Wayang mixes physical operators from different data systems, but it doesn't add LLM-backed semantic operators. That gap motivates SABER, which extends relational algebra with semantic operators so they can compose like SQL.

## Semantic operators built on extended relational algebra

SABER keeps the structure of relational algebra and swaps each data transformation or comparison for an LLM-based one. The authors call the result SABER, for Semantic Algebra Based on Extended Relational algebra. Because the semantic operators keep the relational meaning, rewrite rules such as selection push-down still apply. The rule e1 ≡ e2 that holds in the conventional setting gives a matching semantic rule under the appropriate semantic equivalence.

The authors aim this at declarative query evaluation and logic plan optimization in semantic data processing systems.

The base is extended relational algebra, which represents relations as ordered lists so that duplicates and order are kept. SABER has 12 conventional relational algebra operators and 10 semantic relational operators. Product, bag-union and top-k get no semantic version, because their definitions use only standard auxiliary functions and the Loop function.

Those three operators don't need LLM-based semantic involvement, since they never compare or transform data values with a model. Semantic operators are marked with a superscript sem, which separates them from their classical counterparts.

A semantic selection, written σ^sem\_P(r), keeps each row of r for which the boolean semantic predicate P holds. An LLM evaluates P from the user's natural-language predicate, plus extra metadata and prompt wording. Deduplication compares rows by similarity rather than by exact data-type equality. Semantic difference depends on a membership test, isIn^sem, that checks semantic equivalence instead of plain equality.

Semantic sorting orders rows by an attribute specification that reflects semantic comparability, not syntactic order.

Semantic projection and semantic aggregation are defined over function sets whose members carry semantic interpretation. The semantic operators behave like their relational counterparts, and only the predicate or transformation changes. The data transformation is treated as a type-checked black box to relational algebra, so the algebra itself stays unchanged.

The authors reuse this grounding to bridge structured and unstructured data processing.

## Which relational operators the three backends cover

The authors check each SABER operator against the documented APIs of LOTUS, DocETL and Palimpzest, and against each system's observed behaviour. Selection and projection form the common core, because all three systems support both operators. Semantic join works in LOTUS and DocETL, but Palimpzest doesn't offer it. Grouping, aggregation, deduplication and sorting vary from one system to another.

Palimpzest gives only partial aggregation, while LOTUS and DocETL offer richer operator sets.

The sharpest gap is that none of the three systems supports semantic difference or intersection directly. Difference and intersection matter because they capture exclusion and overlap in comparative and conditional analyses. The authors suggest that intersection can be composed from projection and join, instead of being built directly. All attributes are first projected into one attribute, and the join then yields a result equivalent to intersection.

SABER treats these gaps as a blueprint for system evolution, not only as a list of missing features. Because the three systems lack difference and intersection, the authors implement both with embedding-based similarity. When a backend lacks an operator, SABER uses its own implementation instead. Semantic join is limited to equi-joins in this work, and general theta-joins are left for future work.

## How SQL text turns into semantic calls

SABER doesn't change the SQL parser or the query optimizer to run semantic calls. Instead, it scans the SQL text with regular expressions to find semantic UDF invocations and their arguments. Each matched call, such as SEM\_JOIN(...), is dispatched to a dedicated runtime handler that implements the matching SABER semantics. This pragmatic approach avoids invasive parser changes, which is why the authors call it enabling rapid deployment in existing systems.

The pipeline has three stages, and the first one loads the data a semantic operator references from tables or subqueries. That data then passes through an LLM-backed transformation, such as a prompt-based projection. The output is materialized as an intermediate table or dataframe, so later steps can read it. In the last stage, the SQL is rewritten so semantic calls point at the materialized outputs, and a standard relational engine keeps processing the query.

Each semantic UDF is a standalone Python function, and its output is a relational table that downstream SQL operators can consume.

SABER runs on top of LOTUS, DocETL and Palimpzest rather than on a new engine. Those three systems don't support semantic difference or semantic intersection, so SABER implements both with embedding-based similarity. This design lets SABER reuse existing query optimization in the backends while keeping its own semantics for these two operators.

The paper reports no evaluation of these two operators.

Consider a query that asks for the most expensive apple-related product. A SEM\_WHERE clause with the lotus backend filters product names by their relation to apple. ORDER BY price DESC with LIMIT 1 then picks the single answer from the filtered rows. Because the output stays relational, the query keeps the algebraic closure that the authors rely on for downstream operators.

## One movie query across three backends

The authors ran one mixed structured and unstructured query on LOTUS, DocETL, and Palimpzest to test the design end to end. They built a normalized semantic database from the official IMDb non-commercial dataset and the Cinemagoer library. Each movie was linked to its primary director, so every film row pairs with one director. The authors pulled the top 250 movies through the IMDbPY API, keeping title, year, rating, and plot.

That process produced two tables: movies for film-level metadata and directors for biographical context.

The backend-free query in Figure 1 asks for the top 5 rated movies about personal resilience. Two SEM\_WHERE conditions filter rows, one on the director's overcoming of challenges and one on the plot. SEM\_SELECT writes a one-sentence summary of each director's biography. The rows are then ordered by rating in descending order and capped with LIMIT 5.

Because SEM\_SELECT and SEM\_WHERE are semantic, the query combines projection and selection in one plan.

Each backend gets its own rewritten SQL, so each version carries that backend's own LLM prompt. Figure 2 lists the three rewritten queries, and the prompt wording differs across them. The authors read the three outputs as showing that SABER keeps the semantic interpretation consistent. Table 3 shows the ranked movies each backend returned, along with director summaries.

The authors didn't score these outputs against labelled answers, so the consistency claim rests on the result tables.

## Limits of the prototype and the evidence

The prototype dispatches semantic operators by matching regular expressions against SQL strings. It doesn't go through the SQL parser or the logical plan, so the optimizer can't yet reason about semantic operators. The authors keep parser and optimizer changes out of scope, leaving deeper integration as future work.

The authors state that the LLM responses behind the operators, such as prompt interpretation and similarity scoring, lack formal guarantees. LOTUS, DocETL, and Palimpzest lack semantic difference and intersection, so SABER builds both on embedding-based similarity. The text doesn't report any evaluation of that choice against alternatives.

Join covers only equi-joins for now, and general theta joins are left for future work.

The validation is a single movie query run on three backends: LOTUS, DocETL, and Palimpzest. That query draws on the top 250 movies retrieved through the IMDbPY API. The authors' claims of portability, compositionality, and expressive power therefore rest on this one case.

Cost-based planning across semantic and classical operators appears only as a future extension, and they didn't test it. Extending SQL parsers and query planners would enable deeper optimization and execution efficiency, the authors argue.

## Paper info

- **Authors**: Changjae Lee, Zhuoyue Zhao, Jinjun Xiong
- **Venue**: arXiv · Preprint
- **First published**: 2025-8-29
- **Added**: 2026-10-20
- **Updated**: 2025-8-29
- **Version**: v1
- **arXiv**: 2509.00277
- **Category**: cs.DB · cs.AI
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/2509.00277v1) · [PDF ↗](https://arxiv.org/pdf/2509.00277v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Changjae Lee, Zhuoyue Zhao, Jinjun Xiong (2025). SABER: A SQL-Compatible Semantic Document Processing System Based on Extended Relational Algebra. arXiv:2509.00277v1. https://arxiv.org/abs/2509.00277v1

**BibTeX**

```
@misc{lee2025saber,
  title = {{SABER: A SQL-Compatible Semantic Document Processing System Based on Extended Relational Algebra}},
  author = {Changjae Lee and Zhuoyue Zhao and Jinjun Xiong},
  year = {2025},
  eprint = {2509.00277},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.00277v1}
}
```

## Related papers

- [Holistic Evaluation of Language Models](https://refivu.com/en/papers/88eac8fe-87f0-44a8-9be8-34c00f101de4-holistic-evaluation-of-language-models.md)
- [How to Fine-Tune BERT for Text Classification?](https://refivu.com/en/papers/b42bc4b9-8309-43db-89e9-41cd1d0ec800-how-to-fine-tune-bert-for-text-classification.md)
- [Linformer: Self-Attention with Linear Complexity](https://refivu.com/en/papers/470ce67a-0f79-4a06-ae89-f26384095187-linformer-self-attention-with-linear-complexity.md)
- [Longformer: The Long-Document Transformer](https://refivu.com/en/papers/095aa21a-9a7f-4317-a80b-f961fdd4e423-longformer-the-long-document-transformer.md)
- [Online Label-Free Gradient Matching for Continual Language Model Training](https://refivu.com/en/papers/8a35577d-0d59-4cb9-8918-b7d9da395e37-online-label-free-gradient-matching-for-continual-language.md)
- [Thumbs up? Sentiment Classification using Machine Learning Techniques](https://refivu.com/en/papers/099cc783-1d4a-4899-b08c-ce3886810f1a-thumbs-up-sentiment-classification-using-machine-learning.md)

## Other paper commentary

- [PaLM-E: An Embodied Multimodal Language Model](https://refivu.com/en/papers/c14507e3-43e7-434d-adc8-94f0d2c42b5f-palm-e-an-embodied-multimodal-language-model.md)
- [Large Language Models are Zero-Shot Reasoners](https://refivu.com/en/papers/6b8a675c-a686-4e78-8256-301472d5cac2-large-language-models-are-zero-shot-reasoners.md)
- [Generative Agents: Interactive Simulacra of Human Behavior](https://refivu.com/en/papers/3638efc4-db4a-48d9-bc16-5a758d9198fd-generative-agents-interactive-simulacra-of-human-behavior.md)
- [SWE-bench: Can Language Models Resolve Real-World GitHub Issues?](https://refivu.com/en/papers/1cf41e87-39dc-4e23-9d0c-22ab7bc2a24b-swe-bench-can-language-models-resolve-real-world.md)
- [Voyager: An Open-Ended Embodied Agent with Large Language Models](https://refivu.com/en/papers/39fe0a31-1bf8-4ca2-bc7b-151ae7a6faa4-voyager-an-open-ended-embodied-agent-with-large.md)
- [AesCode: Aesthetic Code Generation with Decoupled Cross-Modal Rewards](https://refivu.com/en/papers/e713a54c-052c-45c2-b68e-1a4041440f7a-aescode-aesthetic-code-generation-with-decoupled-cross-modal.md)
- [Flow Straight and Fast: Learning to Generate and Transfer Data with Rectified Flow](https://refivu.com/en/papers/a0c4439d-88d7-4d0f-be30-5509d158003e-flow-straight-and-fast-learning-to-generate-and.md)
- [Photorealistic Text-to-Image Diffusion Models with Deep Language Understanding](https://refivu.com/en/papers/eaa0c3ba-e0e4-4517-8ef7-d6ec6ba261b6-photorealistic-text-to-image-diffusion-models-with-deep.md)
- [Let's Verify Step by Step](https://refivu.com/en/papers/389050a4-3045-4cce-994c-b4c5da04031a-let-s-verify-step-by-step.md)
- [InfiniSplat v2: Analyzing and Improving Feed-Forward 3DGS from Any Views](https://refivu.com/en/papers/4de463d3-264b-4bb9-bb04-8ef641faec5e-infinisplat-v2-analyzing-and-improving-feed-forward-3dgs.md)
- [Consistency Models](https://refivu.com/en/papers/f97e5129-1522-4b93-9b60-0a1f3af22d42-consistency-models.md)
- [wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations](https://refivu.com/en/papers/084e48fc-2ff1-4e6f-a703-2575f966a7bc-wav2vec-2-0-a-framework-for-self-supervised.md)

## Terms in this paper

- [Large language models](https://refivu.com/en/terms/f2404476b183-large-language-models)
- [deduplication](https://refivu.com/en/terms/7e43208183ba-deduplication)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/c1ac9468-9718-49de-bad2-4505803dee02-saber-a-sql-compatible-semantic-document-processing-system)
