How we build Bayan

How using Bayan differs from generative AI models

General models put fluency ahead of accuracy; Bayan answers from Egyptian law itself, linked and cited.

[date] · [author] · 15 min read

It is late, the memo is due in the morning, and you ask a general AI chatbot a question about Egyptian law. The answer arrives in seconds: fluent, organised, confident. It names an article of the Civil Code and a ruling of the Court of Cassation. It reads like the work of a capable associate.

Some of it is right. The trouble is that nothing in the answer tells you which part. To find out, you have to do the research the answer was meant to save you.

This is not because general models are poor. They are among the most capable tools ever built, and we use them inside Bayan every day. It is because of what they read, how they read it and what they are built to do. A general model is built to give a plausible answer to any question. A lawyer needs a correct answer to one question, and needs to show where it comes from.

This article explains why. First, how these models actually work and why they put fluency ahead of accuracy; then what that means for Egyptian law, with real examples.

1. How a language model works, and why it puts fluency first

To see why a fluent answer can be wrong, it helps to know what a language model actually does. The science is simpler than it sounds.

Every stage rewards a likely, confident answer. None checks it against the law.
1Pretraining

Reads a vast amount of text and learns to predict the next word

Built for: likely wording
2Tuning

People compare answers and pick the one they prefer; the model moves toward it

Built for: pleasing answers
3Scoring

Tested on accuracy alone, so a guess scores better than saying I don't know

Built for: never a blank
The result: fluent and confident on every topic, accurate where facts are common, weakest where they are rare.

It learns by predicting the next word. A language model is trained on an enormous amount of text with one task, repeated billions of times: hide the next word in a sentence, guess it, compare the guess with the real word, and adjust slightly. (Strictly, it works with tokens, which are pieces of words.) Over time it becomes remarkably good at continuing any text in a way that resembles the text it has read. Your phone's keyboard suggesting the next word does the same thing on a tiny scale.

It keeps patterns, not pages. What training leaves behind is not a library of documents but billions of numbers, the model's weights, that encode patterns: which words tend to follow which, what a court citation looks like, how an article of a civil code is usually phrased. When a model “remembers” Article 223, it is not looking it up. It is rebuilding the most likely wording from those patterns. Often it gets it right. Sometimes it produces a blend of several texts that look alike.

What is common, it learns well. What is rare, it does not. A pattern seen thousands of times comes back accurately. A fact seen once or twice, such as a single ruling of the Court of Cassation or a decree issued last year, is learned weakly or not at all. Researchers from the University of North Carolina, Google and Berkeley measured this in 2023: one large model's accuracy on general knowledge questions rose from about 25% to above 55% as the number of documents about the question in its training text rose from ten to ten thousand. Egyptian legal text is a small share of what models read, and Arabic legal text as a whole a smaller one. Where the model's knowledge runs thin, it does not stop. It fills the gap with the most likely pattern from what it knows better: another Arab code, a common law idea, an older version of the law.

Then it is tuned to please. After this first stage, models are tuned with feedback: people compare two answers and pick the one they prefer, and the model is adjusted toward their choices. People tend to prefer answers that are complete, confident and well written. Researchers at Anthropic found in 2023 that people, and the models trained on their preferences, sometimes prefer a convincingly written answer that agrees with the user over a correct one that does not. Researchers at OpenAI found in 2025 that the usual way models are tested rewards guessing: a model that answers every question scores higher than one that says “I don't know” when it doesn't, just as a student who guesses on a multiple choice exam outscores one who leaves blanks.

It writes one word at a time, and does not go back. When it answers, the model picks each word from a list of candidates ranked by likelihood, then the next word, and so on. Nothing in that step looks anything up or checks it. Once it has written “Article 224”, the most likely continuation is a sentence explaining Article 224, whether or not it is the right article. Ask the same question twice and the wording, and sometimes the answer, can change.

The model picks a likely next word. It does not look the article up.

Agreed compensation is set out in Article

Candidates for the next word, ranked by likelihood (illustration)
  1. 223· Egyptian Civil Code
  2. 224· Syrian Civil Code, same wording

Two codes put the same words under each number, so both look likely. The model picks one; nothing in this step checks which country you asked about. Illustration, not measured values.

Its knowledge stops on a date. Training ends at a cutoff. Anything published afterwards is unknown to the model unless it is given the text, and the law keeps changing after every cutoff.

Put together. A general model is built to write the answer that reads as most likely, and rewarded for sounding sure. It puts fluency ahead of accuracy. Fluency is learned well because the patterns of language are regular and repeated; accuracy on a rare fact cannot come from patterns alone. On a narrow, local, fast changing subject like Egyptian law, accuracy is the first thing to go. The model does not know when it is wrong, and its confident tone is the same either way.

