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.
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.