AI that follows the rules — and knows when not to

The recipe, and two demos that show it in practice

Most attempts to make an AI follow the rules pour the whole rulebook into it and hope it complies. It does not, and that can be measured. Here is a running demo built on the opposite principle: it looks up the single rule when it is needed, answers only when the source covers the question, and holds back or refers to a human when it does not. The goal is an AI that fails as little as possible, and predictably when it does. The way there is that it can say when it doesn't know, instead of guessing.

Try them

Two demos, one for each side of the recipe. Both run on open language models and are demonstrations of the research, not finished products.

The tutor is also the safe, public stand-in for a more sensitive field. The same architecture was built for a counselling-area conversation demonstration, but that one is deliberately not offered to the public: a public mental-health chatbot is, in substance, a regulated medical device under EU rules, and a disclaimer does not exempt it. The tutor is deliberately built with no grading, no scoring and no emotion recognition, the very things that would make an education AI a high-risk use under the AI Act. Finding those lines is itself part of the work: a responsible system also knows the limit on its own reach. Research access to the counselling architecture can be arranged.

The one idea: optimal, not perfect

Following a rule is an internal race between routes, like any other action. The rule's route has to win the races it should win and yield the ones it should yield. It can fail in two ways. It can ignore the rule under pressure, so the rule loses a race it should have won. Or it can follow the rule so rigidly that it refuses legitimate things and turns useless. An assistant tuned to "never break a rule" lands in the second ditch. The right place is the middle, where it follows the rule when it should and gives way when it should.

The same holds for holding back. A model that answers everything fabricates confident answers when the source is missing. A model trained to always hold back ends up withholding on what it actually knows. What works is the selective middle: answer what is covered, hold back on what is not. That is what the demos try to hit.

The recipe: how to build a maximally compliant AI system

This is the most reliable compliance you can build, and it rests on one architectural choice. Compliance is behaviour, not information, so you install the behaviour and look the rules up, instead of pouring the whole rule-set into either the prompt or the weights.

The one choice, in short

The rule of thumb: behaviour → fine-tune. Knowledge and rules → look up (RAG).

Behaviour, rule, or knowledge? And where the line falls

What decides it is whether the answer depends on the situation. It is not about what you call it. Four types on a sliding scale:

A concrete example: one topic, three types. Picture an assistant that handles names in documents.

Same topic, names, but three different homes, because one needs judgement and the other does not.

Yes, the transition is a gradient, and the clean test is two questions. Does it apply the same way every time, regardless of the case? Then fine-tune it in. Does the right answer change with the situation or the facts, and do you need to see which one applied? Then look it up. The boundary case shows it: "always redact names" fine-tunes fine, because it is deterministic, while "redact names except when the requester is the person themselves" is conditional and belongs in RAG. Same topic, each side of the line, because one needs judgement and the other does not.

Step by step

knowledge one phrasing: 38 % same knowledge four phrasings: 94 %
Why steps 3 and 5 are there. The same 25 facts loaded in one way are found again 38 percent of the time. Loaded four ways they are found 94 percent of the time, with no extra training. Each new phrasing is another way in to the same place, and the question only has to hit one of them.

Is this the right architecture for you?

Choose it when you want maximum reliable compliance with a fixed rule-set and a clear view of where it is about to break a rule; when the rules change (RAG updates without retraining); and when a confident wrong answer is costly. Watch two things. It is optimal, not perfect: it will sometimes abstain on something it could have answered, and that is the safe trade. And the choice of base model matters: a standard chat model cannot easily be made to respond differently depending on how far it trusts the user, so choose the model deliberately.

The research behind it

The demos build on a set of findings about how language models work inside:

A full paper on the architecture is in preparation.

Related: Behaviour design: find the field that blocks · Which prompt trick helps your AI · Using AI: you are the pilot
The demos were built by Tomas Lund. If your organisation has a similar task, you are welcome to write to tomas.lund@frictiontheory.org.