LLM Document Generation: Capability Evolution and Engineering Practices for Production Pipelines

    This article examines why large language models that impress in document generation demos often fail in real workflows, and how to turn general-purpose LLM capabilities into a stable, reproducible, and auditable document production pipeline. It breaks down the core difficulties across the input, generation, and acceptance stages, then proposes a five-layer reference architecture with explicit contracts between layers: ingestion and parsing, metric and entity alignment, planning, rendering, and validation with write-back. Key engineering practices include planning before generation, versioned templates as contracts, mandatory numerical recomputation, non-optional citations, and fallback mechanisms. The article also outlines a three-tier evaluation system covering factual, structural, and efficiency metrics, and closes with deployment suggestions on Baidu AI Cloud.

    1. The Problem: Impressive Demos, Difficult Deployment

    A recently released general-purpose LLM from a cloud vendor drew attention for its improved professional document generation, especially for presentations, spreadsheets, and structured reports. The demo was representative: given a retailer’s previous-quarter performance report, along with the current quarter’s earnings announcement and regulatory filings, the model was asked to update the report while preserving the existing style. The vendor summarized the difference between the old and new model outputs as “a difference in the granularity of information extraction”—the new model put sales growth, a key metric, directly into the headline, further split online versus brick-and-mortar performance, and produced actionable business recommendations based on the financial data.

    External users with early access were noticeably more conservative, however, judging the new version “basically unusable” in real workflows and unwilling to write a full review. This gap between the official demo and real experience is not an isolated issue with one model, but a structural challenge of document generation tasks: demos are completed under controlled inputs, a single objective, and loose acceptance criteria, while production environments must deal with multi-source heterogeneous materials, strict formatting, compliance requirements, and traceability.

    For developers and enterprise users, the real question is not “which model is stronger,” but how to package general-purpose LLM capabilities into a stable, reproducible, and auditable document production pipeline. The rest of this article abstracts the topic into a general technical problem and presents a practical engineering solution.

    2. Capability Boundaries: Why Document Generation Is Hard

    2.1 Input: Multi-Source Heterogeneity and Metric Conflicts

    Real materials typically mix structured tables, scanned screenshots, long-form announcements, and compliance attachments. Different sources carry differences in statistical definitions (tax-inclusive versus tax-exclusive, consolidated versus parent-company, calendar quarter versus fiscal quarter). Without a metric alignment layer, a model can easily stitch together numbers based on different baselines and produce conclusions that “look reasonable but are actually wrong.”

    2.2 Generation: Dual Constraints of Layout and Semantics

    A presentation is not plain text; it is constrained by layout masters, font hierarchy, information density per slide, and chart types. A plain-text model outputs a content draft, which still faces a “rendering gap” before it becomes a deliverable slide. In addition, headlines must carry conclusions while body text must carry evidence, and the two cannot substitute for each other.

    2.3 Acceptance: Insufficient Verifiability

    The acceptance standard in enterprise scenarios is that “every number must be traceable.” If the generated result provides only conclusions without citations, the review cost quickly exceeds the cost of manual writing—the core reason external testers judged it “unusable.”

    3. Reference Architecture: A Five-Layer Pipeline

    The system should be split into five layers that communicate through explicit contracts, avoiding the mistake of pushing all complexity into a single model call.

    1. Ingestion and parsing layer: uniformly parse documents, tables, and images into a normalized intermediate structure.
    2. Metric and entity alignment layer: maintain a metric dictionary and entity mapping to resolve definition conflicts.
    3. Planning layer: produce an outline and a “conclusion–evidence” mapping first, then generate the body text.
    4. Rendering layer: map structured content to layout templates, with charts driven directly by data.
    5. Validation and write-back layer: perform numerical recomputation, citation completeness checks, and non-compliance interception.

    An illustrative intermediate structure (pseudocode that expresses the contract only and does not represent any specific interface):

    1. {
    2. "deck": {
    3. "template_id": "quarterly_review",
    4. "pages": [
    5. {
    6. "layout": "title_with_kpi",
    7. "headline": {"text": "Sales up 5.3% year over year", "refs": ["f1"]},
    8. "kpi": [{"name": "sales_growth", "value": 0.053, "refs": ["f1"]}],
    9. "notes": ["Online vs. brick-and-mortar split", "Three business recommendations"]
    10. }
    11. ]
    12. },
    13. "evidence": {
    14. "f1": {"source": "Announcement attachment", "locator": "Page 12, Table 3", "raw": "5.3%"}
    15. }
    16. }

    4. Key Engineering Design Points

    4.1 Plan Before Generating

    Have the model output the outline and evidence IDs first, then let deterministic code fill in the layout. This significantly reduces “number drift” and lets reviewers spot-check by ID, reducing acceptance cost from full-text reading to sampled verification.

    4.2 Templates as Contracts

    Layout templates should be version-controlled, with field names mapped one-to-one to the business metric dictionary. Template changes should go through a review process to prevent misalignment between model output and layout.

    4.3 Numerical Recomputation Is Mandatory

    All ratios, year-over-year and quarter-over-quarter changes, and proportions must be recomputed by a calculation engine before rendering and compared against the model’s text for consistency. Any mismatch blocks rendering and falls back to a manual confirmation queue.

    4.4 Citations Are Not Optional

    Every conclusive statement must bind at least one evidence ID; sentences without evidence are downgraded to “to be supplemented” at the rendering stage rather than output directly.

    4.5 Failures Must Be Recoverable

    The pipeline needs to support paragraph-level retries and manual takeover points so that a single failure does not discard the entire document.

    5. Evaluation System: Turning “Usable or Not” into Metrics

    A three-tier evaluation is recommended:

    • Factual tier: numerical accuracy, citation coverage, and metric consistency rate.
    • Structural tier: layout compliance rate, field missing rate, and chart-to-data consistency rate.
    • Efficiency tier: manual revision time, first-pass rate, and number of rework rounds.

    The evaluation set should cover long documents, scanned copies, metric conflicts, empty data, and abnormal data, with fixed random seeds and prompt versions to keep results comparable. After launch, log services and monitoring alerts should continuously collect revision behavior, feeding high-frequency revision points back as regression cases.

    6. Deployment Suggestions on Baidu AI Cloud

    If Baidu AI Cloud is used to host this pipeline, it can be organized by general capability layers: object storage holds raw materials and artifact versions; a message queue decouples parsing and rendering tasks; a container platform hosts stateless rendering and validation services; and log services with monitoring alerts handle full-chain tracing and a quality dashboard. Model calls and business logic are decoupled through configuration switches to support canary releases and rollbacks.

    7. Conclusion

    The progress of the new-generation model in document generation is real, but between “demo-usable” and “production-usable” lie four engineering gates: metric alignment, layout contracts, numerical recomputation, and citation traceability. Treating the model as one stage in the pipeline rather than the entire pipeline is the prerequisite for making professional document generation truly work in production.