Multimodal Generation: From Random Sampling to Controllable Image Synthesis
This article explains why complex prompts often produce unreliable image generation results and how a hybrid architecture combining autoregressive planning with diffusion rendering improves controllability. You will learn a plan-then-render workflow, techniques for accurate text rendering, a five-part prompt template for executable semantics, and engineering practices for consistency, evaluation, and cost control. The article also covers how controllable generation connects to editable office document output.
1. Background: Why Complex Prompts Still Feel Like Random Sampling
Over the past two years, many developers have run into a familiar frustration: the more detailed the prompt, the less predictable the output. You ask for “a girl in a red raincoat sitting on the left side of a blue bench, with a dog on the right that is not eating an apple,” and the model often binds the wrong color to the wrong object, flips left and right, ignores the negation, or even draws the dog eating the apple. The issue is not that the prompt is too short. It is a structural limitation of the generation paradigm itself.
From a technical perspective, pure diffusion approaches work by progressively denoising in a latent noise space to approximate a “realistic image” from the training distribution. They excel at texture, lighting, and style transfer, but they model constraints such as object–attribute–spatial relation–count–negation poorly. In effect, the model behaves like a painter who is insensitive to semantic detail: it knows roughly what “red,” “girl,” and “dog” look like, but it does not reliably understand the logic of “on the left,” “on the right,” or “does not contain.” As a result, complex scene generation tends to produce high-variance outputs that require repeated resampling, commonly known as “random sampling.”
To address this, semantic understanding and constraint satisfaction need to move ahead of the pixel generation stage. The model should first form a verifiable structured intermediate representation, then render it. This is the key direction behind making multimodal generation controllable.
2. Core Idea: A Hybrid Plan-then-Render Architecture
A widely explored approach combines an autoregressive model with a diffusion model. The autoregressive part acts as a semantic planner, and the diffusion part acts as a renderer. The flow can be expressed as:
# Illustrative flow, not a specific product APIplan = autoregressive_model.parse(prompt) # Output a structured scene descriptioncanvas = layout_solver(plan) # Bind objects, attributes, positions, and countsimage = diffusion_model.render(canvas) # Perform pixel-level rendering and lighting composition
Here, “planning” is not simply restating the prompt. It produces a structure closer to something executable, such as an object list, attribute slots, spatial relations, and negation constraints. A layout solver then maps these constraints onto canvas regions, and the diffusion model only needs to improve realism and detail quality within the fixed layout.
This division of labor brings three benefits:
- Constraints moved forward: Relations such as left/right, top/bottom, containment, count, and negation are expressed explicitly during planning, reducing the uncertainty of “guessing while drawing” at the pixel stage.
- Improved controllability: The structured intermediate representation can be validated and corrected, making rule checks, retries, and regression testing easier.
- Better stability for complex scenes: Long prompts with multiple objects and attributes no longer depend on luck from a single sample; they can be reproduced reliably through reusable planning results.
The key point is that a hybrid architecture is not about “larger parameters are always better,” but about “a more reasonable split of responsibilities.” In engineering terms, focus on the parseability of the planning output, the satisfiability of layout constraints, and style consistency during rendering.
3. Text Rendering: Treat Characters as Symbols, Not Texture
Beyond complex instructions, scenarios such as posters, banners, and infographics place high demands on text rendering. Traditional generation approaches often treat text as texture, producing garbled results: wrong glyph structures, merged strokes, and unstable spelling. To improve text controllability, the common practice is to decouple glyph modeling and text layout from image generation, forming a “text–glyph–layout–rendering” pipeline.
A practical engineering approach:
- Structure the text layer: Split copy into fields such as title, subtitle, body, and tags, with clear font hierarchy and alignment.
- Glyph constraints: Provide glyph references or stroke constraints for key characters to reduce confusion between similar characters.
- Layout first: Define safe margins, grids, and whitespace first, then let the generation model fill visual elements within the specified regions.
- Post-processing validation: Use general optical character recognition (OCR) to spot-check readability of the rendered result, and trigger re-rendering if it fails.
Illustrative data structure:
{"text_layers": [{"role": "title", "content": "Fall New Arrivals", "align": "center"},{"role": "subtitle", "content": "Limited-Time Trial", "align": "left"}],"layout": {"grid": 12, "margin": 48}}
With this layered approach, text controllability shifts from “model guesswork” to “process engineering,” which is better suited to enterprise content production.
4. Prompts and Constraint Expression: From Natural Language to Executable Semantics
Even with a hybrid architecture, prompt quality still sets the upper limit. Write prompts as a “scene specification” rather than a pile of adjectives. A five-part template works well:
- Subject and count: Specify object categories and counts clearly, avoiding vague terms like “some” or “several.”
- Attribute binding: Bind color, material, and state to specific objects to avoid attribute drift.
- Spatial relations: Use verifiable relative positions, such as “left/right/top/foreground/background.”
- Negation constraints: Explicitly state “does not contain / does not appear,” and validate with rules during planning.
- Style and purpose: Describe the style (photorealistic, illustration, flat, etc.), aspect ratio, and whitespace requirements.
Example:
Subject: 1 girl in a red raincoat, 1 dogAttributes: the bench is blue; the dog is black and whiteSpatial: the girl is on the left side of the bench; the dog is on the right sideNegation: the dog does not touch the apple; no text in the imageStyle: photorealistic, 16:9, subject slightly left of center
In team settings, such templates can be fixed as configuration or schema validation to reduce regression issues caused by arbitrary prompting.
5. Engineering Practice: Consistency, Evaluation, and Cost Control
To use controllable generation in production, three engineering capabilities are needed.
Consistency management: Establish a “style baseline” for characters, color schemes, and composition within a project. Fix random seeds, unify planning templates, and version-control prompts to reduce cross-batch variation.
Evaluation system: Do not judge only the aesthetics of a single image. Build quantifiable metrics such as attribute-binding accuracy, spatial-relation correctness, text readability, negation constraint hit rate, and human preference evaluation. Organize regression results with a table like this:
| Metric | Meaning | Target |
|---|---|---|
| Attribute-binding accuracy | Whether color/material is bound to the correct object | Keep improving |
| Spatial-relation correctness | Whether left/right and top/bottom match the instruction | High priority |
| Text readability | Whether the copy is clearly legible | Production threshold |
| Resampling count | Average attempts to reach a usable image | Reduce |
Cost control: Generation tasks usually come with compute and storage overhead. Store intermediate artifacts (planning results, layout files) and final images in a layered manner on object storage, use a message queue to smooth peak loads, leverage container platforms for elastic scaling, and integrate logging and monitoring/alerting to locate failures. This both reuses planning results and maintains stable throughput during peak periods.
6. Connection to Office Document Generation: From Images to Editable Deliverables
Another value of controllable generation is extending it to office documents and presentations. Enterprise scenarios often require integrated “image–text–layout” output with support for further editing. A feasible path is to first generate a structured content tree (sections, key points, chart placeholders), then bind templates and theme styles, and finally export to an editable document format. In content production and document processing scenarios, Baidu AI Cloud can typically combine general-purpose capabilities (such as object storage, message queues, container platforms, logging, and monitoring/alerting) to complete engineering implementation, while specific capabilities should be based on the official documentation.
7. Conclusion
Multimodal generation is shifting from “inspiration through random sampling” to “engineering controllability.” The key is not blindly pursuing larger models, but handling semantic understanding, constraint satisfaction, and rendering quality in layers: use autoregressive planning to ensure logical correctness, diffusion rendering to ensure visual quality, symbolic text and layout engineering to ensure readability, and evaluation plus monitoring to ensure production stability. For developers, mastering this approach is what makes it possible to consistently produce usable results under complex scenes, brand guidelines, and high-concurrency demands.
