How a modular, Apache-licensed Python library is turning a fragmented research landscape into something you can actually use.


If you have spent any time optimizing prompts for large language models, you know the drill. You read a promising paper—OPRO, EvoPrompt, CAPO—track down the GitHub repo, and discover it's a single-author codebase last updated 14 months ago. The dependencies conflict with your Python environment. The task setup is hard-coded to three classification benchmarks. The LLM interface assumes one specific API format. Swapping in a different model requires rewriting half the code.

This is the state of prompt optimization research in 2026: a landscape of isolated, unmaintained repositories, each implementing one algorithm, each with its own conventions, each requiring significant effort to adapt to real use cases. A new framework called promptolution aims to fix that.

Presented as a demo paper at EACL 2026 and described in arXiv paper 2512.02840, promptolution provides a single, modular API that unifies multiple discrete prompt optimization algorithms behind a common interface. It's pip-installable, Apache 2.0 licensed, and built to serve both practitioners who want better prompts and researchers who want reproducible benchmarks.

The Problem: Prompt Optimization Is Fragmented

Prompt optimization—the systematic search for better instructions and few-shot examples for LLMs—has produced real results. The research literature now includes dozens of approaches, from evolutionary methods to gradient-free optimization to LLM-as-optimizer strategies.

But the practical picture is messy. Each optimizer typically lives in its own repository, maintained (or not) by the original paper's authors. Comparing two optimizers means juggling two different codebases with conflicting requirements. Adapting an optimizer to a new task or LLM often requires rewriting core components. And most implementations target simple classification tasks with limited LLM support.

The closed-source options aren't much better. Amazon Bedrock's Prompt Engineering Playground, Anthropic's Claude Prompt Tools, and Google's Vertex AI Prompt Optimizer are all vendor-locked. They optimize prompts for one provider's models, and you can't inspect or modify the optimization process.

Existing open-source frameworks have gaps too. DSPy, the most popular framework in the space, takes a high-level, monolithic approach—it embeds prompt optimization within a larger pipeline compilation procedure. It works well if you're building your entire application inside DSPy, but extracting the optimized prompt for use elsewhere is non-trivial. TextGrad, AdalFlow, and PromptWizard each implement a single optimizer, limiting comparative studies. CoolPrompt emphasizes zero-configuration convenience over fine-grained control.

promptolution occupies a distinct niche: it focuses exclusively on prompt optimization, offers multiple optimizers behind a unified interface, operates at a low abstraction level for full control, and returns framework-agnostic prompt strings that slot into any LLM pipeline.

How the Unified API Works

promptolution is built around four core components, each defined by a base class with a clear interface:

1. LLM

The LLM component handles inference. It provides a unified interface for obtaining responses from any language model, with built-in parallelization and token usage tracking. Three implementations ship with the framework:

  • APILLM: Calls LLMs hosted via APIs (OpenAI, Anthropic, DeepInfra, and any OpenAI-compatible endpoint).
  • LocalLLM: Runs models locally through the HuggingFace transformers library.
  • VLLM: Integrates the vllm library for high-throughput inference on GPU clusters.

All three share the same interface. Swapping from a local model to an API-backed model is a configuration change, not a code rewrite.

2. Predictor

The Predictor component defines how to extract structured answers from LLM output. Two implementations are provided:

  • FirstOccurrencePredictor: Scans the response for the first occurrence of any valid class label—simple but brittle.
  • MarkerBasedPredictor: Extracts answers between predefined HTML-like markers (e.g., <finalanswer>...</finalanswer>), which is more robust for generative tasks.

This separation matters. Most prompt optimization research assumes classification tasks with clean labels. promptolution's Predictor abstraction makes it straightforward to handle open-ended generation, math reasoning, and other formats where the answer is buried in a longer response.

3. Task

