Multimodal Generation: Think First, Then Render for Controllable Image Synthesis
This article explains why pixel-fitting models struggle with complex instructions and how a two-stage "reasoning plus rendering" architecture improves controllability. It covers the intermediate representation shared between the two stages, structured decoding of in-image text, and the handling of spatial, counting, and negation constraints. It also offers prompt-writing practices, a multi-dimensional evaluation approach, engineering integration patterns for cloud deployment, and the current capability limits and risks.
1. From “Gacha” to Controllable Generation: Where the Problem Actually Lies
Early image generation was often described as “gacha”: sampling the same prompt repeatedly produced wildly varying quality. The problem gets worse with complex instructions — attribute bindings get scrambled, spatial relations break, negative conditions are ignored, and text inside the image turns into gibberish. The root cause is not that the model “lacks taste,” but an expressiveness bottleneck in the generation paradigm: models trained to fit a pixel distribution have no explicit way to model structured semantics such as symbols, counts, directions, containment, and negation, so they can only “guess” based on the statistical correlations of co-occurrence in the data.
The industry has therefore converged on a shared view: decouple semantic planning from visual rendering. The former turns natural language into an executable scene description and a list of constraints; the latter produces a high-quality image under those constraints. This article takes that general technical route as its subject, explaining why it substantially improves controllability and how to evaluate and integrate it on the engineering side.
2. Core Mechanism 1: Two-Stage Collaboration Between Semantic Planning and Pixel Rendering
The two-stage architecture can be abstracted as a “reasoning kernel plus a rendering kernel.”
- Reasoning kernel: usually an autoregressive model with strong instruction-following and structured-output ability, commonly on the order of billions of parameters. It does not produce pixels directly; it emits an intermediate representation such as a list of scene elements, attribute bindings, relative positions, occlusion relations, camera and style tags, and the text fragments to be drawn.
- Rendering kernel: usually a diffusion-based model that iteratively denoises in latent space and turns the intermediate representation into an image. It excels at materials, lighting, and texture, but is insensitive to complex logic.
An illustrative intermediate representation (pseudocode, not a specific product interface):
{"canvas": {"ratio": "16:9", "style": "photorealistic"},"entities": [{"id": "e1", "label": "girl", "attrs": {"coat": "red"}, "relation": {"pos": "left_of", "ref": "e2"}},{"id": "e2", "label": "bench", "attrs": {"color": "blue"}},{"id": "e3", "label": "dog", "relation": {"pos": "right_of", "ref": "e1"}, "negation": ["eating apple"]}],"texts": [{"content": "SALE", "bbox": [0.1, 0.1, 0.4, 0.2]}]}
This decomposition yields three benefits: constraints become explicit, which makes validation and retries easy; regions can be repainted locally, changing only one entity or text area; and templates can be reused, turning stable layouts into engineering assets.
3. Core Mechanism 2: Structured Decoding of In-Image Text
Text rendering is hard because general-purpose models tend to treat glyphs as texture. A workable approach is to treat characters as symbol sequences and introduce glyph-level conditioning: the planning stage supplies the text content, font style, and bounding box, and the rendering stage constrains the local region using character structure (strokes, baseline, weight, letter spacing). Engineering work is also needed for complex scripts such as Chinese, long-text line wrapping, perspective, and occlusion. The practical recommendation is to render the text layer and the background layer separately, then composite them, so changing the copy does not require repainting the whole image.
4. Core Mechanism 3: Making Spatial, Counting, and Negation Constraints Work
- Spatial relations: express left/right/above/inside with relative position maps or region masks, instead of relying on word order alone.
- Counting and uniqueness: state counts and IDs explicitly to prevent count drift.
- Negation: convert “does not eat the apple” into a negative constraint or a region exclusion, rather than simply concatenating a negated word.
- Consistency checks: after generation, run rule-based validation (are all entities present, are attributes bound correctly, is the text legible) and fall back to re-planning on failure, closing the loop.
5. Prompt and Invocation Practices
- Write the “facts” first, then the “style.” Put facts and relations up front and style at the end to reduce ambiguity.
- Express relations with explicit phrasing, such as “A is to the left of B” or “A is inside B.”
- Declare copy separately, with its content and approximate position.
- Break complex requests into multiple rounds: produce a structural sketch first, then repaint locally.
- Fix the random seed and parameters so results can be compared in regression tests.
6. Evaluation Dimensions: Don’t Just Look at “Nice”
Build a multi-dimensional evaluation set: semantic consistency (hit rate for entities, attributes, and relations), text accuracy (character-level correctness), structural plausibility (occlusion and perspective), aesthetic quality, stability (variance across repeated samples of the same prompt), and editability (success rate of local edits). Prepare 50–100 fixed cases per category and record pass rates and the distribution of failure types; only then can you determine the capability boundary.
7. Engineering Integration and Cloud Deployment
A typical pipeline: an access layer handles authentication and rate limiting; a task queue smooths out peaks; inference services are kept stateless and scaled horizontally; object storage holds source images and intermediate artifacts; logging and monitoring with alerting track latency, failure rate, and retry rate; and caching is used under high concurrency (reusing results for identical prompts and parameters). For cost control, generate a small preview first and render in high resolution only after confirmation, which significantly reduces wasted compute. If you use Baidu AI Cloud capabilities, a general combination works: a container platform to host inference services, object storage for assets, a message queue to decouple tasks, and logging plus monitoring for observability.
8. Capability Limits and Risks
This class of approach can still fail on extreme occlusion, very long text, rare glyphs, and fine-grained count errors. Content safety filtering must happen up front, and generated results should carry labels and be auditable. For production systems, always design failure fallbacks and a human review step, and avoid feeding probabilistic output directly into compliance-sensitive scenarios.
9. Conclusion
The key leap in multimodal generation is upgrading from “draws a convincing picture” to “thinks clearly and draws accurately.” Understanding two-stage collaboration, structured decoding, and constraint validation is what lets developers balance controllability, cost, and experience, and build generative applications that are genuinely deliverable.
