Building a Retrieval-Augmented Content Production Workflow: Separating Evidence Collection from Writing

    This article explains how to design a two-stage content production pipeline that separates retrieval from generation. It covers how to divide responsibilities between stages, structure an evidence pack with sources and confidence scores, apply style-controlled rewriting, run fact-checking, and measure quality with a stable test set. Practical Python code examples are included.

    Why Separate Retrieval from Generation

    Most users turn to question-answering tools for one thing: a clear answer—what something is and how to do it. Background reasoning and cause analysis are secondary. This means the primary metrics for such a system are answer accuracy and actionability, with style and length coming second.

    A single model usually struggles to satisfy all three requirements at once. The first is retrieval coverage—finding enough sources that are sufficiently fresh and authoritative. The second is factual accuracy—whether generated content stays faithful to its sources. The third is style control—adapting to different formats such as podcast scripts, Q&A posts, explainers, or long-form technical articles. These capabilities require different training priorities and engineering approaches, and forcing one model to handle all of them often produces a clear weakness in at least one area.

    A more reliable approach is to split the task into two stages. The first stage focuses on evidence gathering, answering only “what are the facts and where do they come from.” The second stage focuses on expression, answering only “how to explain this clearly to the target audience.” The two stages are connected through a structured evidence pack, so that every fact can be traced back to a source.

    Dividing Capability Boundaries

    Before designing the pipeline, define what each stage is allowed to do—and what it must not do.

    The retrieval stage is responsible for keyword and semantic recall, source quality filtering, recency assessment, and deduplication. Its output should be a list of items with source URLs, publication dates, and confidence scores. It should not polish language or merge multiple items into conclusions.

    The generation stage is responsible for restructuring, style transfer, and audience adaptation. It may only use content from the evidence pack. If the generation model fills in numbers, dates, or names from its own memory, it introduces unverifiable errors. This is the most important constraint in the entire design.

    The table below summarizes the boundaries between the two stages.

    Dimension Retrieval Stage Generation Stage
    Input Topic, time range, source preferences Structured evidence pack, target genre, target audience
    Output Fact items with sources and timestamps A complete article matching the required genre
    Allowed operations Recall, filtering, deduplication, annotation Restructuring, rewriting, adding transitions
    Prohibited operations Writing conclusive paragraphs Introducing facts outside the evidence pack

    Designing the Two-Stage Pipeline

    A practical pipeline typically involves seven steps.

    Step 1: Requirement parsing. Convert the user’s request into a structured task brief specifying the topic, target genre, audience, word count range, and content to avoid. The brief is the basis for all subsequent steps; without it, each stage tends to develop its own interpretation of the goal.

    Step 2: Multi-source retrieval. Query multiple search endpoints for the same topic and record the source URL and publication date of each result. When relying on a single source, bias is hard to detect.

    Step 3: Evidence cleaning. Remove ads, duplicate content, and obvious site template text. For contradictory information, don’t pick a side—keep both versions, mark the conflict, and leave the judgment to later steps or a human.

    Step 4: Build the evidence pack. Each item should contain at least four fields: the claim, the source URL, the publication date, and a confidence score. Confidence can be rated based on source type, recency, and cross-source corroboration; the scoring rules should be defined by the team for its own scenario.

    Step 5: Genre-based rewriting. The rewrite prompt should include genre requirements, audience description, word count range, and factual constraints. Constraints must be stated explicitly—never rely on the model’s own judgment.

    Step 6: Fact checking. Verify every number, date, proper noun, and quote in the rewritten draft against the evidence pack. Anything that cannot be matched should be deleted or sent back for rewriting.

    Step 7: Human review. Automated checks can only catch formal deviations; they cannot judge whether context is appropriate. For high-risk topics such as healthcare, finance, and law, keep a human review step and avoid fully automated publishing.

    Key Code Example

    The following code shows the basic structure of an evidence item, evidence pack generation, and rewrite prompt construction. The scoring rules and search interface must be replaced for your actual environment—only the framework is shown here.

    1. from dataclasses import dataclass, field
    2. @dataclass
    3. class Evidence:
    4. claim: str # The factual statement
    5. source_url: str # Source URL
    6. published_at: str # Publication date, "unknown" if unavailable
    7. confidence: float # Confidence score between 0 and 1
    8. @dataclass
    9. class Brief:
    10. topic: str
    11. audience: str
    12. genre: str
    13. word_limit: tuple[int, int]
    14. evidence: list[Evidence] = field(default_factory=list)
    15. def collect_evidence(topic: str, search_fn, score_fn) -> list[Evidence]:
    16. """Call an external search function, filter invalid results, and build scored evidence items."""
    17. evidence = []
    18. for item in search_fn(topic):
    19. text = (item.get("text") or "").strip()
    20. url = item.get("url")
    21. if not text or not url:
    22. continue # Discard items missing content or a source
    23. evidence.append(Evidence(
    24. claim=text,
    25. source_url=url,
    26. published_at=item.get("date", "unknown"),
    27. confidence=score_fn(item),
    28. ))
    29. return evidence
    30. def build_rewrite_prompt(brief: Brief) -> str:
    31. """Combine the task brief and evidence pack into a rewrite prompt with explicit factual constraints."""
    32. lines = [
    33. f"Target genre: {brief.genre}",
    34. f"Target audience: {brief.audience}",
    35. f"Word count range: {brief.word_limit[0]} to {brief.word_limit[1]} words",
    36. "Factual constraint: only use facts from the evidence below. Do not add numbers, dates, or quotes.",
    37. "Evidence (sorted by confidence, descending):",
    38. ]
    39. for e in sorted(brief.evidence, key=lambda x: x.confidence, reverse=True):
    40. lines.append(f"- {e.claim} (source: {e.source_url}, date: {e.published_at})")
    41. return "\n".join(lines)

    The sorting of the evidence pack deserves a note. Sorting by confidence in descending order means the rewriting model sees the most reliable content first, while low-confidence items are more likely to be ignored or explicitly flagged. Sorting alone doesn’t guarantee correct output, but it reduces the chance that low-quality sources shape the main argument.

    Common Quality Risks and How to Check for Them

    Four problems come up most often in a two-stage setup.

    Factual drift. During rewriting, numbers may be rounded, dates miscalculated, and conclusions with qualifications turned into absolute statements. The remedy is mechanical checking of the final draft: extract all numbers, dates, and proper nouns, and compare them item by item against the evidence pack.

    Source distortion. An author’s subjective opinion in the original material may be rewritten as an objective fact. The remedy is to distinguish factual statements from opinions within the evidence pack, and to require the rewrite prompt to preserve that distinction.

    Staleness errors. Outdated information may be presented as the current state. The remedy is to state the statistical cutoff date in the prompt, and to flag or down-weight evidence older than a defined threshold.

    Style homogenization. Articles generated repeatedly may reuse similar openings and transitions, losing any recognizable voice. The remedy is to maintain separate templates for each genre and run periodic spot checks.

    The following function implements basic number verification.

    1. import re
    2. NUMBER_PATTERN = re.compile(r"\d+(?:\.\d+)?")
    3. def check_numbers(draft: str, evidence: list[Evidence]) -> list[str]:
    4. """Return numbers that appear in the draft but cannot be found in the evidence pack."""
    5. source_text = " ".join(e.claim for e in evidence)
    6. allowed = set(NUMBER_PATTERN.findall(source_text))
    7. issues = []
    8. for num in NUMBER_PATTERN.findall(draft):
    9. if num not in allowed:
    10. issues.append(f"Number {num} not found in evidence, needs manual confirmation")
    11. return issues

    This check has limitations. It only compares literal numbers—it cannot catch semantic drift such as “about half” being rewritten as “more than half,” nor can it detect incorrect unit conversions. Treat it as a filtering tool, not a complete fact audit.

    Evaluation

    Judging whether the pipeline works requires a stable test set. A good starting point is to sample 20 to 50 topics from your real business, and manually annotate each with a list of key facts and a target genre. After every change to the pipeline, run the same test set and compare results.

    Four metrics are worth tracking. Factual consistency rate: the proportion of statements in the rewritten draft that can be traced back to the evidence. Key information coverage: the proportion of key facts correctly retained. Style conformity: scored by reviewers against a fixed rubric. Average revision time: reflects the cost of manual post-processing.

    Set pass thresholds based on your team’s own historical data. Different topics and audiences have very different expectations for accuracy and expression, so generic benchmarks are of limited value.

    Rollout Recommendations

    Start with a small pilot—for example, one genre and one topic category. During the pilot, record every manual edit and its reason, and feed high-frequency issues back into the prompts and checking rules.

    Keep source URLs and timestamps in the evidence library for the long term. When a reader questions a specific number, the team can quickly trace it back to the original source—far more reliable than any after-the-fact explanation.

    For high-risk topics, make human review mandatory. Automation can significantly reduce repetitive work, but in fields like healthcare, finance, and law, the cost of an error far outweighs the efficiency gain—don’t skip the review step.