Legal AI Academy · Foundations
RAG, Prompts and Risk: Legal AI Foundations for Moroccan Teams
A practical introduction to the essential building blocks of reliable legal AI.
Legal AI does not begin with a model. It begins with the work.
The work of a Moroccan lawyer is rarely "answer this question." It is much closer to: read this contract, compare it to the last three we signed with this supplier, check whether the indemnity clause survived our standard markup, prepare a one-page note for the executive committee in French, and make sure nothing in it would be embarrassing if it ended up in front of a judge in Casablanca.
That is the real measuring stick. Any conversation about legal AI that does not pass through that filter is, at best, incomplete.
This first article in the Burhan Legal Academy walks through the four building blocks of legal AI (the model, the prompt, the context, and the guardrails) and explains why the risk it creates is not technical, but legal.
What legal AI is not
Before defining what legal AI is, it is useful to clear three misunderstandings that follow most introductions to the subject.
Legal AI is not a search engine. A search engine returns documents. Legal AI generates text. The difference is enormous. A search engine can be wrong about which document is relevant. Legal AI can be wrong about what the law says.
Legal AI is not a chatbot. A chatbot is a user interface. Legal AI is a system: model, retrieval layer, context, prompts, controls, audit. Reducing it to a chat window is like reducing a law firm to its reception desk.
Legal AI is not a replacement for legal judgment. A model can draft a memo. It cannot decide whether to send it, whether to soften a sentence before a regulator reads it, or whether the client is actually asking the right question. That remains the lawyer's job, and increasingly, the lawyer's most valuable contribution.
The four building blocks
Almost every legal AI product in the market today, from international platforms like Harvey or Legora to enterprise legal research environments such as LexisNexis, can be understood through the same four building blocks.
1. The model (the LLM). A large language model is a statistical engine trained on enormous amounts of text. It is fluent, fast, and confident, sometimes too confident. On its own, a general-purpose LLM knows a great deal about contracts in the abstract and almost nothing about your contracts, your client, or the procedural posture of your matter before the Tribunal de commerce.
2. The prompt. The prompt is the instruction you give the model. "Summarise this contract" is a prompt. "Identify every clause where the liability cap is below twelve months of fees, list them with article numbers, and flag deviations from our internal template" is a much better prompt. A prompt is a hypothesis about what you want. The quality of the answer is bounded by the quality of the instruction.
3. The context. The context is everything the model can actually see when it answers: the documents you have given it, the matter file, the parties, the prior versions, the applicable text of the law, the prior advice on the same client. We will return to this in much more detail in Article 4 (Context Engineering), because in legal work, context is not decoration. Context is the case.
4. The guardrails. Guardrails are what stop the system from being dangerous: source citations on every claim, retrieval that points to a real document, audit logs that record what was asked and what was produced, access controls, validation steps, and the human review at the end of the chain.
A serious legal AI product is the sum of all four. A weak one is just the first.
RAG, in plain language
The acronym you will hear most often is RAG, for Retrieval-Augmented Generation. The idea is straightforward. Instead of asking the model to answer from memory, you first retrieve the right documents (a contract, a clause library, a recent court decision, an internal policy), and you let the model answer based on those documents, with citations.
RAG is the difference between a confident generalist and a junior associate who actually opened the file before speaking.
For legal work, RAG matters for three reasons.
- Sourcing. Every claim can be traced back to a real document. The lawyer reviews the source, not just the answer.
- Currency. The model is no longer limited to its training cutoff. It can work from the contract you signed yesterday.
- Confidentiality. The retrieval can be limited to your documents, in your environment, under your access rules.
Anthropic's published work on legal skills, Legora's collaborative drafting environment, and Harvey's enterprise deployments all rely heavily on retrieval. The retrieval layer is not a feature. It is the spine.
Hallucinations and why they are a legal problem
When a language model produces a confident, fluent, well-structured statement that is simply not true, the technical term is hallucination. The legal term is harder to translate, but it is closer to risk.
In other professions, a fluent wrong answer is annoying. In law, a fluent wrong answer can be sent to a client, signed by a partner, attached to a board pack, or quoted in conclusions before a court. The cost of a single hallucinated article number, fake citation, or invented decision is not a refund. It is reputation, malpractice, and discipline.
The defenses are not mysterious. Anchor every claim in a retrieved source. Show the source to the human. Make the human review the output before it leaves the system. Log it.
This is the difference between using AI and practising law with AI.
Risk is asymmetric in law
There is a deeper point worth pausing on. In many industries, the upside of AI is large and the downside is small. A marketing email that misses the mark costs little. In law, the asymmetry runs the other way. A well-drafted clause saves hours. A poorly drafted clause that nobody reviewed can destroy a deal, a defence, or a career.
This is why a serious legal AI strategy does not start with productivity. It starts with control. Productivity follows, but it is the reward of a well-governed system, not the headline.
In Morocco and francophone practice
Three realities make these fundamentals especially relevant in Morocco.
Bilingualism. Moroccan business law is predominantly francophone, while many procedural acts, court filings, judgments, and administrative documents are in Arabic. A legal AI that handles French elegantly but stumbles on an Arabic procès-verbal is not a Moroccan legal AI. It is a French legal AI deployed in Morocco.
Source dispersion. There is no single, comprehensive, structured public database of Moroccan jurisprudence comparable to what large common-law jurisdictions enjoy. International references like LexisNexis Middle East are valuable, but much of a firm's most useful knowledge lives in its own past matters: prior conclusions, memos, advice notes, contract templates. RAG on the firm's own corpus is, for many Moroccan teams, the most realistic starting point.
Professional secrecy. The duty of confidentiality owed by Moroccan lawyers is not a preference. It is a structural rule of the profession. Any prompt sent to a public AI tool that includes client information is, at minimum, a question to be taken seriously. We will dedicate Article 2 to this.
Practical example
A junior associate in a Casablanca law firm is asked to prepare a first draft of conclusions in a commercial dispute. The matter file contains the original contract (bilingual, French body with Arabic annexes), six months of email exchange, two technical reports, a mise en demeure already sent, and the opposing party's prior pleadings.
Three scenarios.
- Without legal AI. The junior spends two days reading, summarising, and producing a first draft. The partner spends three hours rewriting it. The junior learned by doing, slowly.
- With a generic public AI tool. The junior pastes excerpts of the contract into a chatbot. The output reads well. It also references articles that do not exist in the contract, invents a procedural step, and (separately) every word pasted has just left the firm's confidentiality perimeter.
- With a properly deployed legal AI inside a Legal OS. The junior asks the system to produce a first structured draft based on the matter file. The system retrieves the relevant clauses, the prior mise en demeure, and the firm's own template for similar disputes. Every paragraph cites the source document. The partner reviews, corrects, and signs. The junior learns by reading the partner's edits, not by retyping.
The third scenario is not science fiction. It is the working assumption of every serious legal AI platform on the market today.
This example is illustrative. Any legal output must be reviewed by a qualified Moroccan legal professional before use.
What this changes for Burhan
Burhan is not built around a model. Burhan is built around the legal work itself: matters, documents, parties, tasks, hearings, approvals, and the trail of who did what and when.
The model is one component. The retrieval over your own documents is another. The bilingual handling of French and Arabic is another. The source citations, the audit logs, the access controls, the validation steps, those are not optional features. They are what makes a legal AI usable by a Moroccan lawyer in good conscience.
The rest of this Academy explains, article by article, why each of those layers matters, and how they fit together.
Key points
- Legal AI is a system, not a chatbot. Model, prompt, context, and guardrails work together.
- RAG (retrieval-augmented generation) is the spine of any serious legal AI deployment.
- Hallucinations are not a technical curiosity in law. They are a risk to be designed out.
- Risk in law is asymmetric. A wrong answer costs far more than a right one saves.
- For Moroccan legal teams, bilingualism, source dispersion, and professional secrecy reshape what "good legal AI" even means.