Large Language Model Q&A and Rewriting: A Practical Guide to Combining Capabilities
This article explains why asking "which model is better" is the wrong starting point for LLM applications, and proposes a staged retrieval-generation-rewriting pipeline instead. It covers capability layering across search, answer convergence, rewriting, and code generation; a vendor-neutral reference architecture with structured source material; a three-layer evaluation methodology with scoring logic; prompt design and engineering details; cost and stability controls; common pitfalls; and a practical rollout checklist.
1. Reframing the Problem: From “Which One Is Better” to “How Do We Combine Capabilities”
Once conversational AI applications become part of the daily development workflow, the question teams ask most often is still “which model works better.” From an engineering perspective, that phrasing has no verifiable decision criteria. Real business needs usually abstract into two goal types. One is what + how: the user wants a clear, traceable answer that can be acted on immediately. The other is why: the user wants to understand causes, mechanisms, and boundary conditions. The two goal types place completely different demands on the system. The first depends heavily on retrieval quality, source credibility, and the ability to converge on an answer. The second depends more on reasoning depth and the organization of the explanation.
A more rigorous approach is to rewrite the question as: how do we build a staged “retrieve - generate - rewrite” pipeline where each stage uses the capability it is best at, and validate the result with a unified evaluation set? This decoupling aligns with established retrieval-augmented generation (RAG) practice, and it makes it easier to optimize model capability, the retrieval ecosystem, and post-processing strategies separately.
2. Capability Layers: Retrieval, Understanding, Rewriting, Coding
Layering LLM capabilities helps avoid the trap of “using one model to solve everything.”
- Retrieval and search ecosystem: determines whether authoritative, current, verifiable sources can be recalled. Evaluation focuses on recall rate, source domain credibility, freshness, deduplication, and support for structured citations.
- Answer convergence and factuality: determines whether output is direct and actionable, and whether it clearly separates “known facts” from “inferences.”
- Text rewriting and style transfer: determines whether material can be turned into podcast scripts, Q&A scripts, popular-science pieces, long-form columns, and other styles while keeping facts unchanged.
- Code and structured generation: in intelligent coding, configuration generation, and script conversion scenarios, the focus is on syntactic correctness, testability, and effective use of the context window.
A common and effective combination is a two-stage pattern: first, a general-purpose Q&A model with strong retrieval produces a “material package” (key points, sources, timestamps); second, a model with stronger rewriting ability restyles and reorganizes it. This preserves the factual foundation while improving readability.
3. Reference Architecture: A Two-Stage Pipeline
The architecture below is not tied to any specific vendor and maps directly onto self-hosted services or general cloud capabilities (object storage, message queues, container platforms, logging services, monitoring and alerting, and similar general categories).
User question-> Query rewriting and intent recognition-> Retrieval/search (multi-source recall + reranking + credibility scoring)-> Material structuring (key points / citations / timestamps)-> Draft generation (what + how first)-> Style rewriting (podcast / Q&A / popular science / long-form)-> Fact checking and citation backfill-> Output and audit trail
The key engineering point is “material structuring.” Converting unstructured search results into a unified structure lets the later rewriting stage work on clean input only, which significantly reduces the probability of hallucination.
{"query": "original question","claims": [{"text": "claim statement", "source": "source identifier", "ts": "2025-01-01", "score": 0.87}],"open_questions": ["points not yet confirmed"]}
4. Evaluation: Reproducible Metrics and Datasets
Without evaluation, model selection degrades into personal preference. Three evaluation layers are recommended:
- Retrieval layer: recall rate, hit rate@K, source credibility distribution, duplication rate, freshness compliance rate.
- Generation layer: factual consistency, citation coverage, answer actionability (whether steps are given), correctness of refusals.
- Rewriting layer: style match, fact preservation rate, terminology consistency, length controllability.
The evaluation set should contain three sample categories: “answerable,” “partially answerable,” and “should refuse,” each with a different weight. Illustrative scoring logic:
def score(item, pred):fact = 1.0 if pred["consistent"] else 0.0cite = pred["cited_claims"] / max(1, len(item["claims"]))execu = 1.0 if pred["actionable"] else 0.0style = pred["style_match"] # 0~1return 0.4*fact + 0.3*cite + 0.2*execu + 0.1*style
5. Prompts and Engineering Details
The retrieval-stage prompt emphasizes “conclusions and sources only”; the rewriting-stage prompt emphasizes “no new facts may be added.” Examples:
[Retrieval stage]Output JSON: claims[], sources[], open_questions[]; every claim must include a source and a timestamp.[Rewriting stage]Rewrite using only the given claims; do not introduce information that was not provided; keep terminology consistent; target style = popular science.
Engineering also requires attention to the following: set cache keys for retrieval results (normalized query + time window) and cache results for high-frequency questions; apply length and structure constraints to the rewriting stage; log the full chain with metrics so it is easy to trace whether a problem came from retrieval or generation.
6. Cost and Stability Control
- Tiered routing: simple factual Q&A goes to smaller models; complex reasoning goes to larger models.
- Caching and batching: material caching, result caching, offline batch rewriting.
- Timeouts and degradation: if retrieval fails, degrade to “answer based only on known information and explicitly state uncertainty.”
- Content safety: filter both input and output, and retain an audit trail.
7. Common Pitfalls
- Using a single model for both retrieval and rewriting, so factuality and readability drag each other down.
- Evaluating style only, without evaluating citation coverage and factual consistency.
- Ignoring “should refuse” samples, which produces overconfident output.
- Treating style samples as a source of facts, which causes hidden hallucinations.
8. Rollout Checklist
- Determine whether the business goal is what+how or why; 2. Build the three-layer evaluation set; 3. Implement material structuring and citation backfill; 4. Decouple the two stages and tune them separately; 5. Add caching, monitoring, and degradation; 6. Run regression evaluation weekly and keep iterating on prompts and reranking strategies.
