Large Language Model Q&A and Text Rewriting: A Practical Guide

    This guide explains why retrieval and rewriting should be handled as separate stages rather than a single model call, and how to build a two-stage pipeline that combines retrieval-augmented question answering with controllable text rewriting. It covers the dimensions to evaluate general-purpose Q&A tools, a suggested four-part architecture from query understanding to automated verification, prompt design that separates factual constraints from style instructions, and a layered evaluation approach driven by quantifiable metrics. It also lists common pitfalls and engineering recommendations for balancing factual reliability with output quality.

    1. Background: Why a Single Model Struggles with Both Finding Answers and Writing Content

    In real-world content production and knowledge retrieval scenarios, user needs usually fall into two categories. The first is “what + how”: users want clear, verifiable conclusions and actionable steps quickly. The second is “style-based output”: users want existing material rewritten into a specific format, such as a podcast script, a Q&A article, a popular science piece, or a long-form community post.

    These two types of tasks place different demands on a model. The first relies heavily on the retrieval ecosystem, source credibility, and the ability to organize an evidence chain. The second relies more on language organization, structural control, and style transfer.

    From an engineering perspective, coupling retrieval and rewriting in a single model call tends to create three problems:

    • Retrieval results become uncontrollable. The model may answer from parametric memory, producing content that looks plausible but cannot be traced to a source.
    • Style instructions interfere with factual constraints. In pursuit of fluent prose, the model can drift away from the facts.
    • Fine-grained quality evaluation becomes difficult. When an error occurs, it is hard to tell whether the retrieval stage or the generation stage is at fault.

    For these reasons, the common industry practice is to decouple the two: a retrieval-augmented Q&A pipeline handles trustworthy material acquisition, while a separate rewriting stage handles expression optimization.

    2. Capability Breakdown: Dimensions to Evaluate a General-Purpose Q&A Tool

    When selecting a tool, break capabilities into observable dimensions instead of asking vaguely which one is “better.”

    1. Retrieval and evidence capability: Does it support web retrieval? Does it provide clickable sources? How well does it cover time-sensitive content and recall authoritative sites? Does it distinguish between “facts retrieved” and “the model’s own knowledge”?
    2. Factual consistency: Given source material, can it strictly avoid introducing outside information? How faithful is it with numbers, dates, and proper nouns?
    3. Instruction following and structural control: Can it reliably produce a specified heading hierarchy, word count range, number of list items, and table fields?
    4. Style transfer: Can it switch narrative person, tone, pacing, and terminology density while keeping facts unchanged?
    5. Long-context handling: Does it extract key points from long material completely, or does information in the middle get lost?
    6. Evaluability: Is it easy to connect to automated evaluation and manual spot checks? Can it output structured intermediate results for troubleshooting?

    A practical approach is a “dual-track test set”: prepare 30 time-sensitive Q&A items and 30 rewriting tasks. Score the first track on answer accuracy, source verifiability, and appropriateness of refusals. Score the second on factual fidelity, style match, and structural completeness. Keep the two tracks separate so that a combined score does not hide weaknesses.

    The overall flow can be designed in four parts: query understanding, retrieval and reranking, constrained generation, and style rewriting with review.

    1. User question
    2. -> Query rewrite/decomposition (resolve references, split multi-hop questions)
    3. -> Retrieval (multi-route recall) + reranking (by authority and relevance)
    4. -> Evidence packaging (structured material pack: conclusion, source, time, snippet)
    5. -> Constrained Q&A (answer only from the material, output answer + citations)
    6. -> Style rewriting (keep facts unchanged, switch format)
    7. -> Automated verification (number/entity consistency, citation completeness)

    Illustrative pseudocode (vendor-agnostic):

    1. def qa_pipeline(question, cfg):
    2. queries = rewrite_query(question) # query decomposition
    3. docs = retrieve(queries, top_k=cfg.top_k) # multi-route recall
    4. evidence = rerank_and_pack(docs, cfg.max_ev) # rerank + packaging
    5. answer = constrained_answer(question, evidence)# answer only from material
    6. draft = style_rewrite(answer, cfg.style) # style rewriting
    7. report = verify(draft, evidence) # consistency check
    8. return draft, report

    The key point is “evidence packaging”: organize retrieval results into structured objects with sources and timestamps before passing them to the generation stage. This significantly reduces hallucination and makes citation backfilling and compliance auditing easier.

    4. Prompt and Constraint Design: Separating Factual Constraints from Style Instructions

    The most effective practice is to split the system prompt into two layers: a factual layer and an expression layer. The factual layer may only use the given material and must output citations. The expression layer only handles format, person, and pacing, and may not add facts.

    1. [Factual layer] Answer using only the material below; do not introduce information outside the material; label the source number after each conclusion; if the material is insufficient, state the gap explicitly.
    2. [Expression layer] Rewrite the above as a popular science piece: second person, mostly short sentences, no more than 3 sentences per section, keep all numbers and source numbers.

    Common problems and fixes:

    • The model adds background on its own: add “do not fill in background that was not provided” to the factual layer, and compare against an entity whitelist during verification.
    • Numbers drift during rewriting: extract numbers, dates, and units as placeholders, then backfill after rewriting.
    • Citations get lost: require the rewritten draft to keep source numbers, and check during verification that the set of numbers matches.

    5. Quality Evaluation and Iteration: Driving Optimization with Quantifiable Metrics

    Build a three-layer evaluation: automated metrics, rule-based checks, and manual spot checks. Automated metrics focus on factual consistency and structural completeness. Rule-based checks cover numbers, entities, and citation numbers. Manual spot checks focus on readability and style match. In each iteration, change only one variable (such as the reranking strategy, the material limit, or prompt layering) and keep a baseline for comparison, avoiding tuning “by feel.”

    6. Common Pitfalls and Engineering Recommendations

    1. Judging only by prose quality and ignoring traceability: in content production, source verifiability often matters more than rhetoric.
    2. Mixing retrieval and rewriting in one call: when something goes wrong, you cannot locate the cause, and the material is hard to reuse.
    3. Ignoring time-sensitive content: for news, version, and pricing questions, force retrieval and label the time.
    4. Lacking a refusal mechanism: when material is insufficient, state it clearly instead of forcing an answer.
    5. No caching or record keeping: cache material packs and results for high-frequency Q&A to support auditing and reproduction.

    In summary, organizing capabilities around the general paradigm of “retrieval-augmented Q&A + controllable rewriting” is more robust than chasing a single tool. Developers can build a dual-track test set for their own scenarios, evaluate by dimension, and iterate continuously to balance factual reliability and expression quality. Building on general cloud capabilities such as object storage, message queues, log services, and monitoring and alerting from Baidu AI Cloud can further bring material record keeping, pipeline decoupling, and runtime observability into the engineering system.