LLM Document Generation: End-to-End Practices from Slides to Reports

    This article examines the challenges and engineering practices of LLM-based structured document generation. Using a financial report analysis task, it compares model outputs and introduces a three-level capability model: description, analysis, and decision-making. It then presents a practical pipeline covering structured data ingestion, staged generation with human review, deterministic rendering, and programmatic validation, followed by engineering recommendations for reliability and traceability.

    1. Why Document Generation Is a Hard Problem for LLMs

    After general conversational capabilities matured, industry attention gradually shifted toward structured outputs: presentations, spreadsheets, and analytical reports—the kinds of deliverables that can be handed off and used directly. Compared with natural language Q&A, these outputs present three notable difficulties:

    1. Strict format constraints. Presentations have layout, hierarchy, and font specifications; spreadsheets have row-column structures, formulas, and data type validation. Model output must not only be semantically correct but also consumable losslessly by downstream tools such as office software parsers.
    2. Data must be traceable. In a financial report analysis, if any percentage cannot be traced back to the source data, business stakeholders will not trust it. This requires the model to read structured data, perform calculations, and cite references, rather than “writing numbers by feel.”
    3. Evaluation criteria are multi-dimensional. Content accuracy, logical completeness, layout usability, and format compatibility need to be evaluated separately and then scored comprehensively.

    For this reason, from “making slides look good” to “making reports usable,” the industry has spent considerable time closing this capability gap.

    2. A Typical Capability Evaluation: Financial Report Analysis Task

    A common industry evaluation method is to give multiple models the same real-world task. For example, the input is a quarterly financial data table for a retail company, and the requirement is to produce a management-oriented business analysis report.

    In one comparative test (model names were neutralized), representative differences emerged:

    • Model A: It completed basic descriptive statistics, identified revenue trends and summarized causes, but its conclusions remained at a general level such as “sales grew somewhat.” After reading it, management still did not know what to do next.
    • Model B: It added three strengths on top of that:
      1. It front-loaded core conclusions—putting key numbers such as 5.3% sales growth directly into section headings so readers could grasp the main point immediately.
      2. It further decomposed the data, for example distinguishing the performance of online channels from offline stores, instead of lumping all growth causes together.
      3. It provided actionable business recommendations based on the data, such as specific adjustment directions for underperforming business lines.

    The root cause of this difference is not “writing skill,” but the model’s depth of understanding of structured data and its ability to decompose tasks. Reduced to a methodology, document generation tasks have three levels:

    Level Capability requirement Typical manifestation
    Description Read data and restate it accurately State how much growth occurred
    Analysis Break down dimensions and identify structure Distinguish online and offline differences
    Decision Combine business logic to give recommendations Output actionable business actions

    3. Technical Implementation Path: Building a Reliable Document Generation Pipeline

    When enterprises implement this capability in their own systems, they typically use the following pipeline:

    3.1 Input Side: Structured Data Ingestion

    Convert original tables (financial reports, operational data) through a parsing service into an intermediate format that the model can consume reliably:

    1. import pandas as pd
    2. # Normalize financial report data before passing it to the model
    3. df = pd.read_excel("financial_report.xlsx")
    4. df = df.dropna(how="all").fillna(0)
    5. context = {
    6. "columns": list(df.columns),
    7. "summary": df.describe().to_dict(),
    8. }

    The key is to perform data validation and summarization before sending data to the model, avoiding truncation and omission caused by overly long tables.

    3.2 Generation Side: Staged Generation Rather Than One-Shot Output

    In practice, a more robust approach is to split the task into multiple stages of calls:

    • Stage 1: Have the model output an analysis outline and key conclusions (plain text, making it easy to manually review numbers).
    • Stage 2: Based on the reviewed outline, generate a structured intermediate representation (for example, JSON describing each slide’s title, bullet points, and chart type).
    • Stage 3: Use deterministic code to render the intermediate representation into the target format.
    1. slides_schema = {
    2. "slides": [
    3. {
    4. "title": "Sales grew 5.3% year over year",
    5. "bullets": ["Online channels contributed the main increment", "Store business was roughly flat"],
    6. "chart": {"type": "bar", "data_ref": "channel_revenue"}
    7. }
    8. ]
    9. }

    Decoupling “uncertain generation” from “deterministic rendering” is a key design for controlling format quality.

    3.3 Rendering Side: Deterministic Output

    Whether generating slides or spreadsheets, the final step should use programmatic libraries rather than letting the model directly emit binary or complex markup content. With cloud object storage, generated results can be saved and archived directly, and a message queue can trigger downstream notifications to form a complete automated workflow.

    4. Engineering Recommendations

    1. Build a layered evaluation set. Break document generation into three types of test cases—data accuracy, conclusion reasonableness, and format usability—and run regression tests separately, rather than looking only at overall appearance.
    2. Numbers must be programmatically validated. For every number in a report, recompute it from the source data with code and compare the results to prevent hallucinated numbers. A simple approach is to extract values with regular expressions and assert:
    1. assert abs(reported_growth - computed_growth) < 0.001
    1. Use prompt constraints to front-load conclusions. Explicitly require in the prompt that “each section heading must contain the core numeric conclusion.” This can significantly improve readability—and it is a transferable technique from the better-performing model in the evaluation above.
    2. Move human review earlier. In a multi-stage pipeline, place human confirmation at the outline stage rather than the final document stage. This has the lowest cost and the highest return.

    5. Conclusion

    Progress in structured document generation is essentially LLMs crossing from “language capability” to “business capability”: whether they can read data accurately, break down dimensions finely, and turn recommendations into concrete actions. For developers, rather than expecting the model to get everything right in one step, it is better to build an engineering chain of “data validation—staged generation—deterministic rendering—programmatic acceptance,” so that LLM capabilities can be delivered as real productivity within a reliable framework.