What changes the picture. The problem is not the model's writing; it is its memory. When the right text is placed in front of the model at the moment it answers, and the model is told to answer only from that text, it stops rebuilding from memory and starts reading. The same 2023 study found that giving the model the relevant document reduces its dependence on what it memorised. It is the difference between a closed book exam and an open book exam. Bayan is built on that idea, with one more step: every citation in the answer points to a page you can open beside it and check for yourself.

2. What a general model has read about Egyptian law

A general model reads what is easy to find. Bayan reads where the law is.
What a general model reads most
  • The open web, as it happens to be
  • Forum answers and news reports
  • Firm blog posts and summaries
  • Copies of laws, some out of date
  • Other Arab codes, numbered differently
  • Search results: news about a law
Result: a partial, undated sample
What Bayan reads
  • Egyptian law, as published
  • Legislation, with every amendment
  • Regulations and ministerial decrees
  • Cassation rulings, printed volumes too
  • Supreme Constitutional Court rulings
  • Official Gazette issues kept as scans
  • Each text with its number, year, dates
Result: the sources, linked and cited

A general model learns from a vast body of text, most of it from the open web. For Egyptian law, the open web is a thin and uneven slice of the real thing.

Much of Egyptian law lives where a general model reads poorly or not at all: the printed collections in which the Technical Office of the Court of Cassation publishes its rulings; issues of the Official Gazette and of Al Waqa'i' al Misriyya, where laws, regulations and decrees are published, many of them kept as scanned pages; court archives; and paid databases that open only with a password.

What is easy to find online is a different mix: forum answers, news reports, firm blog posts, unofficial copies of laws that may predate their latest amendment, and the civil codes of other Arab countries. Several of those codes come from the same drafting school as Egypt's, so their articles say almost the same thing under different numbers.

So a general model's picture of Egyptian law is a sample: partial, undated and mixed with other countries' law. It writes well from that sample. It cannot tell you what the sample is missing.

Web search closes only part of the gap. A model that searches may find a news story about a new law. It still does not have the law as published, the date each article took effect, or the rulings that have read it since.

3. Five ways a fluent answer goes wrong

These are the patterns we see most often when general models answer questions on Egyptian law. Each one reads well. Each one can cost a client.

The right rule under another country's number. Agreed compensation, the penalty clause, is Article 223 of the Egyptian Civil Code. In the Syrian Civil Code the same text sits at Article 224, and the rule that agreed compensation is not due when the creditor suffered no harm, Article 224(1) in Egypt, sits at Article 225. In Egypt, Article 225 sets a different rule: when the harm exceeds the agreed amount, the creditor cannot claim more unless the debtor committed fraud or gross fault. A model that has blended the codes can give you the right rule under the wrong number, or a number that, in Egypt, sets a different rule altogether.

Why the model does this. Arab civil codes share wording, so in the model's patterns the same sentence is tied to several numbers. Asked for the article, it writes the number most strongly tied to that wording across everything it read, and Egypt is only one of the countries in that mix.

Bayan's library is Egyptian law. Every article it cites is the Egyptian article, and it opens beside the answer.

Half an article. Article 374 of the Civil Code begins «يتقادم الالتزام بانقضاء خمس عشرة سنة»: an obligation lapses after fifteen years. Many answers stop there. The article goes on: «فيما عدا الحالات التي ورد عنها نص خاص في القانون وفيما عدا الاستثناءات التالية», except where the law provides otherwise and except for the exceptions that follow. The exceptions are the point. Articles 375 to 378 set five years for periodic rights such as rent, wages and pensions; five years for the fees of doctors, lawyers and engineers for their professional work; three years for taxes and fees owed to the state; and one year for a group of claims by merchants and workers. A client told “fifteen years” may already be out of time.

Why the model does this. Short quotations of a rule tend to travel without their exceptions, in summaries, forum answers and lecture notes. The model reproduces the form it has seen most often, and the most common form stops at “fifteen years”.

Bayan quotes the article whole and follows it to the articles it points to.

A ruling that does not exist. A Court of Cassation citation has a familiar shape: «الطعن 1477 لسنة 51 ق جلسة 30/12/1984 مكتب فني 35 ج 2 ق 437 ص 2315». That is the appeal number, the judicial year and the session date, then the Technical Office year, part, rule and page. A general model learns the shape well enough to produce it for a ruling that was never issued. In 2023 a federal court in New York fined two lawyers who had filed a brief citing cases that ChatGPT invented, in Mata v. Avianca. The citations looked real. No one could find them, because they never existed.

Why the model does this. The model has learned what a citation looks like far better than any particular citation: the shape is common, the number is rare. It writes the number one digit at a time, each digit plausible, and the whole is never checked against a court record, because the model has none.

Bayan cites only rulings in its library, and every citation opens to the ruling.

