Multimodal Image Generation: Logical Constraints and Text Rendering Explained

    This article breaks down why complex prompts often cause multimodal image generation to lose control, and how a two-stage "plan then render" architecture addresses the issue. It covers structured intermediate blueprints for spatial, attribute-binding, and negation constraints, the role of diffusion models in pixel synthesis, and techniques for rendering readable text as discrete symbols. It also provides practical guidance on structured prompting, evaluation metrics, common pitfalls, and a general cloud deployment path.

    1. Why Complex Instructions Cause Image Generation to Drift

    In real applications, users rarely provide a simple description of isolated nouns. Instead, they issue compound instructions with explicit spatial relationships, attribute bindings, and negation conditions—for example, “a girl in a red raincoat on the left, and a dog that does not eat apples on the right.” Such requests impose three categories of constraints on a generation system:

    • Spatial constraints: the relative positions of subjects must remain stable.
    • Attribute-binding constraints: attributes such as color and material must bind to the correct subject without drifting.
    • Negation constraints: the system must express “not included / does not happen” rather than simply ignoring it.

    The traditional approach maps text directly to a pixel distribution using a single end-to-end generation network. This works reasonably well for short prompts with a single subject, but as the number of constraints grows, problems such as attribute drift, subject substitution, and reversed relationships appear. The root cause is that the text encoder provides only a global conditioning vector; spatial and logical relationships are not explicitly decomposed into executable intermediate representations. The model must rely on implicit alignment from the data distribution, which limits generalization.

    2. Architecture: A Two-Stage “Plan First, Render Later” Paradigm

    A widely discussed approach separates “understanding and organization” from “drawing and rendering,” forming two stages with clear responsibilities.

    2.1 Planning Stage: Turning Natural Language into a Structured Blueprint

    The planning stage is typically handled by an autoregressive model with strong language modeling capability. It does not produce pixels directly; instead, it outputs an intermediate representation such as a list of scene elements, attribute slots for each element, relative position relationships, and content to exclude. A schematic intermediate structure can be expressed as:

    1. {
    2. "canvas": {"width": 1024, "height": 1024},
    3. "objects": [
    4. {"id": "girl", "attrs": {"coat": "red"}, "relation": {"to": "bench", "pos": "left"}},
    5. {"id": "dog", "attrs": {"action": "not_eating_apple"}, "relation": {"to": "bench", "pos": "right"}},
    6. {"id": "bench","attrs": {"color": "blue"}}
    7. ],
    8. "negatives": ["apple_in_dog_mouth"]
    9. }

    The value of this approach is that constraints become explicit, verifiable, and reusable. On the engineering side, rule-based validation can run on the blueprint before rendering—checking subject count, position conflicts, and completeness of attribute slots—so that some errors are intercepted before generation begins.

    2.2 Rendering Stage: Pixel Synthesis with a Diffusion Model

    The rendering stage is typically handled by a diffusion-based model. It takes the blueprint and text conditions as joint input and generates an image through multi-step denoising. The focus here is image quality, lighting consistency, and texture detail—not another round of semantic reasoning. With the two stages decoupled, the rendering model no longer carries the burden of complex logical understanding, and the planning model does not need to concern itself with pixel-level detail. Each has a clearer capability boundary.

    2.3 Why This Separation Works Better

    • Errors are easier to localize: when something goes wrong, you can tell whether it was “understood incorrectly” or “drawn incorrectly.”
    • Stronger controllability: adjusting the blueprint changes the composition without repeatedly rewriting long prompts.
    • Easier engineering integration: the blueprint is structured data, suitable for caching, auditing, and batch task orchestration.

    3. Text Rendering: From “Texture” to “Symbol”

    Text in images has long been a difficult problem. If text is treated as ordinary texture, the model only learns approximate statistical features of strokes, producing results that look like characters but are unreadable. A more reasonable approach is to treat text as a discrete symbol sequence and introduce an encoding path with text-understanding capability, so that glyph shape, character order, and semantics all enter the conditioning information. Key practices include:

    • Clearly separate “text content in the image” from “description of the image” to prevent the two from contaminating each other.
    • Provide structured constraints for font, size, and layout position instead of a single vague instruction like “add a title.”
    • For long text, use segmented rendering or post-composition to reduce the difficulty of one-shot rendering.
    • Establish a readability check, such as character-level comparison, as a basis for automatic filtering.

    4. Engineering Practices for Prompts and Invocation

    Regardless of the underlying implementation, the calling side can significantly improve stability through structured prompts. It is recommended to split the prompt into four sections: subjects and attributes, spatial relationships, negation conditions, and output specifications.

    1. [Subjects] Girl (red raincoat), dog, blue bench
    2. [Relations] Girl is to the left of the bench; dog is to the right of the bench
    3. [Negation] Dog does not touch the apple; no other people in the image
    4. [Specs] 1024x1024, poster style, reserve a title area in the upper-left corner, title text is "Autumn Prompt"

    Additional engineering recommendations:

    1. Run a small-size test first to confirm structure and relationships, then scale up for final output.
    2. Fix the random seed for A/B comparison to isolate the impact of prompt changes.
    3. Set up a task queue and retry mechanism for batch jobs.
    4. Archive the generation result, blueprint, and prompt together for traceability.

    5. Evaluation Dimensions: How to Measure “Better Obedience”

    It is recommended to build a quantifiable evaluation set across five dimensions:

    • Relationship accuracy: whether relative positions are completely correct.
    • Attribute-binding accuracy: whether color and material land on the correct subject.
    • Negation compliance rate: whether excluded elements truly do not appear.
    • Text readability rate: the proportion of characters correct at the character level.
    • Visual quality: sharpness, structural soundness, and style consistency.

    The evaluation set should cover four sample types: single subject, multiple subjects, long text, and strong negation. Regression testing should be run after each prompt strategy or parameter adjustment to avoid judging results “by feel.”

    6. A General Path to Cloud Deployment

    To carry this capability in production, a combination of general cloud components can be used: a container platform to host inference services with elastic scaling, object storage to save inputs, outputs, and blueprint data, a message queue for asynchronous task decoupling, and logging and monitoring services with alerting to track success rate, latency, and failure causes. Baidu AI Cloud offers corresponding capabilities in these general categories, and you can choose managed or self-hosted options based on business scale. The key is to connect “generation—validation—archiving—regression evaluation” into a closed loop.

    7. Common Pitfalls and How to Avoid Them

    • Pitfall 1: Treating long prompts as a master key. The more constraints there are, the more you should structure them rather than pile on adjectives.
    • Pitfall 2: Looking only at single-image results. You should look at the stable pass rate on a fixed evaluation set.
    • Pitfall 3: Ignoring negation. Negation must enter the intermediate representation, or it is very likely to be ignored.
    • Pitfall 4: Mixing text and image description. The two use different conditioning paths and should be described separately.

    8. Summary

    For image generation under complex instructions, the core is not making the model “draw more flashily,” but making it “think clearly before acting.” Decoupling semantic planning from pixel rendering, modeling text as symbols, structuring prompts, and automating evaluation—these four steps form a reusable practical framework and a key yardstick for assessing whether a new generation of multimodal generation capabilities has truly advanced.