Skip to main content

lotus

Project description

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).
  • Deep research & synthesis — fan out over a corpus, extract, and synthesize.
  • Agent-trace failure analysis — mine large volumes of agent logs for failure modes.
  • Document extraction & unstructured analysis — structured fields and insights from text.
  • LLM-judge evals & RAG — declarative pipelines that the engine optimizes for you.

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.

On macOS with pip, install FAISS via conda: conda install -c pytorch faiss-cpu=1.8.0 (uv handles this automatically). See the docs for GPU and troubleshooting details.

Quickstart

Give LOTUS a corpus and a task. It allows you to run parallel agent and LLM calls. Below we show an example of an agentic map reduce, allowing you to bulk process code files by automatically sharding the corpus, spawning an agent per shard in parallel (each with a sandboxed Python REPL), and reducing the results into one answer.

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

# Configure the LM — export your API key first (e.g. OPENAI_API_KEY)
lotus.settings.configure(lm=LM(model="gpt-4o-mini"))

# A corpus can be files, documents, DataFrame rows, or one large text
corpus = lotus.Corpus.from_files("myproject/**/*.py")

# One task. LOTUS derives the map + reduce, runs agents in parallel, and aggregates.
result = corpus.agentic_map_reduce(
    task="For each file, find security-sensitive code and summarize the risks with "
         "file:line. Then produce one prioritized report across the codebase.",
    tools=[PythonREPLTool()],
)

print(result.output)     # the reduced report
print(result.findings)   # per-file findings
print(result.usage)      # token usage

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

How it works

You express what you want over a corpus 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

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

See the documentation and the intro Colab tutorial for more on semantic operators that LOTUS serves.

Docs

Full documentation at lotus-ai.readthedocs.io. Key sections:

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

Contributions welcome! Read the Contributing Guide and check existing issues before opening a PR. 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},
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lotus_ai-1.2.3.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lotus_ai-1.2.3-py3-none-any.whl (176.6 kB view details)

Uploaded Python 3

File details

Details for the file lotus_ai-1.2.3.tar.gz.

File metadata

  • Download URL: lotus_ai-1.2.3.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for lotus_ai-1.2.3.tar.gz
Algorithm Hash digest
SHA256 9116611c27d86e768cecff3e206ee9724e3c32befe440346af431c31c5640871
MD5 f258c35fbc6d7f51d086d7f1256c96e0
BLAKE2b-256 85943eb40da44fe1d37aa84bb0ad4426dc732db1eed0b8f4177b05c7a4c76315

See more details on using hashes here.

File details

Details for the file lotus_ai-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: lotus_ai-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 176.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for lotus_ai-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4b8c99879bd57e83a7df6d184a50e195282ee9421a4bf65c39e75146467689fd
MD5 da22989a8d6d299c1cf53b02992621c7
BLAKE2b-256 212cfc699edfc89360a5af080ca578c5f1e37226bfced20b67e4171a51e66385

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page