A law that has changed. Labour Law No. 12 of 2003 governed employment in Egypt for more than twenty years. Labour Law No. 14 of 2025, published on 3 May 2025, replaced it from 1 September 2025. The Personal Data Protection Law No. 151 of 2020 had no executive regulations until Ministerial Decree No. 816 of 2025 was issued on 1 November 2025. A model trained on years of commentary on the old law and a few months of the new one will reach for the old law first, and it will not tell you so.

Why the model does this. Its knowledge stops at the training cutoff, and even before it, years of text about the old law outweigh a few months of text about the new one. The model reaches for the pattern it has seen most.

Bayan keeps every text with its dates, answers from the text in force on the date that matters to you, and tells you when it changed.

A text without its relations. In Egyptian law the answer is rarely one text. It is the statute, the laws that amended it, the regulations and decisions that carry it out, the Court of Cassation rulings that read it, and the Supreme Constitutional Court rulings that struck parts of it down, each with its own date. A general model may know one or two of these. It has no way to know how they connect, or which came last.

Why the model does this. A model stores associations between words, not a record of which text amended, carried out or struck down which, or when. Texts that are often mentioned together become linked in its patterns; texts that rarely are do not, however closely the law ties them. The next section shows what that looks like in practice.

4. One question, five texts: old rent

The answer on old rent rests on five linked texts
  1. 1981
    Law No. 136 of 1981
    Fixed the annual rent of residential units let under it
    struck down in part by
  2. 9 Nov 2024
    Supreme Constitutional Court, Case No. 24 of judicial year 20
    Fixed annual rent held unconstitutional; effect deferred to the end of the session
    followed by
  3. 4 Aug 2025
    Law No. 164 of 2025
    New rents, periodic increases, and an end date after a transitional period
    carried out by
  4. 2025 to 2026
    Governorate committees and a Prime Minister's decree
    Areas classed as distinguished, middle or economic, which sets each rent
    now challenged in
  5. Pending
    A challenge to Law No. 164 of 2025
    Before the Supreme Constitutional Court: the ground may move again
A general model · Usually one or two of these, with no dates
Bayan · All five, linked in order, each one cited

Each link changes the answer, and each has its own date

Ask a general model whether a landlord can raise the rent on an apartment let under the old rent laws, and you will likely get an answer built on one text. The answer today is built on at least five, in this order:

Law No. 136 of 1981 fixed the annual rent of the residential units it covers.

On 9 November 2024 the Supreme Constitutional Court, in Case No. 24 of judicial year 20, held the first paragraph of Articles 1 and 2 of that law unconstitutional insofar as it fixed the annual rent, and set the day after the end of the House of Representatives' current regular session as the date its ruling took effect.

Law No. 164 of 2025, published on 4 August 2025, reorganised the relationship between landlords and tenants under the old rent laws: new rents, periodic increases, and an end date for these tenancies after a transitional period.

Decisions issued under it carried it out: committees in each governorate classified areas as distinguished, middle or economic, which sets the rent each unit owes, and Prime Minister's Decree No. 3977 of 2025 extended the committees' work.

A challenge to Law No. 164 of 2025 is now before the Supreme Constitutional Court.

Every one of these changes the answer. A lawyer who sees only the first gives advice that was right in 2023. One who sees the first three but not the fourth cannot tell a client what the rent now is. One who misses the fifth does not warn the client that the ground may move again.

This is the work Bayan was built for. Its library does not keep texts as separate documents; it keeps them linked: this article was amended by that law, carried out by that decision, read by these rulings and struck down in part by that one, on these dates. When you ask about an old rent contract, Bayan follows those links and answers from the whole chain, citing each text so you can open it yourself.

5. The same question, answered two ways

Same question. One answer sounds right; the other is right and shows why.
Question

The electricity company is claiming bills from three years ago. Has its claim lapsed?

A general model
Illustration of common patterns, not a transcript

No. Obligations lapse in fifteen years under Article 374 of the Civil Code.

Bills recur, so five years may apply under Article 375.

See Cassation, Appeal No. ●●●● of judicial year ●●.

  1. 1Only half of Article 374
  2. 2Cassation rejected five years here
  3. 3Right format, leads nowhere
Sources that open:none
Bayan
The answer with its sources

Possibly, but only on oath.

Article 378(1)(a): one year for the claims of merchants for goods supplied to people who do not trade in them.

Cassation treats the electricity company as a merchant: Appeal 3316 of year 78, session of 1 December 2015.

Article 378(2): you must swear you paid; the judge directs the oath himself.

Sources that open:Article 374Article 378Appeal 3316/78

Graphic 3 puts the difference side by side. The question is one lawyers hear every week: the electricity company is claiming bills that went unpaid three years ago; has its claim lapsed?

