Separating Retrieval from Rewriting: A Practical Guide to AI Q&A Engineering

    This article explains why retrieval and rewriting should be handled as separate stages in an AI question-answering system. It covers the reference data flow, key practices on the retrieval side (query expansion, multi-source recall, reranking, source trust tiers, and freshness), and rewriting techniques such as numbered evidence, structured prompts, and style control. It also lists evaluation metrics, common pitfalls, and fallback strategies for building a reliable Q&A pipeline.

    1. The Real Requirement: What Users Want Is “What + How”

    In real-world question-answering scenarios, most questions do not require complex causal reasoning. They fall into two categories: clear facts (what) and actionable steps (how). This means the system’s first priority is not “reasoning ability” but finding accurate, complete, and up-to-date information.

    When retrieval and generation are handled by a single model, two typical problems appear: sources cannot be verified, and writing style cannot be controlled. A more reliable engineering approach is to separate responsibilities—retrieval provides evidence, and generation handles expression.

    2. Why Retrieval and Rewriting Should Be Separated

    2.1 Retrieval Is an Evidence Problem

    Retrieval quality depends on three things: corpus coverage, recall and ranking strategy, and source credibility tiers. It requires ongoing investment, including index update frequency, whitelists for sites and data sources, and freshness weighting. None of these can be solved by model parameters alone.

    2.2 Rewriting Is an Expression Problem

    Rewriting focuses on structure, tone, terminology density, and audience fit—for example, turning the same material into an interview piece, a Q&A article, a popular science post, or a long community post. It relies on long-context understanding, instruction following, and style transfer.

    2.3 Benefits of Separation

    • Replaceable: the retrieval side and the generation side can be upgraded independently.
    • Auditable: every conclusion can be traced back to a specific evidence snippet.
    • Cost-controlled: short-context retrieval plus long-context rewriting avoids stuffing in excessive noise at once.

    3. Reference Architecture and Data Flow

    1. User question
    2. -> Query understanding (rewriting / decomposition / intent recognition)
    3. -> Retrieval (multi-source recall + reranking + credibility filtering)
    4. -> Evidence assembly (deduplication, trimming, source labeling)
    5. -> Generation (constrained writing + citation)
    6. -> Validation (factual consistency / coverage / refusal policy)
    7. -> Output

    The key engineering point is evidence assembly: assign a stable ID to each piece of material, require the model to cite those IDs in its output, and explicitly state when a key question is not covered instead of letting the model improvise.

    4. Retrieval-Side Practices

    1. Query rewriting: expand a conversational question into several search queries that cover synonyms and broader/narrower concepts.
    2. Multi-path recall: run keyword retrieval and vector retrieval in parallel. The former handles proper nouns well; the latter handles semantic similarity.
    3. Reranking: score candidate snippets with a cross-encoder, prioritizing conclusion sentences and step sentences.
    4. Credibility tiers: handle official documentation, authoritative media, and personal experience at different levels. When they conflict, higher-credibility sources take priority and the disagreement is noted.
    5. Freshness handling: increase the freshness weight for questions about version numbers, prices, and policies.

    Illustrative code (pseudo-implementation, showing the flow only):

    1. def retrieve(query, top_k=8):
    2. queries = expand(query) # Query expansion
    3. cands = bm25(queries) + vector(queries) # Multi-path recall
    4. cands = dedup(cands)
    5. ranked = rerank(query, cands)[:top_k] # Reranking
    6. return [c for c in ranked if c.trust >= 0.6] # Credibility filtering

    5. Rewriting-Side Practices

    After numbering the evidence, constrain the output with a structured prompt:

    1. You are a technical writer. Use only the given material; do not introduce outside knowledge.
    2. Material: [1] ... [2] ...
    3. Requirements:
    4. 1) Cite the ID after each conclusion;
    5. 2) If the material is insufficient, output "insufficient information" and state what else needs to be retrieved;
    6. 3) Target style: popular science article; explain a term in one sentence the first time it appears;
    7. 4) Structure: conclusion first -> point-by-point argument -> action checklist.

    Style differences are controlled through three things—a structure template, sentence-length constraints, and a glossary—which is far more stable than simply writing “make it more professional.” If multiple styles are needed, generate several versions in parallel from the same evidence set and then compare them for consistency.

    6. Quality Evaluation and Common Pitfalls

    • Metrics: citation coverage, factual consistency rate, step executability rate, and refusal accuracy.
    • Build a small regression set and run it every time the model or prompt changes.
    • Common pitfalls: noisy material leads to “confidently wrong answers”; information in the middle of a long context gets ignored (put key evidence at the beginning and end); over-citation hurts readability.
    • Fallback strategy: when confidence is low, split the answer into “known / unknown” sections and list suggested directions for additional retrieval.

    7. Conclusion

    “Retrieval is responsible for truth, rewriting is responsible for quality” is a robust principle for building question-answering systems. Splitting capabilities into independently evolving modules, combined with citation constraints and regression evaluation, balances effectiveness, cost, and maintainability. To further reduce the cost of building your own system, you can run index construction, task orchestration, and runtime observability on general cloud capabilities offered by Baidu AI Cloud (such as object storage, message queues, container platforms, log services, and monitoring alerts), and focus your effort on retrieval strategy and writing quality itself.