Prompt to Audience

Senior AI Engineer · Elsewhen · 2025

A modular agentic RAG pipeline that translates plain-English queries into complex audience trees for a Big Six advertising agency.

Background

Defining an audience at the agency was a manual UI exercise. Analysts would drill through a deep directory tree of taxonomies, hunt for the relevant segments, and compose with Boolean logic - a process that routinely took several minutes per audience. It also demanded prior familiarity with the dataset. Anyone without that mental map risked picking a near-miss segment, or missing a relevant one entirely, and there was no easy way to know which had happened.

The ask was to collapse that workflow: let users describe an audience the way they’d describe it to a colleague - in natural language - and have the system do the discovery and composition for them, against the underlying data model.

Approach

The original prototype was a monolithic prompt: one large model call attempting to decompose the query, retrieve relevant attributes, and assemble the Boolean logic in a single pass. It broke on queries with nested logic and frequently hit context limits.

I redesigned it as a modular pipeline with post-RAG assembly:

Outcome

Query latency dropped by more than 50%. Queries that previously took around 60 seconds - often timing out or requiring retries for JSON formatting - now typically complete in under 15, and context-overflow failures on nested queries were eliminated. Improved modularity also allowed for much easier testing, and iteration on individual stages.