Ask a general model about Algerian law and it may answer with another country's code, article numbers included. See why, and how to make it answer from the official text you give it.
Ask a general model how much notice ends a commercial lease under Algerian law. The answer is fluent, organised and sure of itself.
Then check the article it cites. Sometimes it describes another country's code, under an Algerian heading. This article shows why, and how to build answers you can verify.
A model learns from what is published online. Far more legal text from other countries is online than Algerian legal text.
A hallucination is an answer a model states with confidence and that is false, such as an article that does not exist. Its danger is that it reads exactly like a true answer.
Algerian civil law shares its vocabulary with other French-language and Arabic-language codes. When the model has little Algerian text to rely on, it fills the gap with the code it saw most.
If I ask in French, won't it simply answer with French law?
That is precisely the risk. The language of the question does not choose the jurisdiction. You have to give the model the Algerian text and tell it to answer from that text only.
The method has a name. Retrieval means finding the right passage in a trusted source and placing it in the prompt. Its role is to make the model read the law before it answers.
For Algerian law, the trusted source is the Journal officiel, published by the government's general secretariat at joradp.dz. You copy the article you need, then ask your question about it.
from openai import OpenAI
client = OpenAI(base_url="https://opendunes.com/v1", api_key="your-opendunes-key")
article = "…the article's text, copied from the Journal officiel…"
answer = client.chat.completions.create(
model="openai/gpt-6-luna",
messages=[
{"role": "system", "content": "Answer only from the text provided. Quote the sentence you rely on. If the text does not answer, say so."},
{"role": "user", "content": f"Text:\n{article}\n\nQuestion: what notice does this article require?"},
],
)
print(answer.choices[0].message.content)Let's see right away what one grounded question costs.
You send a 2,000-token article with your question and get a 500-token answer. On GPT-6 Luna, at 31.2 DA per million tokens sent and 156 DA per million returned, that costs about 0.14 DA. On Claude Sonnet 5, about 2.81 DA. Rates from the model pages, read on 5 October 2026.
Grounding lowers the risk without removing it. The last check is yours.
Ask the model to quote the sentence it relies on. If that sentence is not in the text you gave, reject the answer.
A quote is easy to check: you search for it in the text, and it is there or it is not.
Copy an article number from a model's answer into a contract or a submission without opening the text.
Open the article in the Journal officiel, read it, and keep the model's answer only if the quote matches.
Different models handle long texts and Arabic legal wording differently. With one key, you can send the same question to two models and compare their quotes.
Context: you have the chat open and the text of one Civil Code article, copied from the Journal officiel.
Task: write a message that makes the model answer only from that text and quote the sentence it uses.
Paste the article first, then write: "Answer only from the text above. Quote the exact sentence you rely on. If the text does not answer my question, say that it does not." Then ask your question.
Fine-tuning teaches a model a style more than exact facts. To answer from the law's own words, giving the text in the prompt is simpler and easier to check.
Each model page shows how much text the model accepts at once. Send the same article and question to two models, and keep the one whose quotes match the text.
The Journal officiel is published online at joradp.dz. Copy the article from there rather than from a secondary website.
You now have a method to keep a model honest about Algerian law. To see how this fits with data protection and professional secrecy, go back to the guide Law 18-07 and AI: What Algerian Businesses Actually Have to Do.