DEV Community

yuer
yuer

Posted on

Fixing Identity Drift in AI Image Generation with a Deterministic Constraint Layer (Minimal PoC Inside)

Fixing Identity Drift in AI Image Generation with a Deterministic Constraint Layer (Minimal PoC Inside)

Everyone building image or multimodal applications knows this pain:

  • you generate the same character twice → the face changes
  • change the angle → body ratio collapses
  • add more iterations → drift becomes uncontrollable
  • and the model “just does whatever it wants”

People call it randomness.

But it’s actually a missing structure problem.

Today I’m sharing a small, fully reproducible PoC that stabilizes:

✅ identity

✅ body ratio / geometry

✅ scene semantics

✅ lighting context

❌ without fine-tuning

❌ without LoRA

❌ without prompt hacks

Just a deterministic constraint layer.


✨ Why this PoC works

Most generation pipelines have:

  1. a model
  2. a prompt
  3. a hope that it behaves

This PoC adds a missing piece:

4. A deterministic constraint layer

The constraint layer defines:

  • identity anchors
  • ratio + geometry targets
  • allowed semantic drift
  • forbidden alterations
  • reproducible prompt assembly
  • stable configuration YAML

The model keeps its creativity,

but the “rails” prevent drift.


🧩 Core idea

Control doesn't come from more parameters — it comes from structure.

The model predicts.

The constraint engine limits the space of acceptable predictions.

This hybrid gives you:

  • stable identity
  • consistent proportions
  • fixed scene context
  • reproducible runs
  • simple code anyone can extend

📦 GitHub Repo (Minimal, Safe, No Hidden Tricks)

👉 https://github.com/yuer-dsl/vertex-deterministic-agents-poc

This is a small, practical PoC — not a full framework.

I designed it so normal engineers can read the code in minutes.

Files include:

  • structured_multimodal_constraints.yaml
  • constraint_loader.py
  • multimodal_prompt_builder.py
  • deterministic_agent_stub.py
  • parse.py

Everything is deterministic and reproducible.


🔧 When should you use this?

  • building a multimodal app
  • stabilizing an image pipeline
  • doing character-consistent content
  • prototyping product features
  • improving reproducibility for demos
  • replacing fragile prompt engineering

If you ever felt:

"This model is strong, but impossible to control."

Then the deterministic layer solves exactly that.


👤 Author

Yuer — independent engineer exploring deterministic AI, multimodal stability, and structured reasoning layers.


💬 Open to discussion

If you want a version for other models (Claude, OpenAI, PixArt, stable-diffusion, etc.), just drop a comment or open an issue in the repo.

Let’s make AI powerful AND predictable.

Top comments (0)