MOAR Optimizer
The MOAR (Multi-Objective Agentic Rewrites) optimizer explores different ways to optimize your pipeline, finding solutions that balance accuracy and cost.
What is MOAR?
When optimizing pipelines, you trade off cost and accuracy. MOAR explores many different pipeline configurations (like changing models, adding validation steps, combining operations, etc.) and evaluates each one to find the best trade-offs. It returns a frontier of plans that balance cost and accuracy, giving you multiple optimized options to choose from based on your budget and accuracy requirements.
Quick Navigation
- Getting Started - Step-by-step guide to run your first MOAR optimization
- Configuration - Complete reference for all configuration options
- Evaluation Functions - How to write and use evaluation functions
- Understanding Results - What MOAR outputs and how to interpret it
- Examples - Complete working examples
- Troubleshooting - Common issues and solutions
When to Use MOAR
Good for
- Finding cost-accuracy trade-offs across different models
- When you want multiple optimization options to choose from
- Custom evaluation metrics specific to your use case
- Exploring different pipeline configurations automatically
Basic Workflow
- Create your pipeline — Define your DocETL pipeline in Python or YAML
- Write an evaluation function — Create a Python function to measure accuracy
-
Run optimization — Call
frame.optimize()with your eval function:optimized = frame.optimize(eval_fn=evaluate, metric_key="score")Or via CLI:
docetl build pipeline.yaml -
Review results — Run the optimized pipeline, or browse the cost-accuracy frontier:
rows = optimized.collect() # Execute the optimized pipeline results = optimized.search_results best = results.best() # Highest accuracy cheap = results.cheapest() # Lowest cost print(results.to_df()) # All explored plans
Ready to get started? Head to the Getting Started guide.