A Practical Guide to LLM Question Answering and Rewriting

    This guide explains how to build a two-stage LLM pipeline that separates retrieval-based question answering from style rewriting. It covers query normalization and multi-route recall, source credibility tiers, answer assembly with citations, structured JSON handoff between stages, style control parameters, a three-layer evaluation system, and engineering practices for caching, cost routing, and degradation. Readers will learn why decoupling evidence gathering from expression produces more reliable and readable output.

    1. The Core Problem: Users Want Clear Answers, Not Reasoning Traces

    In real-world LLM applications, most end-user requests reduce to a simple formula: what + how. Users rarely care why the model reasoned a certain way; they want an actionable, verifiable conclusion as fast as possible.

    This leads to a basic engineering judgment: question answering and rewriting should be decoupled. Splitting “find the evidence” from “write the expression” into two stages, each optimized with the most suitable strategy, is usually more stable and more controllable than chasing a single all-purpose model.

    A typical two-stage pipeline looks like this:

    1. User question
    2. -> Query understanding and rewriting
    3. -> Retrieval and source filtering
    4. -> Answer assembly with citations
    5. -> Style transfer
    6. -> Validation and output

    2. Stage One: Retrieval-Augmented QA Sets the Ceiling on Trustworthiness

    2.1 Why retrieval augmentation is required

    Purely parametric generation has two inherent problems: stale knowledge and factual drift. The core value of retrieval-augmented generation (RAG) is moving the factual basis of an answer from model memory to updatable external corpora, which makes conclusions traceable.

    2.2 Query understanding: turning colloquial questions into retrievable expressions

    User input often contains references, omissions, and noise. In practice, normalize first, then run multi-route recall:

    1. def build_queries(raw: str):
    2. # Normalize: remove noise, unify entity mentions
    3. q_norm = normalize(raw)
    4. return {
    5. "lexical": q_norm, # keyword recall, strong on proper nouns
    6. "semantic": embed(q_norm), # vector recall, strong on paraphrases
    7. "expanded": expand_synonyms(q_norm) # synonym expansion, improves coverage
    8. }

    Fusing the three recall sets with a rank-based method (such as reciprocal rank fusion) significantly reduces misses where only literal matches are retrieved and semantic matches are not.

    2.3 Source credibility tiers: the real fix for precision

    When answer precision is low, the problem is usually not the model but an ungoverned corpus ecosystem. A workable approach is to tag sources with credibility labels and constrain them explicitly in the prompt:

    1. source_policy:
    2. tier_a: [official documentation, standards, authoritative publications] # usable as direct evidence
    3. tier_b: [specialized media, high-quality technical communities] # requires cross-verification
    4. tier_c: [aggregators, unsigned content] # leads only, not evidence
    5. reject: [content farms, scraper sites, obvious marketing pages]

    A matching prompt constraint:

    1. Draw conclusions only from tier_a and tier_b sources;
    2. tier_c may be used to surface leads but must not appear in the conclusion;
    3. if evidence conflicts, output a conflict note instead of forcing a single answer.

    2.4 Answer assembly: making conclusions verifiable

    A high-quality answer should follow a fixed three-part structure: conclusion first → evidence and citations → applicability boundaries. Stating boundaries explicitly (version differences, scenario prerequisites, failure conditions) builds more trust than piling on adjectives.

    3. Stage Two: Style Rewriting Turns Material into a Finished Draft

    3.1 Rewriting and generation are different capabilities

    The retrieval stage produces structured material (points, data, citations), while a finished draft needs stable voice, rhythm, and genre conventions. Handing both to the same strategy commonly yields output that is “factually right but awkward to read.” The rewriting stage therefore deserves separate design.

    3.2 Isolating facts from expression with a structured intermediate format

    Have the retrieval stage emit JSON material and allow the rewriting stage to consume only that structure, which prevents reintroducing factual errors:

    1. {
    2. "topic": "Causes of cache penetration and how to handle it",
    3. "points": ["null value caching", "Bloom filter", "request coalescing"],
    4. "citations": ["doc-1", "doc-2"],
    5. "constraints": ["do not mention specific vendor product names"]
    6. }

    3.3 Key parameters for style control

    Style drift mostly comes from excessive sampling randomness. A practical baseline:

    1. cfg = {
    2. "temperature": 0.6, # can be slightly higher for explainers or podcast scripts
    3. "top_p": 0.9,
    4. "max_tokens": 1200,
    5. "frequency_penalty": 0.2 # suppresses repeated sentence patterns
    6. }

    Different genres can reuse the same prompt skeleton, swapping only the style description block:

    1. Genre: {podcast script | Q&A piece | explainer | long-form community post}
    2. Audience: {beginners | frontline developers | technical decision makers}
    3. Hard constraints: keep all citation IDs; do not add facts absent from the material.
    4. Style: conversational but not gimmicky; break long sentences; one central sentence per paragraph.

    4. Evaluation: No Measurement, No Optimization

    Build a three-layer evaluation instead of tuning prompts by feel:

    • Fact layer: whether conclusions are backed by tier_a/tier_b evidence and whether citation IDs map one to one;
    • Structure layer: conclusion-first ordering, presence of applicability boundaries, point coverage;
    • Expression layer: sentence length distribution, terminology consistency, genre fit, checked by human sampling.

    Add two production monitors on top: unsupported answer rate and fact loss rate after rewriting. The latter is especially easy to overlook — rewriting tends to “conveniently drop” qualifiers, turning a correct conclusion into an incorrect one.

    5. Engineering Governance: Caching, Cost, and Stability

    • Tiered caching: three cache levels for normalized queries, retrieval results, and finished drafts; the normalization layer usually has the highest hit rate;
    • Cost routing: route simple factual QA to smaller models and long-form rewriting to long-context models, dispatching by task;
    • Degradation strategy: when retrieval returns nothing, explicitly reply “no reliable evidence found” rather than generating freely;
    • Observability: log services record the distribution of recall source tiers, alerting covers latency and failure rate, and object storage keeps the evaluation sample set.

    6. Common Pitfalls

    1. Treating search capability as model capability: with insufficient ecosystem governance, no amount of generation strength compensates for bad corpora;
    2. Chasing a single all-capable model: retrieval and rewriting goals conflict, so decoupling pays off more;
    3. Loosening factual constraints during rewriting: “no new facts” must be locked down;
    4. Ignoring applicability boundaries: answers without boundary statements are nearly unusable in professional settings.

    7. Conclusion

    “Retrieval owns trustworthiness, rewriting owns readability” is the most reliable architectural stance for this kind of system. The engineering focus is not picking a specific tool but three things: source tier governance, structured material isolation, and quantifiable three-layer evaluation. Get these solid, and the QA pipeline can achieve both precision and expression quality while iterating continuously at a controlled cost.