Skip to content

lotus-data/lotus

Repository files navigation

LOTUS logo

LOTUS: Optimized Agentic and LLM Bulk Processing

Bulk process your datasets with agents and LLMs at scale, with higher accuracy and lower cost.

From Stanford University and UC Berkeley

PyPI PyPI - Python Version Arxiv Documentation Status Discord Colab Demo

What is LOTUS?InstallQuickstartSemantic OperatorsCommunityDocsCite


What is LOTUS?

LOTUS makes agentic and LLM bulk processing fast, easy, and robust. It introduces and optimizes semantic operators (e.g., LLM-based map, reduce, filter primitives) to let you process your large datasets with LLMs and natural language instructions. LOTUS optimizes these operations to help you get higher accuracy and lower cost.

What you can build:

  • Agentic code processing — run a tool-using agent (with a sandboxed Python REPL) over every file, document, or record, then reduce to one answer (codebase analysis, security sweeps, migrations). [example]
  • Deep research & synthesis — fan out over a corpus, extract, and synthesize. [example, blog]
  • Agent-trace failure analysis — mine large volumes of agent logs for failure modes. [blog]
  • Document extraction & unstructured analysis — structured fields and insights from text. [example, blog]
  • LLM-judge evals — score model outputs, app responses, and content quality, row by row. [example, blog]
  • RAG — retrieve the relevant context and generate grounded answers over your data. [blog]

LOTUS stands for LLMs Over Text, Unstructured and Structured Data.

Installation

pip install lotus-ai

Or with uv: uv add lotus-ai. For the latest features, install from source: pip install git+https://github.com/lotus-data/lotus.git@main.

See the docs for more.

Quickstart

Give LOTUS a corpus and a task. It shards the corpus, spawns an agent per shard in parallel (each with a sandboxed Python REPL for exact computation), and reduces the per-shard findings into one answer. The example below is fully self-contained — set your API key, paste, and run.

import lotus
from lotus.models import LM
from lotus.tools import PythonREPLTool

# Configure the LM — export your API key first (e.g. export OPENAI_API_KEY=sk-...)
lotus.settings.configure(lm=LM(model="gpt-5", reasoning_effort="low"))

# A corpus can be inline documents, a DataFrame, files, or one large text.
# Here: a few small functions, some of them subtly buggy.
snippets = [
    "def average(nums): return sum(nums) / (len(nums) - 1)",
    "def word_count(s): return len(s.split())",
    "def percent(part, whole): return part / whole",
    "def reverse(s): return s[::-1]",
]
corpus = lotus.Corpus.from_documents(snippets)

# Each agent actually *runs* its function in a sandboxed REPL to find bugs —
# then LOTUS reduces the per-function results into one report.
result = corpus.agent(
    task="Test each function on example inputs and report which ones are buggy, "
         "with a counterexample for each bug.",
    ops=["map", "reduce"],       # compose agentic ops: map, filter, reduce
    tools=[PythonREPLTool()],
)

print(result.output)   # the reduced bug report

See the Agentic Map-Reduce docs and examples/agentic_map_reduce/ for more.

How it works

You express what you want over a dataset using high-level semantic operators (i.e., LLM-based map, reduce, filter); LOTUS' optimizer decides how to run it — batching calls, applying model cascades and proxies, and lazily planning the whole pipeline — for higher accuracy at lower cost.

LOTUS pipeline: Corpus → Declarative Programming → LOTUS Optimizer → Results

The Results: Across diverse tasks, LOTUS' optimized pipelines match or exceed the accuracy of high-quality baselines while running substantially faster and cheaper:

Results of LOTUS optimized pipelines

See the blog for the full results and further reading.

What are Semantic Operators

LOTUS introduced and optimizes semantic operators. Each operator implements an LLM-based transformation over your dataset, which you specify with a natural language instruction, and the operations can be transparently optimized. Here are a few examples:

Semantic operators: sem_map, sem_filter, sem_agg (reduce), and sem_join, each showing docs flowing through an LM to an output

LOTUS supports two classes of semantic operators, so you can match the execution style to the task:

  • Agentic operators run tool-using agents over a corpus (corpus.agent(ops=["map", "filter", "reduce"], ...)). They shine on complex or ambiguous tasks that benefit from multiple steps and tool calls — running code to compute exact values, parsing files, sweeping a codebase, or filtering with non-trivial judgment. See the runnable examples/agentic_map_reduce/ (an expense-report roll-up and a codebase sweep).

  • LLM operators (sem_map, sem_filter, sem_agg, sem_join, sem_extract, …) invoke far fewer model calls per record and are ideal for well-defined tasks — LLM-as-judge evaluations, document and attribute extraction, and unstructured data analysis at scale.

LOTUS optimizes semantic operators for higher accuracy and lower cost. See the blog for walkthrough examples, or the documentation and the intro Colab tutorial for more.

Docs

For more, you can checkout the official docs, which includes more on:

Community

Join us on Discord to ask questions and share what you're building.

Check out these awesome projects that are building with LOTUS:

  • MAP: Measuring Agents in Production — a large-scale empirical study of deployed LLM agent systems across many domains (UC Berkeley, Intesa Sanpaolo, UIUC, Stanford, IBM Research; ICML 2026).
  • VibeCheck — discovers and quantifies qualitative differences between LLMs (UC Berkeley; ICLR 2025).
  • DeepScholar — generative research synthesis over the scientific literature, competitive with OAI DR (Stanford, UC Berkeley).

Using LOTUS in your project? Reach out to @semantic_operators on discord if you'd like it featured.

Contributing

We welcome all contributions! Read the Contributing Guide. For trouble-shooting or feature requests, open an issue and we'll get to it promptly.

References

Follow @lianapatel_ on X for updates. If you find LOTUS or semantic operators useful, please cite:

@article{patel2025semanticoptimization,
    title = {Semantic Operators and Their Optimization: Enabling LLM-Based Data Processing with Accuracy Guarantees in LOTUS},
    author = {Patel, Liana and Jha, Siddharth and Pan, Melissa and Gupta, Harshit and Asawa, Parth and Guestrin, Carlos and Zaharia, Matei},
    year = {2025},
    journal = {Proc. VLDB Endow.},
    url = {https://doi.org/10.14778/3749646.3749685},
}
@article{patel2024semanticoperators,
    title={Semantic Operators: A Declarative Model for Rich, AI-based Analytics Over Text Data},
    author={Liana Patel and Siddharth Jha and Parth Asawa and Melissa Pan and Carlos Guestrin and Matei Zaharia},
    year={2024},
    eprint={2407.11418},
    url={https://arxiv.org/abs/2407.11418},
}
@article{patel2026ainative,
    title = {Towards AI-Native Data Systems with the Semantic Operator Model and LOTUS},
    author = {Patel, Liana and Guestrin, Carlos and Zaharia, Matei},
    year = {2026},
    journal = {IEEE Data Engineering Bulletin},
    url = {http://sites.computer.org/debull/A26mar/A26MAR-CD.pdf#page=61},
}

Packages

 
 
 

Contributors

Languages