A Two-Stage LLM Workflow for Publication-Quality Academic Figures
Separating diagram logic from visual rendering makes LLM-assisted academic figure creation more reproducible and easier to validate. This article explains how to define structured diagram specifications, apply reusable rendering styles, build an automated validation loop, and scale the workflow into a pipeline for batch figure production.
1. Why Academic Figures Have Two Separate Quality Barriers
In research papers and technical reports, figures can communicate complex relationships more efficiently than prose. A clearly structured diagram often shapes a reviewer’s first understanding of a method. Producing a high-quality academic figure, however, involves two distinct challenges:
- Logical accuracy: Authors must break a method down into modules, data flows, variable relationships, and causal chains. Every element in the figure must correspond to the written description.
- Visual quality: Even when the logic is correct, colors, whitespace, font hierarchy, arrow semantics, and grid alignment require careful adjustment to meet publication standards.
Traditional workflows combine these tasks: authors reason about the method while manually arranging elements in a drawing tool. Visual editing interrupts logical thinking, while changes to the underlying logic undo layout work.
Separating these responsibilities is the key to a more efficient and consistent workflow.
2. The Core Idea: Separate Logic from Rendering
The workflow divides figure creation into two independent but complementary stages:
- Logical construction—the architect role: Determines what the figure should show and why. Its output is a structured specification independent of the rendering implementation.
- Visual rendering—the renderer role: Determines how to present that specification clearly and consistently. It takes the specification as input and produces the figure.
This separation offers three immediate benefits:
- Specifications can be version-controlled and reused.
- Renderers can be replaced without changing the diagram’s logic.
- Each stage can be validated independently, making problems easier to diagnose.
The structured specification serves as the contract between the two stages.
3. Stage One: Build the Logical Specification
An AI coding tool with reasoning and programming capabilities handles logical construction. Its inputs include the paper’s method description, equations, variable definitions, and the author’s intended message. Its output is a declarative diagram specification.
Use a structured format rather than a free-form natural-language description. For example:
{"canvas": { "width": 1200, "height": 800, "grid": 20 },"layers": [{ "id": "input", "label": "Raw Input", "type": "dataset" },{ "id": "encoder","label": "Feature Encoding", "type": "module" },{ "id": "fusion", "label": "Multi-Source Fusion", "type": "module" },{ "id": "head", "label": "Task Output", "type": "output" }],"edges": [{ "from": "input", "to": "encoder", "semantics": "data" },{ "from": "encoder", "to": "fusion", "semantics": "feature" },{ "from": "fusion", "to": "head", "semantics": "prediction" }],"annotations": [{ "target": "fusion", "text": "Attention Weighting", "style": "note" }],"constraints": ["No crossing connections","Horizontally align elements in the same layer","Use only three arrow semantics"]}
Three principles matter when designing the specification:
- Make semantics explicit. Label the meaning of each connection, such as data flow, feature flow, or gradient backpropagation. The renderer should not have to infer it.
- Define constraints upfront. Express requirements such as alignment, non-crossing connections, and minimum font size as machine-checkable constraints rather than leaving them to the renderer’s discretion.
- Keep terminology consistent with the paper. Every node label should map to a term in the text, preventing discrepancies between the figure and the method description.
4. Stage Two: Render the Figure
The rendering stage maps the specification to graphical elements and styles. A template-and-stylesheet approach makes publication conventions reusable rather than requiring them to be recreated for every figure.
The following illustrative code shows the rendering pattern:
STYLE = {"font": {"size": 14, "min_size": 11},"palette": ["#2E5EAA", "#7A9E7E", "#C46A4A"],"arrow": {"data": "solid", "feature": "solid", "gradient": "dashed"},"spacing": {"node_gap": 40, "layer_gap": 80}}def render(spec, style=STYLE):canvas = new_canvas(spec["canvas"], grid=spec["canvas"]["grid"])for layer in spec["layers"]:canvas.place(layer, align="center", style=style)for e in spec["edges"]:canvas.connect(e["from"], e["to"], style=style["arrow"][e["semantics"]])canvas.apply(style["palette"])return canvas.export(format="svg") # Prefer vector output
Practical rendering guidelines include:
- Prefer vector output. Vector figures remain sharp when resized for paper layouts or printing. Use raster images for previews.
- Limit the color palette. Generally, use no more than three or four primary colors and check that the palette is color-blind friendly.
- Enforce a minimum font size. Labels must remain readable at the figure’s final printed dimensions.
5. Close the Loop with Automated Validation
The two-stage workflow becomes more useful when rendering is followed by validation. If a figure fails a check, return to logical construction and repair the specification rather than manually editing the image.
spec = architect.build(method_text)for i in range(MAX_ITER):img = renderer.render(spec)issues = checker.validate(img, spec, constraints)if not issues:breakspec = architect.repair(spec, issues)
Validation can check whether:
- Elements extend beyond the canvas.
- Connections cross.
- Font sizes fall below the required minimum.
- Labels match the terminology used in the paper.
- The legend is complete.
Turning these checks into executable rules is what distinguishes this workflow from one-shot image generation. Corrections remain part of the specification, preserving reproducibility instead of accumulating undocumented manual changes.
6. Turn the Workflow into a Production Pipeline
When figure requirements expand from a single diagram to batches—such as multiple ablation studies or comparisons across datasets—the workflow should become a reusable pipeline.
Key components include:
- Template and style libraries: Maintain templates for different paper types, with each specification describing only the differences.
- Batch generation: Drive rendering through configuration files and apply consistent output names and version numbers.
- Artifact storage and distribution: Archive rendered figures together with their specifications in object storage for traceability and collaboration.
- Execution infrastructure: Run the pipeline on a container platform and use a message queue to decouple construction tasks from rendering tasks.
- Observability: Use logging, monitoring, and alerts to track failure rates, average iteration counts, and processing time. These signals help identify declining specification quality.
Baidu AI Cloud is one platform on which these general infrastructure components—container platforms, object storage, message queues, logging, monitoring, and alerts—can be combined to support the pipeline. The workflow itself does not require any stage to be tied to a proprietary implementation.
7. Common Pitfalls
- Generating images without a specification: This may appear faster initially, but it makes results difficult to reproduce and revise, increasing rework.
- Leaving constraints undefined: Giving the renderer complete discretion over visual decisions can cause styles to drift across repeated generations.
- Allowing figure terminology to diverge from the text: Inconsistent labels are a common source of reviewer feedback.
- Confusing exploration with delivery: Trying multiple approaches is useful during exploration. Once the workflow moves into delivery, fix the templates and validation rules to keep outputs reproducible.
8. Conclusion
The central bottleneck in academic figure production is the forced coupling of logical reasoning and visual design. A two-stage workflow separates these responsibilities: logical construction defines the figure’s meaning, while visual rendering applies presentation standards.
Using a structured specification as the sole contract between stages allows reasoning to focus on correctness and rendering to focus on consistency. Automated validation then closes the loop. Combined with reusable templates and general-purpose cloud infrastructure, this approach supports both careful refinement of individual figures and reproducible batch production.
