New method enables AI for safety-critical situations
MIT researchers have developed a method for making generative AI outputs obey strict safety, physical, and task-specific requirements without retraining the underlying model. Called HardFlow, the algorithm is designed for situations where an answer that is merely “close” can still cause harm — such as planning a robot’s path around people and machinery.
The technique preserves the model’s ability to explore many possible solutions while applying hard constraints to the final result. In experiments involving robotic manipulation, maze navigation, and text-guided image editing, HardFlow satisfied the required constraints and produced higher-quality solutions than existing approaches. as reported by News Mit ## Why intermediate constraints can limit AI
Pretrained generative models, including diffusion systems such as Stable Diffusion and flow-matching models such as FLUX, generate new data by transforming random noise. Their flexibility allows them to be adapted to many tasks, but that flexibility can create problems when outputs must comply with nonnegotiable rules.
A robot path that is almost collision-free, for example, could still send a machine into a human co-worker. To address this risk, existing projection-based methods repeatedly force the model’s intermediate samples — partial solutions created during generation — to satisfy the constraints. The ai research story also surfaces in New AI Architecture Mimics the Human..., adding another angle.
That approach can prevent the model from exploring better options. It may also focus narrowly on feasibility, without improving other qualities such as the length or efficiency of a robot’s route. “For constraint satisfaction, what ultimately matters is the model’s final output, since the internal process is discarded,” says Zeyang Li, a graduate student in mechanical engineering and the Laboratory for Information and Decision Systems and the paper’s lead author.
HardFlow leaves room to search
HardFlow takes a different approach by allowing more freedom during generation and enforcing the hard requirements on the final output. The researchers reformulated constrained sampling as a trajectory-optimization problem, drawing on methods from optimal control.
This lets the algorithm make subtle corrections to the model’s sampling trajectory rather than restricting every intermediate step. Because the task is framed as an optimization problem, HardFlow can pursue multiple goals at once — for example, finding a collision-free route that is also the shortest path to a target. The same ai search question is explored in Kernel-Managed Shared Memory for System-Wide Personalization, which adds a research perspective.
The researchers faced a major computational challenge: the optimization problem surrounds neural networks that may contain hundreds of interconnected layers. To make it practical, they used the structure of flow-matching models to break the problem into a sequence of smaller, single-step problems. They then applied transformations and approximations to create an efficient algorithm that can run at deployment time.
“Control theory gives us a powerful framework for formalizing the optimal way of making these corrections,” says Navid Azizan, senior author of the study and the Alfred H. and Jean M. Hayes Career Development Associate Professor at MIT.
Results and open questions
In testing, HardFlow enabled a robotic manipulator to avoid obstacles while finding a faster route to a target object. Other methods either produced collisions or generated substantially longer paths. Across the experiments, HardFlow consistently outperformed baseline techniques on measures of solution quality while taking comparable or less computation time. The same ai search question is explored in Prompt Revision as a Source of..., which adds a research perspective.
Its deployment-time design also means organizations can apply it to pretrained generative models without retraining them. That plug-and-play quality could be important for applications involving robotics, physical-system control, and computer vision, where safety rules or physical laws cannot be violated.
The research appears 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 say a future direction is extending the framework to settings where the AI model itself can be updated, allowing constraint satisfaction and output quality to improve more adaptively.
