Some AI systems build their output gradually, step by step — planning how a robot arm should move, or editing an image — but nothing in how they are built guarantees the finished result follows a strict, non-negotiable rule. Researchers at MIT built a method called HardFlow that checks whether the rule is met only at the very last step of generation, rather than forcing every step along the way to comply, which leaves the model freer to search for a good answer first. In tests run entirely inside computer simulations, HardFlow satisfied the required rule every time and produced better results than rival methods, without taking longer to compute. It also works on models that are already trained, with no retraining needed. The catch: everything so far has run in simulation, with no independent lab having reproduced the results.
A team at MIT has built an algorithm called HardFlow that lets a class of generative AI models satisfy strict, “hard” requirements on their final output — rules that admit no exceptions, rather than ones the model merely tries to approximate. The researchers point to robotics, the control of physical processes, and computer vision as the kinds of settings where this matters. The work was done by lead author Zeyang Li, a graduate student in mechanical engineering and at MIT’s Laboratory for Information and Decision Systems, co-author Kaveh Alim, and senior author Navid Azizan, an associate professor at MIT’s Department of Mechanical Engineering and Institute for Data, Systems, and Society.
The models in question use a technique called flow matching, which generates an output — an image, or a plan for how a robot should move — by starting from randomness and gradually steering it toward a finished result, using a learned “velocity field” that pushes the process along at each step. HardFlow reframes the problem of enforcing a hard rule on these models as a control problem: it treats small nudges to that velocity field as adjustable controls, and instead of forcing every intermediate step to obey the rule, it only requires the rule to hold at the very end. It breaks the process into a sequence of short, one-step problems it can solve one after another. Because it works this way, it can be applied directly to a model that has already been trained, without retraining it.
“For constraint satisfaction, what ultimately matters is the model’s final output, since the internal process is discarded. By not requiring every intermediate step to satisfy the constraints, we give the model more freedom to find high-quality solutions that are still feasible in the end,” said Zeyang Li.
The authors tested HardFlow against six other methods — most of which check the rule at every intermediate generation step (“projection” methods) or steer the process using a guidance signal — across four tasks: a simulated robot arm avoiding obstacles while reaching for objects (the D3IL benchmark), maze navigation, controlling the boundary conditions of a physical process, and editing images from text instructions. Their argument is that constantly forcing a model’s intermediate outputs to comply with a rule restricts how freely it can explore, which lowers the quality of the final answer compared with checking only at the end.
In the reported experiments, all run in simulation, HardFlow met the required constraint every time while consistently producing higher-quality results than the other methods, and its computation time was comparable to or lower than most of them. In the robotic-manipulation test specifically, HardFlow let a simulated robotic arm avoid the obstacles while also finding the fastest path to its target object, while most of the other methods either collided with obstacles or took substantially longer paths.
“The promise of generative AI is its ability to explore a rich space of possibilities, but the real world places boundaries on which possibilities are acceptable. Our approach lets us preserve that generative power while enforcing the nonnegotiable requirements of high-stakes or safety-critical applications,” said Navid Azizan.
The paper was peer-reviewed and published in IEEE Transactions on Pattern Analysis and Machine Intelligence under the title “HardFlow: Hard-Constrained Sampling for Flow-Matching Models via Trajectory Optimization”. The researchers also say that, in future work, they could extend the framework to settings where the AI model itself gets updated alongside the constraint-enforcement step, which they suggest could improve both compliance and output quality further.
If the pattern holds up outside these tests, HardFlow points to a way of giving an already-trained generative model a firm guarantee about its final output — without retraining it and without the quality trade-off that comes from forcing every intermediate step to comply — which would matter for applications where a violated rule has real consequences, such as robots operating near obstacles.
It does not mean HardFlow has been shown to work on a physical robot or in any deployed system. Every result reported in the paper comes from simulated benchmarks — the D3IL simulator, the Maze2D simulator, a simulated physical-process control task, and image editing — and the paper does not report testing on real hardware or a production system. It also does not mean “perfect constraint satisfaction” is a guarantee that would hold under any condition: the method relies on an approximation of what the final output will look like partway through generation, and its theoretical guarantees depend on mathematical bounds specific to each problem, so a flawless record on these four benchmarks does not establish that the rule would always be met in a different setting.
No lab outside the MIT team has independently reproduced the paper’s benchmark comparisons; the only outside check identified is that IEEE Transactions on Pattern Analysis and Machine Intelligence accepted the paper through peer review, which evaluates methodology and presentation rather than re-running the experiments. Reporting on the result beyond MIT’s own press release consists of sites that republish that release rather than independent journalism, so there is no separate outside verification of the claims described here. It is also not established whether HardFlow can handle the kind of fuzzy, hard-to-formalize safety rules relevant to language-model outputs, as opposed to the geometric and physical constraints tested here, or whether the approach works for generative model families other than flow-matching, such as autoregressive language models.