Short answer
Do not ask a model to recall references. Retrieve the source text first, require every claim to point at a retrieved passage, verify the identifier exists before display, and build a path for the system to say it does not know.
Why models invent references
A language model predicts plausible text. A reference like Article 324 bis 1 has a strong statistical shape. A plausible-looking article number is easy to produce, and nothing in the generation process distinguishes one that exists from one that does not.
This is not a flaw to be prompted away. Asking a model to "only cite real sources" reduces the rate and does not change the mechanism. The fix has to be architectural.
Four layers that work
1. Retrieve first
Keep the source texts in a corpus you control. Retrieve the relevant passages, put them in context, and instruct the model to answer only from what it was given. The model's job becomes summarising supplied text rather than recalling facts.
2. Make every claim point at a passage
Require structured output where each statement carries the identifier of the passage supporting it. A claim with no source attached is a bug you can detect automatically, rather than an error a reader has to catch.
3. Verify the identifier before it is displayed
This step is cheap and frequently skipped. Before rendering a citation, check the identifier against the corpus index. If it does not resolve, do not display it. This catches the exact failure that matters most: a reference formatted perfectly and pointing nowhere.
4. Let the system refuse
If retrieval returns nothing relevant, the correct output is "I could not find a basis for this", not a fluent paragraph. Refusal has to be an explicit, designed path. Systems that cannot refuse will always guess.
What this costs
More engineering, more latency, and a maintained corpus. It also produces a tool that answers fewer questions. That is the intended trade: for a professional whose work must be exact, a narrower tool that is reliable beats a broad one that occasionally invents.
The measure of a professional AI tool is not how often it answers. It is whether you can trust the answers it gives.
How to test it
Ask questions you know have no answer in the corpus. A well-built system says so. A poorly built one produces something fluent and plausible, and that is the single most useful test you can run before buying any AI tool for professional work.
Frequently asked questions
How do you stop AI from making up sources?
Retrieve the source text before generating, require each claim to reference a retrieved passage, verify the identifier against your index before displaying it, and design an explicit path for the system to refuse when retrieval finds nothing.
Is prompt engineering enough to prevent hallucinated citations?
No. Instructions reduce the rate but do not change the mechanism, because the model is predicting plausible text rather than looking anything up. Reliability comes from retrieval and verification outside the model.
How can I test whether an AI tool invents references?
Ask it questions that have no answer in its source material. A well-built system will say it cannot find a basis. A poorly built one will produce a fluent, plausible, unfounded answer.