Constraints are machine-readable restrictions on what an intelligent system can decide, do, or use. These limitations are meant to guide AI towards safe outcomes that make sense in the real world, and that are in line with the goals it’s been given.
Soft constraints can be weighed against one another to guide an optimised decision, whereas hard constraints are boundaries that cannot be violated by AI.
What are soft constraints?
Soft constraints are non-mandatory rules that enable AI to manage trade-offs between competing objectives. Violating soft constraints triggers a penalty function that AI weighs up when operating within a decision framework.
For example, in medicine a system might be constrained to recommend the cheaper of two otherwise identical diagnostic tests. However, it may also be constrained to prioritise reliability. By weighing up these two competing soft constraints, the system may be allowed to recommend a more expensive test if the cheaper one isn’t reliable enough. This would depend on whether the benefit outweighs the penalty according to how the algorithm has been calibrated.
What are hard constraints?
Hard constraints are restrictions, usually within a formal logic system, that cannot be violated by AI. For example, an AI service in a bank might be constrained to never recommend a finance product to someone under the age of 18. This avoids breaking the law.
Both soft and hard constraints can be logical, numerical, ethical, or operational.
Why do constraints matter in the real world?
Constraints play an important role for specialised models and AI agents operating in niche markets or sectors known as verticals. These models have data, rules, workflows and constraints that are optimised for a single domain, such as within law or biotech.
In vertical AI, constraints help to avoid irrelevant or hallucinated results. Properly designed, constraints can also reduce search space, improving performance and speed. Constraints can do this by ensuring that the system stays within set boundaries, using the domain’s own trusted data. These boundaries might include a profession’s rules, standards and logic, for example.
Demand for vertical AI services is growing fast because they can be trusted with high value or critical tasks that enhance domain intelligence. ‘Horizontal’ or general purpose AI, on the other hand, relies more on unstructured data that makes it more flexible but less reliable for certain tasks.
How do constraints work with ontologies?
Vertical AI constraints are often housed within ontologies. Ontologies provide a high-level framework for the knowledge that is in a domain, and define its controlled vocabulary. Ontologies aim to remove ambiguity for both humans and machines, enabling knowledge to be united across different systems using ontology standards.
Constraints, meanwhile, express and enforce these frameworks within the AI system, often in the form of code. They define what must be true or valid. This ensures greater accuracy and trustworthiness based on the domain’s rules.
How do I use constraints with vertical AI?
Vertical AI teams tend to focus on a narrowly defined problem that has verified and structured domain knowledge, enabling the AI model to be highly optimised. This approach was endorsed in a 2025 case study by the Indiana AI Innovation Network called The Art of the Constraint, where it concluded that ‘AI is only as good as its constraints’.
Ontology as a Service (OaaS)
Ontology-as-a-service (OaaS) platforms are emerging that provide a practical development environment for AI builders to create, implement and manage ontologies for constraints to work within, or alongside. OaaS platforms also provide consensus building tools so that domain experts can reach agreement on key concepts and rules, and get a working ontology over the line.