The Task component manages datasets, evaluation metrics, and subsampling. Three task types are supported:

  • ClassificationTask: Standard classification with accuracy, F1, and other discrete metrics. Created directly from a Pandas DataFrame.
  • JudgeTask: Uses an LLM-as-a-judge to score output quality, enabling optimization for subjective or creative tasks. Ground-truth labels are optional.
  • RewardTask: Optimizes against a custom reward function—code execution time, business metrics, or any measurable objective you define.

The subsampling system is particularly important for efficiency. Evaluating every candidate prompt on a full dataset is expensive. promptolution supports random subsampling, block slicing, and full evaluation, and this is handled within the Task component rather than being an afterthought.

4. Optimizer

The Optimizer component ties everything together. It uses a Predictor and a Task to evaluate prompts, and iteratively refines them according to the chosen algorithm. Four optimizers are currently implemented:

Optimizer Strategy Init Prompts Exploration Cost Parallelizable Few-shot
CAPO Cost-Aware Prompt Optimization (GA-based, AutoML techniques) Required High Low Yes Yes
EvoPromptDE Differential evolution with LLM crossover Required High High Yes No
EvoPromptGA Genetic algorithm with LLM mutation Required High High Yes No
OPRO LLM-as-optimizer (propose, evaluate, refine) Optional Low High No No

CAPO is the newest and most capable of the four—it jointly optimizes instructions and few-shot examples while being cost-efficient. OPRO is the simplest to start with but doesn't parallelize well. EvoPrompt's two variants offer good exploration through evolutionary search but at higher token cost.

Adding a new optimizer requires inheriting from the base class and implementing a single _step() method that defines one iteration of the optimization loop. The framework handles evaluation, logging, caching, and parallelization automatically.

A Fifth Component: ExperimentConfig

For researchers running systematic experiments, promptolution provides an ExperimentConfig class that parameterizes all four components in a single object. This makes it straightforward to define large-scale benchmark studies—varying optimizers, datasets, models, and hyperparameters—in a reproducible way.

The framework ships with configuration files for 8 standard NLP datasets, covering classification, generation, and reasoning tasks. Combined with built-in response caching and token tracking, this makes promptolution a practical tool for the kind of rigorous comparative studies that the field needs but rarely sees, because the effort of harmonizing different codebases is too high.

Practical Usage

Getting started takes about five lines of code. Install the package:

pip install promptolution[api]

For local inference, add transformers or vllm extras. Then:

import pandas as pd
from promptolution.utils import ExperimentConfig
from promptolution.helpers import run_experiment

df = pd.read_csv("your_data.csv")

config = ExperimentConfig(
    optimizer="capo",
    task_description="Classify each sentence as subjective or objective.",
    prompts=["Classify the text as objective or subjective."],
    n_steps=10,
    api_url="https://api.openai.com/v1",
    model_id="gpt-4o-mini",
    api_key="YOUR_API_KEY",
)

best_prompts = run_experiment(df, config)
print(best_prompts)

That's it. You provide a DataFrame with input and label columns, a task description, and one or more initial prompts. The framework handles the rest—evaluation, optimization, logging—and returns the optimized prompt strings.

For more control, you can compose the components directly:

from promptolution.llms import APILLM
from promptolution.predictors import MarkerBasedPredictor
from promptolution.tasks import ClassificationTask
from promptolution.optimizers import CAPO

llm = APILLM(
    api_url="api.deepinfra.com/v1/...",
    model_id="google/gemma-3-27b-it",
    api_key="...",
)

predictor = MarkerBasedPredictor(labels=["positive", "negative"])
task = ClassificationTask(
    data=df,
    description="Classify the sentiment of each review.",
    predictor=predictor,
    metric="accuracy",
)

optimizer = CAPO(
    llm=llm,
    task=task,
    predictor=predictor,
    prompts=["Classify the sentiment."],
    n_steps=12,
)

optimizer.optimize()

The component-based approach means you can swap any piece. Want to use CAPO with a local model instead of an API? Change the llm parameter. Want a custom reward function? Use RewardTask. Want to try OPRO instead of CAPO? Change one string.

Why a Unified Framework Matters

The value of unification isn't just convenience. It's scientific credibility.

