Separating Retrieval from Rewriting: A Practical Guide to AI Question Answering
This guide explains why retrieval and rewriting should be decoupled in AI question answering systems, and how to build a reliable pipeline around that separation. It covers query understanding, source credibility tiers, reranking and evidence filtering, constrained generation, multi-style adaptation, and fact verification. You will also find common retrieval failure modes, a three-layer evaluation framework, deployment and cost optimization practices, and frequent pitfalls to avoid when building a high-availability QA system.
1. Background: Users Want Answers, Not Reasoning Traces
In real-world question answering systems, most requests can be reduced to a pair: what (what the facts are) and how (how to do something). After submitting a question, users expect a response they can use directly, with a clear conclusion and reliable sources, rather than a lengthy chain of thought. This shapes the design priority: in the retrieval stage, “retrieving accurately” delivers more user value than “thinking more.”
The combined usage described in the original experience is essentially a separation of responsibilities: one stage locates trustworthy sources in noisy internet-scale text, and the other reassembles the material into the target style. Abstracted, this yields a general pipeline:
User question↓Query understanding and rewriting↓Retrieval and recall↓Rerank and evidence filtering↓Constrained generation↓Citation and verification↓Output
The key design principle is decoupling retrieval from generation. Retrieval focuses on recall and source credibility; generation focuses on language organization and target style. The two have different optimization goals, and combining them in a single model often leads to mediocre results on both.
2. Why Retrieval and Rewriting Should Be Decoupled
2.1 Conflicting Optimization Goals
Retrieval is evaluated with vectorized metrics such as recall, hit rate, and ranking position. Generation is evaluated with human and semantic metrics such as fluency, style consistency, and information completeness. When one model carries both objectives, the training signals interfere with each other. The common outcomes are “fluent language with drifting facts” or “complete facts with stiff expression.”
2.2 Ecosystem and Data Freshness Differences
Retrieval quality depends heavily on index coverage, site quality tiers, and update frequency for time-sensitive content. These are engineering and data governance problems that model size alone cannot fix. Generation quality depends on corpus style coverage and instruction-following ability. Separating the two allows independent scaling, independent canary releases, and independent rollback.
2.3 Replaceability and Cost Control
Once decoupled, the retrieval layer can be swapped for a self-built index, a vector database, or a third-party retrieval service, and the generation layer can swap models of different sizes. Requests can be routed by value: high-value requests take “deep retrieval + strong generation,” while low-value requests take “shallow retrieval + light generation,” controlling cost per request.
3. Key Engineering Points for the Retrieval Layer
3.1 Query Understanding
Raw queries are often colloquial, contain references, and carry implicit constraints. Normalization and expansion are recommended first:
def build_queries(raw: str, history: list[dict]) -> list[str]:# 1) Coreference resolution and ellipsis completionresolved = resolve_coreference(raw, history)# 2) Constraint extraction: time, region, version, scenarioconstraints = extract_constraints(resolved)# 3) Multi-path expansion: synonym rewriting + sub-question splittingvariants = expand_synonyms(resolved) + split_subquestions(resolved)return [f"{v} {constraints}" for v in variants]
Multi-path queries significantly improve recall stability. When a question contains multiple constraints, splitting sub-questions avoids “one long sentence overwhelming retrieval.”
3.2 Source Credibility Tiers
Not all web pages are equal. In practice, maintain source tiers: authoritative institutions and original documentation as tier one, mainstream media and established communities as tier two, and aggregators and content farms as tier three. Weight retrieval results by tier, and prefer tier-one and tier-two evidence during generation.
3.3 Rerank and Evidence Filtering
Initial recall is usually noisy and needs reranking with a cross-encoder or a lightweight discriminator, plus evidence-level filtering:
- Remove time-expired content (set a time window for time-sensitive questions);
- Remove content inconsistent with query entities (entity validation);
- Deduplicate at the fragment level to avoid the same passage repeatedly entering the context;
- Control the context budget, truncating by “information gain / token cost.”
3.4 Common Retrieval Failure Modes
| Failure Mode | Symptom | Mitigation |
|---|---|---|
| Vocabulary gap | User wording differs from document wording | Semantic vector recall + synonym expansion |
| Freshness mismatch | Outdated information returned | Time-window filtering + freshness weighting |
| Missing authority | Low-credibility aggregator content cited | Source tiers + allowlist |
| Context overflow | Key evidence truncated | Evidence compression + gain-based ordering |
4. Key Engineering Points for the Rewriting Layer
4.1 Constrained Generation
Rewriting should not be free creation but “reorganization under given evidence.” A recommended prompt structure:
You are a content editor. Use only information from the [Evidence] below; do not introduce external facts.Target style: {style}Target audience: {audience}Structure requirement: {outline}If evidence is insufficient, explicitly output "insufficient evidence"; do not speculate.[Evidence][1] ...[2] ...
This constraint moves the hallucination risk forward to the judgment of “whether evidence is sufficient,” making system behavior predictable.
4.2 Multi-Style Adaptation
The same material can be reused across delivery formats by switching style parameters and structure templates:
- Q&A draft: one question, one answer, conclusion first;
- Popular science draft: from phenomenon to mechanism, with analogies;
- Podcast script: colloquial, short sentences, with transitions;
- Community long-form: conclusion summary first, then arguments and boundary conditions.
Make “style” a configuration rather than hard-coded, which eases A/B testing and fast iteration:
style_profile:name: popular_sciencesentence_len: shortuse_analogy: trueoutline: [phenomenon, mechanism, example, caveat]citation_style: inline_ordinal
4.3 Fact Verification Loop
Append verification after generation: extract assertions from the answer and perform entailment judgment against the evidence one by one. Unsupported assertions trigger rewriting or downgrade to “insufficient evidence.” This step is key to risk control and the bridge that turns “strong language ability” into “deliverable quality.”
5. A Neutral View of Capability Differences: Why Stages Perform Differently
The industry commonly observes that general assistants optimized for conversational experience are usually more mature in instruction following, context organization, and refusal boundaries, while models strong in code and reasoning are stronger in structured generation and cross-file understanding but not necessarily better in “naturalness” and “sense of boundaries” in open-domain conversation. In addition, language ability varies in “depth”: models with broad corpus coverage and sufficient alignment are more stable when switching styles, while models with a more focused corpus may be more precise on vertical tasks but less flexible in style.
The engineering conclusion is not “pick the single strongest model” but select by stage: the retrieval layer depends on index and reranking, the generation layer on style and constraint adherence, and the verification layer on discriminative ability. The three can come from different implementations and be connected through standard interfaces.
6. Evaluation: Making Optimization Measurable
A three-layer evaluation is recommended:
- Retrieval layer:
Recall@K,MRR, share of tier-one sources, freshness pass rate; - Generation layer: evidence coverage, assertion support rate, style compliance (human or model review), refusal accuracy;
- End to end: task completion rate, human adoption rate, average correction distance (how much users edit before it is usable).
Beyond offline evaluation, keep small-traffic online experiments and monitor the “insufficient evidence” trigger rate. A sudden spike usually means the retrieval layer has degraded, not the generation layer.
7. Deployment and Cost Optimization
- Cache in layers: query result cache, evidence fragment cache, generation result cache (keyed by style dimension);
- Routing strategy: call models of different sizes by question complexity and value tier;
- Asynchronization: deep retrieval runs as asynchronous tasks, with the frontend returning a lightweight conclusion first and completing citations later;
- Observability: full-chain instrumentation recording query rewriting, recall sources, rerank scores, and verification conclusions for attribution;
- If using cloud general capabilities, object storage can hold corpus snapshots, message queues can decouple retrieval tasks, container platforms can host reranking services, and logging plus monitoring alerts can ensure stability.
8. Common Pitfalls
- Pitfall 1: Treating “can reason” as “can retrieve.” Retrieval is a data and index engineering problem; no matter how strong the model, it cannot recall unindexed content out of thin air.
- Pitfall 2: Chasing a single end-to-end model. After decoupling, each layer can iterate independently, with higher long-term returns.
- Pitfall 3: Ignoring refusal design. Clearly stating insufficient evidence builds more trust than fabricating an answer.
- Pitfall 4: Only looking at style, not verification. Language fluency and factual reliability must be measured separately.
9. Conclusion
Splitting “retrieve accurately” and “write well” into two stages, using query understanding, source tiering, and rerank filtering to ensure retrieval quality, and constrained generation, style configuration, and fact verification to ensure output quality, is currently the most reliable engineering path for building a high-availability question answering system. This paradigm is vendor-neutral and can serve as a general foundation, assembled on demand atop general capabilities from cloud platforms such as Baidu AI Cloud, forming a QA pipeline that is evaluable, evolvable, and cost-controlled.
