A Practical Guide to Retrieval and Rewriting for AI Question Answering
This guide explains how to build AI question answering systems by separating retrieval and reasoning from controlled rewriting. It covers the limitations of single-model approaches, a two-stage pipeline architecture, retrieval and deep reasoning practices, fact-preserving rewriting techniques, a three-layer evaluation framework, and engineering recommendations for deployment. Readers will learn how to create explainable, replaceable, and iteratively improvable QA systems without relying on a single black-box model.
1. Background: Why a Single Model Struggles to Be Both Accurate and Usable
In real-world intelligent question answering, user needs generally fall into two categories: What (what are the facts) and How (how to do it). Both demand answers that are clear and actionable, rather than staying at the conceptual level of Why. A single model that relies only on parametric memory tends to run into three typical problems:
- Knowledge staleness: Training data has a time boundary, so coverage of recent events, version changes, pricing policies, and other dynamic information is often insufficient.
- Factual hallucination: Without external evidence constraints, the model may generate plausible-sounding content that has no supporting source.
- Rigid expression style: Even when the facts are correct, the output format and tone may not fit the business context (such as ticket replies, technical documentation, or marketing copy).
The common industry approach is to split the capabilities: retrieval and reasoning handle “finding the right material,” while generation and rewriting handle “presenting it well.” This is an extension of the retrieval-augmented generation (RAG) idea and the mainstream engineering paradigm for building high-trust question answering systems today.
2. Overall Architecture: Dividing Responsibilities in a Two-Stage Pipeline
A two-stage pipeline of “retrieval-based QA + rewriting generation” is recommended, with clear responsibilities for each stage that can be replaced and evaluated independently.
Stage 1: Retrieval-Augmented Question Answering (Retrieval & Reasoning)
- Capability requirements: web retrieval, multi-source information aggregation, source credibility judgment, and deep reasoning chains.
- Output: a set of factual material with citations (key points, data, and text descriptions of reference links).
- Key metrics: recall, source accuracy, and timeliness.
Stage 2: Controlled Rewriting Generation (Controlled Rewriting)
- Capability requirements: long-text understanding, style transfer, structural reorganization, and terminology consistency.
- Output: the final response that matches the target style and format.
- Key metrics: fact preservation rate, style compliance, and readability score.
This split brings three engineering benefits: first, replaceability, since the retrieval layer and generation layer can be upgraded independently; second, auditability, since factual sources and expression results are separated for easier tracing; third, cost control, since different model tiers can be selected as needed, avoiding a high-cost configuration across the entire chain.
3. Stage 1 Practice: How to Obtain High-Quality Material
3.1 Retrieval Strategy
- Query rewriting: Rewrite the user’s colloquial question into multiple search queries covering synonyms and broader/narrower concepts.
- Multi-round retrieval: Start with broad recall, then perform a second, more precise retrieval based on the initial screening results.
- Source tiering: Give higher weight to authoritative institutions, official documentation, and first-hand data.
3.2 Deep Reasoning
Introduce reasoning steps on top of the retrieval results to cross-validate conflicting information. An illustrative prompt structure is shown below:
You are a rigorous research analysis assistant.Task: Answer the question based on the following retrieved snippets.Requirements:1) Use only the given snippets; do not introduce external knowledge;2) If snippets conflict, list the conflict points and explain the basis for your choice;3) Output structured key points and label each point with its corresponding snippet number.Retrieved snippets:[1] ...[2] ...
3.3 Structuring the Material
Organize the retrieval results into a unified structure for consumption by the second stage:
{"query": "the user's original question","facts": [{"point": "key point", "source_id": "1", "confidence": "high"}],"conflicts": []}
4. Stage 2 Practice: Key Points of Controlled Rewriting
4.1 Prioritize Fact Preservation
The first principle of rewriting is to not change the facts. The prompt should explicitly constrain this:
You are a text rewriting assistant.Input: structured material (JSON).Requirements:1) Do not add, delete, or modify any factual information;2) Organize the output as "conclusion first, itemized explanation, action recommendations";3) Target style: technical documentation, objective tone, consistent terminology.
4.2 Style and Structure Control
- Templated output: Predefine a section skeleton to reduce format drift.
- Terminology constraints: Maintain a unified terminology mapping to avoid mixing synonyms.
- Length and hierarchy: Specify word count ranges and the number of heading levels.
4.3 Quality Self-Check
After generation, add a self-check step to verify factual consistency and format compliance, triggering a rewrite when necessary.
5. Evaluation Framework: How to Judge “Usability”
A three-layer evaluation is recommended:
- Fact layer: fact preservation rate, source coverage rate, and conflict-handling accuracy.
- Expression layer: style compliance, structural completeness, and readability score.
- Business layer: first-time resolution rate, human adoption rate, and average handling time.
Maintain an offline evaluation set covering timeliness questions, multi-source conflict questions, and questions with strict format requirements, serving as a regression baseline for version iterations.
6. Engineering Implementation Recommendations
- Caching and reuse: Cache retrieval results for high-frequency queries to reduce latency and cost.
- Fallback strategy: When retrieval is unavailable, clearly communicate the information boundary to avoid fabrication.
- Observability: Log retrieval hits, before-and-after rewriting differences, and user feedback to form a closed loop.
- Security and compliance: Filter sensitive information in inputs and outputs, and retain audit logs.
- General cloud capabilities: You can use object storage to save evaluation sets, message queues for asynchronous decoupling, container platforms to host inference services, and logging services with monitoring and alerting to ensure stability, for example by leveraging relevant general cloud product capabilities from Baidu AI Cloud.
7. Conclusion
“Finding accurately” and “presenting well” are the two main threads of intelligent question answering. By decoupling retrieval reasoning from controlled rewriting, and combining structured material, strict prompt constraints, and a three-layer evaluation framework, you can build an explainable, replaceable, and continuously improvable question answering system without relying on any single black-box model. This paradigm applies both to developers building their own services and to enterprise-level knowledge QA and content production scenarios.
