BriConstrain: Geometrically Constrained Decoding
for Autoregressive Brick Assembly Generation

Nadav Magar1 Amir Hertz2 Ariel Shamir3* Or Patashnik1*
1Tel Aviv University 2Google DeepMind 3Reichman University *Equal advising

The same caption decoded three ways. Freeform decoding places colliding parts (red). Rejection sampling redraws a part when it collides (orange) and keeps it when all eight draws collide. BriConstrain filters colliding placements out before sampling, so collisions are rare. Pick a build above the panels; drag a view to orbit.

Abstract

Language models can generate LEGO assemblies from text, but their builds often contain parts that collide or attach to nothing. The usual approach of rejecting and resampling invalid placements discards decoded tokens without guaranteeing a valid build.

We present BriConstrain, a constrained decoding method that restricts a pretrained language model's next-token probabilities before sampling, steering it towards valid placements. Because the validity of a brick placement depends on the non-predetermined build state, it cannot be compiled into a fixed grammar and must be checked dynamically. However, checking the validity of a brick before sampling is challenging as the space of valid placements is combinatorially large and cannot be enumerated exhaustively.

Our key idea is to narrow the search space by constraining how parts attach rather than which parts attach to each other. Concretely, given the model's predictions of the currently placed part, and the previously placed parent it wants to connect to, we constrain the model's choice of how they attach. This allows us to span the space of part attachments, using a precomputed geometric oracle, and to effectively filter out colliding options. With valid attachment candidates in hand, we bias the model's next-token distribution towards the remaining valid candidates.

We evaluate our method on two LEGO formats and models: BrickNet, which annotates connectivity explicitly, and our proposed Implicit Connectivity LDraw Format (ICLF), which uses numeric values for placements and leaves connectivity implicit. Our method raises collision-free builds from 31% to 91% on BrickNet and from 15% to 65% on ICLF, and outperforms rejection sampling on both formats at about 60% of its decoding cost.

Video

How it works

Inside one decoding step

Every candidate attachment at a step, with the probability the model gives it before (orange) and after (blue) the constraint. Pick a build, scrub through its steps on the timeline, and hover a candidate to find it in 3D.

BibTeX

@article{briconstrain2026,
  title   = {BriConstrain: Geometrically Constrained Decoding
             for Autoregressive Brick Assembly Generation},
  author  = {Magar, Nadav and Hertz, Amir and Shamir, Ariel and Patashnik, Or},
  journal = {arXiv preprint},
  year    = {2026}
}