The general model's answer here illustrates the patterns above; it is not a transcript of any one product. It says no: the general limitation period is fifteen years under Article 374, or perhaps five years under Article 375, since bills recur. Each sentence is plausible. The answer is wrong on the point that decides the case.

Bayan's answer starts from the text the courts apply. Article 378(1)(a) sets one year for the claims of merchants and manufacturers for things they supplied to people who do not trade in them. The Court of Cassation has treated the electricity company as a merchant for this purpose, applied the one year to its claims and rejected the argument for five years under Article 375 (Appeal No. 3316 of judicial year 78, session of 1 December 2015) [Sherif checks that this ruling opens in Bayan]. Article 378(2) then adds the condition the general answer misses: whoever relies on the one year must swear that he actually paid, and the judge puts that oath on his own motion. And under Article 379(2), if the debt was put in a written instrument, it lapses only after fifteen years.

One question. One answer sounds right. The other is right, and shows you why.

6. What happens when you ask Bayan

Models change. The library, the links and the checks stay.
Your answer
with every source open beside it
stays
The checks
every claim points to a source that opens; quotes as published
The model
writes only from what was found; the best model for each task
changes
The search
Arabic as it is written: spelling variants, meaning and exact words
The links
each article tied to its amendments, decisions and rulings
stays
The library
Egyptian legislation and rulings, gathered and organised by our team

How a Bayan answer is built, from the sources up

Bayan is built in layers, and the AI model is only one of them.

The library. Egyptian legislation and court rulings, gathered and organised by our team, including texts that are hard or impossible to find online. Every text carries its number, its year and its dates.

The links. Every article is connected to what amended it, what carries it out, the rulings that read it and the rulings that struck it down, each link with its date.

The search. Bayan reads Arabic legal text as it is actually written. Official texts spell the same word more than one way, such as «التعويض الاتفاقى» and «التعويض الاتفاقي», or «القاضى» and «القاضي». Bayan treats them as one word, searches by meaning and by exact wording together, and finds the article whether you ask in formal Arabic, in Egyptian Arabic or in English.

The model. An AI model reads what the search found and writes the answer from it, and only from it. When the library does not answer the question, Bayan says so instead of filling the gap.

The checks. Every statement in the answer points to its source, every source opens beside it, and a quote is the text as published. [Before an answer reaches you, Bayan checks each citation against the text it points to: Sherif confirms.]

7. Why we treat the model as a commodity

Better AI models now arrive every few months, from several labs, and each is stronger at some tasks than at others. The leading legal AI companies abroad have reached the same conclusion: there is no single best model, so they test models task by task and use the one that does each job best.

We agree, and for Egyptian law we go a step further. The model is the part of the system most likely to change and least likely to be the reason an answer is right. A brilliant reader cannot cite a ruling it was never given, or know that an article was struck down if no one linked the ruling to the article. What makes an answer on Egyptian law reliable is everything around the model: the library, the links, the Arabic search and the checks.

So Bayan is built for the model to be replaceable. We test models on real Egyptian legal questions graded by Egyptian lawyers [Sherif confirms], use the best one for each task, and change it when a better one arrives. Your sources, your citations and the way you check them stay the same. When models improve, Bayan improves with them. When a model gets something wrong, the open sources and the checks are there to catch it.

That is also why we are bringing Bayan into Claude. Through Bayan for Claude, coming soon, a general model will answer from Bayan's library instead of from memory, and its answers will carry Bayan's citations. The model is the same. What it reads is not.

8. What this means for your practice

General models are excellent at much of what a lawyer does: drafting in a clear style, summarising your own documents, turning notes into a first outline, translating a letter. Use them for that.

For what the law says today, treat any answer from any tool as a lead until you have checked it:

  • Open the text. A citation you cannot open is a claim, not a source.
  • Check the country and the code. The right words under the wrong number are still the wrong article.
  • Read the whole article, and the articles it points to.
  • Check the date: the text in force when the facts happened, and every amendment since.
  • Follow the relations: the regulations and decisions that carry the text out, and the rulings that read it or struck it down.

Bayan was built so these checks take seconds, not hours. The legal judgement stays yours.

The question to ask any legal AI is not how well it writes. It is: where does this come from, and can I open it?

Book a team demo

Sources. Kalai, Nachum, Vempala and Zhang, “Why Language Models Hallucinate”, OpenAI, September 2025 · Sharma et al., “Towards Understanding Sycophancy in Language Models”, Anthropic, ICLR 2024 · Kandpal et al., “Large Language Models Struggle to Learn Long-Tail Knowledge”, ICML 2023 · Mata v. Avianca, Inc., 678 F. Supp. 3d 443 (S.D.N.Y. 2023).

Share

The month's key legal updates and what's new in Bayan, once a month.

Ask Bayan your first question.

Or book a team demo and bring a real contract: thirty minutes is enough to know whether Bayan fits your practice.

Book a team demo