LLM-Driven Online Aggregation for Unstructured Text Analytics

Chao Hui, Weizheng Lu, Yanjie Gao, Liping Xiong, Yunhai Wang, Yueguo Chen

Abstract

Large Language Models (LLMs) exhibit strong capabilities in text processing, and recent research has augmented SQL and DataFrame with LLM-powered semantic operators for data analysis. However, LLM-based data processing is hindered by slower token generation speeds compared to relational queries. To enhance real-time responsiveness, we propose OLLA, an LLM-driven online aggregation framework that accelerates semantic processing within relational queries. In contrast to batch-processing systems that yield results only after the entire dataset is processed, our approach incrementally transforms text into a structured data stream and applies online aggregation to provide progressive output. To enhance our online aggregation process, we introduce a semantic stratified sampling approach that improves data selection and expedites convergence to the ground truth. Evaluations show that OLLA reaches 1% accuracy error bound compared with labeled ground truth using less than 4% of the full-data time. It achieves speedups ranging from 1.6$\times$ to 38$\times$ across diverse domains.

Introduction

Data scientists increasingly seek to treat unstructured text like a relational database, using SQL-like queries to extract insights—for example, calculating the average price mentioned across thousands of invoices. While Large Language Models (LLMs) excel at parsing text into structured data, their inference speed is significantly slower than traditional database engines. Processing massive datasets row-by-row can take hours, whereas standard SQL queries take seconds. This performance gap makes interactive data exploration nearly impossible.

Current systems typically rely on batch processing, forcing users to wait for the entire dataset to be processed before seeing any results. OLLA (Online Large Language model Aggregator) addresses this by providing progressive, approximate results that refine over time, enabling real-time interactivity.

The OLLA Framework

OLLA integrates three main components to bridge the gap between slow LLM inference and fast relational queries.

The OLLA system architecture, showing the flow from unstructured data through semantic sampling and LLM processing to online aggregation and the user interface.

1. Online Aggregation (OLA)

Instead of waiting for a batch job to finish, OLLA treats data as a stream. It provides a running estimate of the answer along with a confidence interval (e.g., "The average is 3.65 ± 0.08"), allowing users to monitor the query's progress and stop early if the desired precision is reached.

2. Semantic Stratified Sampling

To achieve high accuracy quickly, random sampling is often insufficient. OLLA uses a small, fast embedding model to map text into a vector space and clusters them using K-means. It then samples from these clusters (strata) using Neyman Allocation, which prioritizes groups with higher internal variety to reduce overall statistical variance.

3. Adaptive Adjustment

Since initial embedding-based clusters may not perfectly align with the LLM’s logic, OLLA includes a feedback loop. As the LLM processes samples, the system identifies "misclustered" items or high-variance groups and dynamically adjusts clusters to better match the LLM’s actual output.

Querying Unstructured Data

OLLA supports various semantic operators within standard SQL queries, allowing users to perform complex analytics on unstructured columns.

Examples of SQL queries (Q1, Q2, Q3) using LLM-powered semantic operators for aggregation, filtering, and grouping.

As shown in the figure above, OLLA can handle:

  • Aggregation (Q1): Extracting and averaging numerical values (e.g., prices) from documents.
  • Filtering (Q2): Using LLMs in WHERE clauses to filter rows based on semantic properties (e.g., sentiment).
  • Grouping (Q3): Categorizing data based on LLM-generated labels.

Evaluation and Results

The framework was evaluated across diverse datasets, including company documents, BBC news articles, arXiv abstracts, and Amazon reviews.

  • Efficiency: OLLA reaches a 1% absolute error bound while processing less than 4% of the total data.
  • Speedups: Compared to full-data batch processing, OLLA achieved speedups between 1.6× and 38× to reach a 5% error bound.
  • Filtering Performance: In WHERE clause scenarios, semantic sampling was significantly faster at finding valid samples than random sampling, reaching target error bounds in roughly half the time.

Conclusion

OLLA demonstrates that semantic stratified sampling and online aggregation can significantly accelerate LLM-based text analytics. By using embeddings as a cheap proxy for data organization and refining results progressively, it enables interactive exploration of massive unstructured datasets. Future work will explore automated hyper-parameter tuning and applying these techniques to more complex multi-step reasoning pipelines.

Summary updated

Abstract

Large Language Models (LLMs) exhibit strong capabilities in text processing, and recent research has augmented SQL and DataFrame with LLM-powered semantic operators for data analysis. However, LLM-based data processing is hindered by slower token generation speeds compared to relational queries. To enhance real-time responsiveness, we propose OLLA, an LLM-driven online aggregation framework that accelerates semantic processing within relational queries. In contrast to batch-processing systems that yield results only after the entire dataset is processed, our approach incrementally transforms text into a structured data stream and applies online aggregation to provide progressive output. To enhance our online aggregation process, we introduce a semantic stratified sampling approach that improves data selection and expedites convergence to the ground truth. Evaluations show that OLLA reaches 1% accuracy error bound compared with labeled ground truth using less than 4% of the full-data time. It achieves speedups ranging from 1.6$\times$ to 38$\times$ across diverse domains, measured by comparing the time to reach a 5% error bound with that of full-data time. We release our code at https://github.com/olla-project/llm-online-agg.git.
BibTeX
@misc{hui2026llm,
  author = {Chao Hui and Weizheng Lu and Yanjie Gao and Liping Xiong and Yunhai Wang and Yueguo Chen},
  title = {{LLM-Driven Online Aggregation for Unstructured Text Analytics}},
  year = {2026},
  eprint = {2603.08443},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.08443},
}

Loading related content...

Figure