AI Question Answering: A Practical Guide to Retrieval and Rewriting
This article explains why a single model often struggles to both find and write answers, and how to split AI question answering into separate retrieval and rewriting stages. It covers a four-layer architecture, key retrieval practices, outline-first rewriting, quantifiable quality evaluation, and common anti-patterns, offering a practical baseline for building accurate and readable content pipelines.
1. Background: Why a Single Model Struggles to Both Find and Write Answers
In real-world content production and knowledge service scenarios, user requests usually fall into two categories. The first is factual goals, such as what and how: the definition of a concept, a sequence of steps, or how to handle a specific error code. The second is expression goals: what tone, structure, and length to use when presenting a conclusion to a particular audience. When teams evaluate tools, they often mix these two categories and expect a single question answering entry point to handle retrieval, filtering, reasoning, and style control all at once. The result is that accuracy and readability often hold each other back.
A more reliable approach is to decouple capabilities: separate “evidence gathering” from “text generation” into two stages that can be evaluated and replaced independently. The retrieval stage emphasizes reliable, traceable, and complete sources. The rewriting stage emphasizes clear structure, consistent terminology, and controllable style. This separation mirrors the separation of concerns in software engineering and makes troubleshooting easier: if an answer is wrong, check the evidence first; if the style is off, adjust the generation.
2. Overall Architecture: Retrieval, Material, Rewriting, and Validation Layers
A practical general pipeline typically has four layers:
- Retrieval layer: Queries an open domain or enterprise knowledge base, recalls candidate materials, and outputs metadata such as title, summary, source type, and timestamp.
- Material layer: Deduplicates, extracts, and normalizes candidate materials into structured assets, such as bullet lists, step sequences, and comparison tables.
- Rewriting layer: Uses the materials as the sole source of truth, generates a first draft in the target style, and forces uncertain items to be flagged.
- Validation layer: Performs consistency checks, citation coverage checks, and sensitive information and compliance checks, then outputs a publishable draft or sends it back for rewriting.
A sample data structure can be expressed as:
{"query": "How to troubleshoot memory leaks on a container platform","evidence": [{"id": "e1", "title": "Monitoring Metrics Guide", "type": "doc", "ts": "2025-01-10"},{"id": "e2", "title": "Log Retrieval Practices", "type": "doc", "ts": "2025-02-02"}],"outline": ["Symptom definition", "Troubleshooting steps", "Verification methods", "Common pitfalls"],"constraints": {"tone": "explainer", "length": 1200, "must_flag_uncertain": true}}
3. Key Retrieval Practices: Reliably Recalling Trustworthy Sources
Retrieval quality sets the upper bound. On the engineering side, you can optimize in three areas:
- Source tiering: Classify materials into authoritative documentation, engineering practices, and community discussions. Rewriting should prioritize the first two tiers, using community content only as leads.
- Time sensitivity handling: For versioned topics such as runtime versions or API behavior, prioritize materials with newer timestamps that match the target version, and avoid mixing conclusions across versions.
- Query rewriting and multi-path recall: Expand the original question into several sub-queries (definition, steps, error, comparison), recall them in parallel, and merge the results to improve coverage.
It is important to emphasize that retrieval results must be traceable. Every conclusion should map to a material id so the validation layer can compute citation coverage. If a conclusion has no supporting material, it should be marked as to be confirmed rather than left for the generation stage to improvise.
4. Key Rewriting Practices: Turning Materials into the Target Style
Rewriting is not synonym replacement; it is restructuring information. A two-step “outline first” approach is recommended:
Step one, generate an outline. Only points from the materials are allowed. Output hierarchical headings and point numbers for each section, for example:
1 Symptoms and scope (e1)2 Troubleshooting steps (e1,e2)3 Verification and rollback (e2)4 Common pitfalls (to be confirmed)
Step two, write from the outline. The prompt should state clear constraints: do not introduce facts outside the materials; numbers, version numbers, and command forms must come from the materials; explicitly flag uncertain parts. A general prompt skeleton is as follows:
You are a technical editor. Write only based on the evidence.Output structure: summary-body-bullet list.Rules:1) Mark the citation id at the end of each paragraph;2) Write "to be confirmed" for content without supporting material;3) Keep terminology consistent and avoid a marketing tone.
For style control, you can define style parameters in advance (narrative person, sentence length range, glossary, whether to keep code blocks) and use different templates for different genres: explainers emphasize analogies and progressive explanation; Q&A pieces emphasize question-answer pairs and boundary conditions; engineering pieces emphasize steps, verification, and rollback.
5. Quality Evaluation: Replacing Subjective Feelings with Quantifiable Metrics
It is recommended to build an offline evaluation set covering four metric categories: factual consistency, citation coverage, structural completeness, and style compliance. Factual consistency can combine sampled manual review with rule-based checks; citation coverage measures the proportion of sentences backed by materials; structural completeness checks the correspondence between the outline and actual sections; style compliance is approximated by glossary hit rate and sentence length distribution. After launch, continuously collect reasons for sending drafts back for rewriting to form an iteration loop.
6. Common Anti-Patterns and Fixes
- Letting the generation stage fill in facts on its own: fix by enforcing citations and to-be-confirmed flags.
- Pursuing style only: fix by going outline first, correctness before expression.
- Using retrieval results once: fix by using multi-path recall and deduplication and normalization.
- Mixing versions: fix by filtering on both timestamp and target version.
7. Conclusion
Splitting AI question answering into retrieval and rewriting, and connecting them with three constraints—structured materials, traceable citations, and quantifiable evaluation—is a general engineering solution that balances accuracy and readability. This approach aligns with the direction of Baidu AI Cloud’s general capabilities in knowledge management and content production, and can serve as a reference baseline for teams building their own pipelines.
