Multimodal Image Generation: Engineering Logic Enhancement for Complex Instructions
This article explains why image generation models often fail on complex prompts involving spatial relationships, attribute binding, and negation, and how a two-stage planning-and-rendering architecture addresses these issues. It covers structured intermediate representations, prompt compilation, controllable text rendering, and quality gating, offering practical guidance for building reproducible and evaluable generation pipelines.
1. The Problem: Why Image Generation Fails on Complex Instructions
Generative image capabilities have spread quickly over the past two years, but in real business scenarios, users now expect accuracy rather than just visual appeal. A single instruction containing spatial relationships, attribute binding, and negation—for example, “A girl in a red raincoat sits on the left side of a blue bench, and on the right is a dog that is not eating an apple”—often leads to incorrect output: mismatched colors, swapped subject positions, or ignored negative conditions.
From an engineering perspective, the issue is not how good the image looks, but whether the semantics are correctly grounded. Traditional diffusion-based approaches focus on pixel denoising and typically use text only through global conditioning, lacking explicit semantic structure modeling. As a result, when an instruction involves multiple subjects, multiple attributes, relative positions, or inclusion and exclusion relationships, the model tends to suffer from “condition leakage” and “attribute bleeding.”
One point should be clear from the start: image generation in complex scenarios is essentially a joint task of language understanding, scene planning, and visual rendering. Optimizing only the rendering side yields limited gains; moving semantic parsing and layout planning upstream is the key to improving stability.
2. Architecture: The Engineering Value of a Two-Stage “Plan-Then-Render” Pipeline
A widely validated approach is to split the generation flow into two stages. The first stage uses a large model with strong semantic understanding to perform intent parsing and structural planning, producing an intermediate representation. The second stage uses a rendering model to generate pixels based on that intermediate representation.
The flow can be described with pseudocode:
instruction = user inputplan = planner.parse(instruction)# plan contains at least: entity list, attribute bindings, spatial relations, negative constraints, canvas ratioimage = renderer.render(plan)
This architecture provides three key benefits:
- Semantic interpretability: the intermediate representation can be logged, reviewed, and replayed, making it easier to locate failure causes.
- Reusable constraints: the same plan can drive multiple rounds of regeneration while keeping subjects and layout consistent.
- Replaceable components: the planning model and the rendering model can be upgraded independently, reducing system coupling.
For implementation, it is recommended to define a stable schema for the intermediate representation and validate fields strictly. An example structure is shown below:
{"canvas": {"ratio": "3:4"},"entities": [{"id": "girl", "attrs": {"color": "red", "cloth": "raincoat"}},{"id": "dog", "attrs": {"action": "not eating apple"}}],"relations": [{"type": "left_of", "subject": "girl", "object": "bench"},{"type": "right_of", "subject": "dog", "object": "bench"}],"negations": ["dog eats apple"]}
With a structured intermediate layer, the system can run consistency checks before rendering, such as detecting duplicate attribute bindings, conflicting positions, or incorrectly materialized negative items.
3. Semantic Alignment: Replacing Natural-Language Stacking with Structured Prompts
Many failures are not caused by insufficient model capability but by imprecise prompt expression. In practice, it is recommended to rewrite natural language into a four-part structure of subject, attribute, relation, and constraint, while explicitly declaring the canvas ratio and viewpoint.
Comparison example:
Weak prompt: red raincoat girl, blue bench, dog, apple, left, rightStrong prompt: subject A = girl, attribute = red raincoat; subject B = dog, attribute = not eating apple;relation = A is to the left of the bench, B is to the right of the bench; canvas = portrait 3:4; viewpoint = eye-level medium shot
In a business system, a prompt compilation layer can be added on the server side to convert colloquial user input into a normalized structure before sending it into the generation pipeline. This lowers the expression burden on end users and makes unified governance and gradual rollout easier.
In addition, attribute binding should follow a locality principle: each attribute binds to only one entity to prevent adjective drift in long sentences. For multi-subject scenes, generating subject masks or region hints first and then rendering can significantly reduce color bleeding and misplaced elements.
4. Controllable Text Generation: From Texture Noise to Symbolic Layout
Text in images has long been a difficult problem. The reason is that general rendering models tend to treat text as texture and lack glyph structure priors. To improve text accuracy, engineering practice usually introduces dedicated text encoding and glyph alignment modules, treats characters as decomposable stroke structures, and strengthens character-level supervision during training or inference.
Implementation recommendations include:
- Text layering: separate the “scene content prompt” from the “in-image copy” to avoid interference.
- Glyph constraints: provide explicit parameters such as font style, weight, and letter spacing for key copy.
- Region reservation: determine a safe area for the copy first, then let the rendering model generate within that area.
- Post-verification: use recognition capability to perform character-level comparison on the generated result and automatically retry if it does not meet the standard.
Example flow:
copy = "Happy Mid-Autumn Festival"safe_box = layout.reserve(copy, ratio="16:9")image = render(scene, text=copy, box=safe_box, style="bold serif")if not verify_text(image, copy):image = retry_with_stricter_box(image)
For copy-heavy scenarios such as posters, banners, and e-commerce main images, it is recommended to monitor text accuracy as an independent quality metric rather than relying only on overall visual scoring.
5. Layout and Controllability: Turning Trial-and-Error into a Reproducible Engineering Process
To bring a generation system into production, it must be reproducible, repeatable, and evaluable. A three-layer control approach is recommended:
- Structural control: fix the canvas ratio, number of subjects, and region divisions to reduce randomness.
- Parameter control: bring random seeds, sampling steps, and guidance strength into configuration management to ensure the same input is reproducible.
- Quality gating: set thresholds for semantic consistency, text accuracy, and subject completeness, with automatic retry or fallback when they are not met.
For cloud implementation, general capabilities can be combined: object storage holds intermediate plans and final images, a message queue smooths traffic peaks, a container platform hosts inference services, and logging and monitoring with alerting track failure and retry rates. Baidu AI Cloud offers mature solutions in these general categories and can be combined flexibly according to business scale, without being tied to specific proprietary interfaces.
It is also recommended to build an evaluation set covering difficult samples such as spatial relations, negative semantics, multi-subject attribute binding, long copy, and small font sizes, forming a fixed regression baseline. Only when “it feels better” is turned into quantifiable metrics can optimization be sustained.
6. Conclusion
The next stage of competition in multimodal image generation will not be about single-point rendering tricks, but about a complete engineering loop of semantic understanding, structural planning, controllable rendering, and quality regression. Developers should prioritize building a structured intermediate representation and a prompt compilation layer, breaking complex instructions into a set of verifiable constraints and then handing them to the rendering model. Combined with text symbolization, region reservation, and automatic retry mechanisms, this is how generation results move from occasionally usable to stably deliverable.
