Retrieval and Rewriting Separation: A Practical Guide to AI Q&A Systems

    This guide explains why separating retrieval from rewriting produces more reliable AI Q&A systems than a single general-purpose model. It breaks down measurable capability targets, a three-layer architecture (retrieval, generation, orchestration), key retrieval and generation practices, engineering and cost controls, and a dual-track evaluation method for building factually grounded, style-controlled content pipelines.

    1. The Problem: Why One Model Cannot Do Everything

    In real-world AI Q&A and content production, many teams start by picking a single general-purpose chat model and handing it retrieval, summarization, and rewriting all at once. This works in a demo, but problems surface quickly in production: stale answers, unverifiable sources, drifting tone, and loose structure in long-form output.

    The root cause is that retrieval and generation are fundamentally different tasks. Retrieval cares about recall, source credibility, and freshness. Generation cares about language organization, logical flow, and style consistency. Forcing both into a single inference pass makes the model juggle conflicting goals within limited context and attention, so it does neither well.

    The more engineering-sound approach is to split the capabilities: let retrieval find trustworthy material, let generation turn that material into the target style, and use an orchestration layer in between to validate and pass data along. This aligns with the widely accepted Retrieval-Augmented Generation (RAG) direction. This article takes it further, down to the concrete implementation of a two-stage separation between retrieval and rewriting.

    2. Breaking Down Capabilities into Measurable Metrics

    Arguing about which tool is “better” is not engineering-useful. You first need to abstract it into testable capability items:

    • Factual accuracy: whether key conclusions in the answer are supported by the retrieved material.
    • Source verifiability: whether traceable citations are provided for manual review.
    • Freshness: whether recent information can be reached, rather than relying only on historical knowledge in the model’s parameters.
    • Style control: whether it can reliably produce different formats such as explainer articles, Q&A pieces, podcast scripts, and long community posts.
    • Long-form structural stability: staying clearly structured, non-repetitive, and on-topic across thousands of words.
    • Operational maintainability: whether logging, monitoring and alerting, rate limiting, and cost control are available.

    Use these six items as the acceptance baseline. Every architecture decision afterward revolves around them, avoiding subjective preference debates.

    3. Reference Architecture: A Three-Layer Decoupled Q&A Pipeline

    The recommended structure is a three-layer design: retrieval layer, generation layer, and orchestration layer.

    The retrieval layer handles query rewriting, multi-path recall, reranking, and snippet trimming, and outputs a structured evidence package. The generation layer has two roles: one produces a grounded answer based on the material, and the other rewrites the answer or material into a specified format. The orchestration layer handles flow control, quality gates, and fallback strategies.

    A schematic data structure looks like this (pseudocode, expressing the contract only, not pointing to any specific interface):

    1. @dataclass
    2. class Evidence:
    3. text: str
    4. source: str
    5. published_at: str
    6. score: float
    7. @dataclass
    8. class Draft:
    9. answer: str
    10. citations: list[str]
    11. missing: list[str] # sub-questions not covered by the material

    The retrieval layer exposes only list[Evidence] upward, and the generation layer consumes only Evidence downward. This contract-based design lets the two layers be replaced and evaluated independently.

    4. Retrieval Layer: It Sets the Ceiling for Answer Quality

    First, query rewriting. Colloquial user questions often contain references and omissions, so you need to normalize them first, split out multiple sub-queries, and cover both “what is it” and “how to do it” intents.

    Second, multi-path recall and fusion. Run keyword retrieval and semantic vector retrieval in parallel, then deduplicate and fuse the results with a combined ranking. This significantly reduces missed recall from any single path.

    Third, reranking and trimming. Rerank candidate snippets by relevance, keep only highly relevant passages, and control the length of injected context to reduce noise.

    Fourth, source tiering. Classify material by credibility (for example, official docs, authoritative media, ordinary community content), and state clearly in the prompt that “low-credibility sources are background only and must not be used as a basis for conclusions.”

    Fifth, empty-result handling. When recall is empty or overall relevance is low, explicitly return “insufficient material” instead of letting the model improvise. This is the most effective step for suppressing hallucination.

    5. Generation Layer: Answering and Rewriting Must Be Separate

    The answering stage uses constrained generation: the model may only answer based on the material, with a citation number after each key conclusion. Parts not covered by the material go into the missing list, and the upper layer decides whether to run additional retrieval.

    The rewriting stage does not add any facts at all; it only converts expression. An example prompt contract:

    1. Role: text rewriter
    2. Input: a list of verified factual points
    3. Constraints:
    4. 1. Do not add, remove, or modify any factual information;
    5. 2. Output format = {explainer | Q&A | podcast script | long community post};
    6. 3. Target word count and paragraph count: {n};
    7. 4. Preserve all citation number positions.

    Separating “facts” from “expression” makes things traceable: if a reader points out a wording problem, you only rerun the rewrite; if they point out a factual problem, you go back to the retrieval layer to gather more evidence. The two debugging paths do not contaminate each other.

    6. Orchestration Layer and Engineering Support

    The orchestration layer needs to do four things: flow orchestration (retrieve -> answer -> validate -> rewrite), quality gates (citation coverage, word count, banned-phrase checks), fallback strategy (switch to “answer only from existing material with explicitly stated limitations” when retrieval fails), and full-chain logging and monitoring/alerting to help pinpoint whether the issue is in recall or generation.

    For cost control, use a tiered model strategy: lightweight models for intent recognition and query rewriting, and more capable models for long-form rewriting. Also cache results for repeated questions and reuse vectorized material snippets.

    A minimal runnable skeleton:

    1. def pipeline(q, style):
    2. ev = retrieve(rewrite(q)) # retrieval layer
    3. if not ev:
    4. return fallback(q) # explicit fallback
    5. draft = answer_with_citations(ev) # generation layer - answer
    6. if draft.missing:
    7. ev += retrieve(draft.missing) # second retrieval
    8. draft = answer_with_citations(ev)
    9. return rewrite_as(draft, style) # generation layer - rewrite

    7. Evaluation: Dual-Track Validation with Offline Sets and Online Metrics

    On the offline side, build an evaluation set covering factual, freshness-sensitive, long-form, and refusal cases, and measure citation accuracy, freshness hit rate, structural compliance rate, and the correct-refusal rate when material is insufficient. On the online side, observe human adoption rate, follow-up question rate, and complaint rate. Running both tracks in parallel avoids inflated offline scores.

    It is worth stressing that any conclusion like “tool X is stronger at retrieval, tool Y is stronger at rewriting” depends heavily on version and scenario. The safer engineering assumption is that capabilities keep changing, so the architecture should stay replaceable. If an organization wants to build this pipeline within its own data and compliance boundaries, it can build on general cloud product capabilities such as object storage, message queues, container platforms, logging services, and monitoring/alerting from Baidu AI Cloud, thereby decoupling model selection from the workflow and keeping the system evolvable over the long term.