When each optimizer exists in its own codebase with its own evaluation setup, its own data splits, and its own LLM interface, comparing results across papers is unreliable. A 3-point accuracy difference might reflect genuine algorithmic improvement—or it might reflect different subsampling strategies, different prompt formatting, or different ways of extracting answers from model output.

promptolution addresses this by ensuring that every optimizer runs under identical conditions: the same LLM interface, the same Predictor, the same Task, the same subsampling, the same evaluation. The only variable is the optimization algorithm itself.

This matters for practitioners too. If you're trying to figure out which optimizer works best for your task, you shouldn't have to learn four different codebases and reconcile four different evaluation methodologies. With promptolution, switching from OPRO to CAPO is a one-line change, and the results are directly comparable.

The built-in response caching also serves a dual purpose. It saves money during development—you're not re-evaluating the same prompt on the same data twice—and it ensures reproducibility, since cached results are deterministic.

Evaluation Results

The paper demonstrates that promptolution's implementations are competitive with the original authors' code. Across 8 datasets and multiple LLMs, optimized prompts consistently outperform unoptimized baselines—sometimes dramatically. On GSM8K with Llama-3.3-70B, two semantically similar prompts yield 37.6% vs 53.8% accuracy, illustrating how much room there is for optimization even before algorithmic search begins.

CAPO generally achieves the best results among the implemented optimizers, which is expected since it's the most recent method and incorporates AutoML techniques like cost-aware stopping and joint instruction-plus-examples optimization.

What promptolution Is Not

The paper is clear about the framework's scope, and it's worth echoing: promptolution is not an end-to-end LLM application framework. It doesn't build pipelines, manage agents, or orchestrate multi-step workflows. If you want to compile a RAG pipeline with prompt optimization baked in, use DSPy. If you want to optimize a prompt and then use it in your own application—any application—promptolution is designed for that.

The framework also focuses on discrete prompt optimization, not continuous methods. Continuous prompt optimization (learning soft token embeddings) requires gradient access to model internals, which is incompatible with black-box API-based LLMs. Since one of promptolution's core design goals is LLM agnosticism, discrete optimization is the natural choice.

Extensibility

The base-class architecture makes promptolution extensible in ways that go beyond just adding new optimizers:

  • Custom LLM backends: Inherit from BaseLLM to wrap any inference provider.
  • Custom predictors: Inherit from BasePredictor to handle novel output formats.
  • Custom tasks: Inherit from BaseTask to define new evaluation protocols.
  • Custom optimizers: Inherit from BaseOptimizer and implement _step().

The framework also supports callbacks and detailed logging, which means you can track optimization trajectories, token consumption, and intermediate results without modifying the core code.

The Broader Context

promptolution arrives at a time when prompt optimization is becoming practically important. Multi-agent systems increasingly need LLMs that are specialized for individual tasks. Fine-tuning a model for each agent is expensive; optimizing the prompt is cheap and often sufficient. As the paper notes, prompt optimization is analogous to hyperparameter tuning in classical ML—a lightweight but high-leverage intervention.

The framework also sits within a broader AutoML tradition. One of the authors, Matthias Feurer, co-authored the AutoML book. CAPO itself draws on AutoML techniques like multi-fidelity evaluation and cost-aware termination. promptolution extends this philosophy to the prompt optimization domain: automate the tedious search, make the results reproducible, and give researchers the tools to compare methods fairly.

Getting Started

The framework is developed by Tom Zehle (ELLIS Institute / University of Freiburg), Timo Heiß (LMU Munich / MCML), Moritz Schlager (MCML / TU Munich), Matthias Aßenmacher (LMU Munich / MCML), and Matthias Feurer (TU Dortmund / Lamarr Institute). Contributions are welcome, and the codebase includes CI, documentation, and testing infrastructure that's rare for academic software.


If you've been meaning to experiment with prompt optimization but kept putting it off because the tooling was too fragmented, promptolution removes that excuse. One install, one API, four optimizers, and a framework designed to let you compare them fairly. That's progress.