Back to projects
01 · Agents & RAGDSPY · OPT
2026
v0 · Manual Prompt
Macro-F1 0.76
v4 · DSPy / TextGrad
Macro-F1 0.89 +13%

Automated Prompt Optimization for AI Agents (DSPy GEPA & TextGrad)

Replacing fragile manual prompt crafting with data-driven prompt compilation (DSPy GEPA, TextGrad), MLflow experiment tracking, confusion matrices, and temperature stability testing.

Impact:Measurable routing & multi-label F1 gains on held-out sets · Full MLflow lineage

01 · Context & Problem

In multi-topic classification and intent routing systems, hand-written prompts silently regress across model updates and struggle on ambiguous boundaries between search and summarization.

02 · Technical Approach

Formulated routing and classification steps as optimizable programs using DSPy GEPA and TextGrad textual gradients. Tracked every prompt candidate, textual critique, Macro-F1 score, and confusion matrix in MLflow with strict held-out re-evaluation.

03 · Measurable Outcomes

Delivered reproducible gains on previously confused classes, cleanly separated annotation noise from model errors, and shipped a reusable optimization toolkit.

Tech Stack

DSPyTextGradMLflowLLM AgentsPythonscikit-learn