HeadlinesBriefing favicon HeadlinesBriefing.com

Dispatcher‑Based Prompt Assembly for Enterprise RAG

Towards Data Science •
×

The article explains how Enterprise Document Intelligence builds a RAG system from four bricks: document parsing, question parsing, retrieval, and generation. The current piece focuses on the generation brick, detailing how a dispatcher turns a Parsed Question into a typed LLM call.

A dispatcher pulls the expected answer shape from the ANSWER_REGISTRY, selects a matching schema, and stitches a system prompt from a fixed BASE plus shape‑specific fragments. It then passes a user prompt that merges the original question, keywords, and retrieved passage lines.

Adding a new answer shape requires only one fragment, keeping token usage low and making the prompt easier to debug. The approach eliminates the monolithic mega‑prompt that grows conditional clauses for every format, which can confuse downstream debugging and inflate context length.

By keeping the prompt assembly modular, the system preserves a clean audit trail: the dispatcher records the full raw response on a trace and returns a typed result. This design scales as new document types and answer shapes appear, making the architecture stable for enterprise workloads.