Intermediate 18 minLegal

Contract analysis for law firms: local LLM FR

Analyzing lawyers’ contracts with a local LLM is not a convenience; it is an ethical obligation. Sending a draft shareholders’ agreement, settlement agreement, or client amendment to ChatGPT could violate Article 226-13 of the French Penal Code and the lawyer’s oath. This guide builds a 100% local pipeline around Mistral Magistral (a French reasoning model) and AnythingLLM, capable of extracting clauses, comparing two versions, and mapping contract risks—without a single token leaving the firm.

By Clara M.·Update 2026-06-15·Tested on Windows, macOS, and Linux

#Professional secrecy = local required

Attorney-client privilege (Article 66-5 of the 1971 law, Article 226-13 of the Criminal Code, RIN Article 2) is general, absolute, and a matter of public policy. It covers every document provided by the client or prepared for the client, including during contract review. The Conseil national des barreaux has repeatedly reminded lawyers that using cloud AI on data covered by privilege constitutes an ethical violation.

The terms of use for consumer LLMs (ChatGPT, Claude, Gemini) provide, unless a specific Enterprise offering applies, for using prompts to improve the service, storing them in datacenters outside the EU, and possible requests from the authorities of the hosting country. For a transactional protocol or a criminal case file, that's enough to turn a good idea into a professional liability risk.

!
“No-training” doesn't cover everything
Even an OpenAI Enterprise contract with a training opt-out leaves your prompts passing through third-party servers and subject to the CLOUD Act. For a lawyer, the only acceptable level of assurance is local inference on the firm's machine, with no outbound connection during analysis.

#The stack: Mistral Magistral + AnythingLLM

The AI at Work Kit

Deploy local AI at work: privacy, compliance, multi-user architecture, costs, the one-page memo for leadership.

  • Lifetime online access
  • PDF + files
  • Lifetime updates

Three building blocks. Ollama as the inference engine, listening on http://localhost:11434. Mistral Magistral as the model: it is a French reasoning model trained by Mistral AI that produces an explicit chain of thought before the answer—exactly what you want to explain why a clause is risky. AnythingLLM as the interface: multiple workspaces, built-in RAG, document management, and conversation traceability.

Mistral Magistral Small (24B)
The right compromise. Q4_K_M fits in 19 GB of VRAM, with French legal quality on par with GPT-4o for standard contract review.
Mistral Magistral 7B
A lighter variant if you have 12 GB of VRAM. Less precise on subtleties, but gets the job done for extracting standard clauses.
AnythingLLM Desktop or Docker
Desktop for a single lawyer's workstation, Docker behind Traefik to share it among several firm colleagues on the intranet.
nomic-embed-text embeddings
Multilingual, free, and sufficient for RAG over 50–500 contracts. There is no need to start with a specialized legal embedding model.
i
Why Magistral instead of a general-purpose model
For legal analysis, the chain of thought is valuable: Magistral writes out its reasoning before reaching a conclusion, making the output auditable. A senior lawyer can review the reasoning and identify within 10 seconds whether the model misunderstood a clause—something impossible with a single-block response.

#Hardware and software requirements

GPU NVIDIA RTX 4080 16 GB or better
Minimum for Magistral Small in Q4_K_M. RTX 4090 24 GB or RTX 5090 32 GB for comfort and extended context.
Mac alternative
Mac Studio M4 Max 48 GB or M2 Ultra 64 GB: Magistral Small runs very well in MLX, at 15–25 tokens/sec on French legal contracts.
32 GB of system RAM
PDF parsing, AnythingLLM, and the browser consume memory. 32 GB avoids swapping.
500 GB minimum SSD
Models (~15 GB), vector database, archive of indexed contracts. BitLocker / LUKS / FileVault encryption required.
Operating system
Windows 11 Pro, macOS 14+ or Ubuntu 22.04/24.04 LTS. No Home version for full-disk encryption.
Ollama installed
Daemon listening by default on http://localhost:11434. systemd service on Linux, native app on Windows / macOS.
→
Air gap during analysis
Once Ollama and the models are installed, you can disconnect the inference machine from the Internet while analyzing a sensitive folder. Nothing phones home: the guarantee is physical, not contractual.

#1. Install Mistral Magistral + AnythingLLM

  1. 01
    Retrieve Magistral via Ollama
    A single command downloads the model (about 14 GB in Q4_K_M for the Small variant) and saves it to the local Ollama registry. Allow 5 to 15 minutes depending on your connection.
  2. 02
    Test the model in the CLI
    Before setting up any interface, verify that inference is running and that the GPU is being used properly. ollama ps should show 100% GPU in the PROCESSOR column.
  3. 03
    Install AnythingLLM Desktop
    Download the official installer from useanythingllm.com. Standard installation, automatic launch, setup in 3 screens.
  4. 04
    Connect AnythingLLM to Ollama
    In Settings → LLM Preference, choose Ollama, enter URL http://localhost:11434, and select magistral from the list of detected models. Embeddings: nomic-embed-text via Ollama as well.
Model pull
# Variante Small (24B) — recommandée
ollama pull magistral

# Test rapide en CLI
ollama run magistral "Analyse cette clause : 'Le présent contrat est résilié de plein droit en cas de retard de paiement.' Donne ton raisonnement avant ta conclusion."

# Vérifier que c'est sur GPU
ollama ps
Embeddings for RAG
ollama pull nomic-embed-text

#2. Workspace cabinet and system prompt

AnythingLLM works through workspaces. The right practice for a law firm is one workspace per major practice area (business law, employment law, criminal law), not one per case. RAG remains relevant at this granularity, and separating by practice area prevents semantic contamination between legal domains.

  1. 01
    Create a "Contract Law — Business" workspace
    In AnythingLLM: New Workspace. Choose a business name, not a client name. Set the chat model to magistral and the temperature to around 0.2 to limit creativity.
  2. 02
    Import the contracts to analyze
    Drag and drop PDFs into the workspace's Documents tab. AnythingLLM extracts, chunks, embeds, and stores the text in the local vector database (LanceDB by default).
  3. 03
    Paste the legal system prompt
    Workspace Settings → Chat Settings → Prompt. This is where you constrain the model's behavior for professional use.
System prompt — Law firm workspace
Tu es un assistant d'analyse contractuelle utilisé par un avocat
inscrit au barreau français. Tu n'es PAS l'avocat. Tu prépares son
travail de relecture.

RÈGLES IMPOSÉES
1. Tu cites TOUJOURS textuellement les passages que tu analyses,
   entre guillemets, en indiquant l'article ou la section.
2. Tu n'inventes JAMAIS une clause. Si une clause demandée n'est
   pas dans le contrat, tu dis : "Absent du contrat fourni."
3. Tu n'émets aucun avis juridique définitif. Tu signales des
   points d'attention, jamais des certitudes.
4. Tu raisonnes EXPLICITEMENT avant de conclure (chaîne de pensée).
5. Tu utilises la terminologie juridique française correcte
   (Code civil, Code de commerce, jurisprudence Cass. com., etc.).
6. Tu refuses toute tâche hors champ contractuel.

FORMAT DE SORTIE PAR DÉFAUT
- Section RAISONNEMENT : ta réflexion étape par étape.
- Section CONSTATS : liste à puces, chaque puce = clause + citation
  + point d'attention en une phrase.
- Section À VÉRIFIER PAR L'AVOCAT : 1 à 5 points qui demandent
  l'expertise humaine.
→
Keep the chain of thought visible
Unlike consumer chatbot use, where the chain of thought gets in the way, here it has real value: it is the material that lets the lawyer verify that the model understood correctly. Don’t hide it.

#3. Extract standard clauses

First real use case: map the standard clauses present in a contract without an exhaustive manual review. Send the model a checklist of standard clauses and ask it to identify each one in the document loaded in the workspace.

Prompt — Clause extraction
Analyse le contrat chargé dans ce workspace. Pour chacune des
clauses ci-dessous, indique si elle est présente, cite textuellement
le passage correspondant (ou "Absent du contrat fourni"), et signale
en une phrase tout point qui mérite l'attention de l'avocat.

GRILLE DE CLAUSES À RECHERCHER :
1. Objet du contrat et périmètre des prestations
2. Durée et conditions de renouvellement (tacite reconduction ?)
3. Prix, modalités de révision, indexation
4. Modalités de paiement et pénalités de retard (taux légal ?)
5. Clause de propriété intellectuelle (cession ou licence ?)
6. Clause de confidentialité (durée post-contractuelle ?)
7. Clause de non-concurrence (durée, périmètre, contrepartie)
8. Clause de limitation / exclusion de responsabilité (réciproque ?)
9. Clause de force majeure (définition propre ou renvoi article 1218 ?)
10. Clause résolutoire (mise en demeure préalable ?)
11. Cession du contrat (autorisation préalable ?)
12. Données personnelles et conformité RGPD
13. Loi applicable et juridiction compétente
14. Clause compromissoire ou attributive de juridiction

Respecte strictement le format de sortie défini dans tes instructions.
i
Adapt the table to your workflow
This grid is a general-purpose starting point. A labor law firm will need a very different grid (mobility clause, probationary period, training repayment clause, mutual termination agreement). Maintain one grid for each major subject area and version it in an internal folder.

#4. Compare v1 / v2 of a contract

A very high-value use case: the opposing party returns an annotated version of the document. What are the actual changes? Which are cosmetic, and which change the economics of the contract? Manual comparison takes an hour per ten pages. Magistral does it in two minutes, leaving the lawyer to validate the result.

  1. 01
    Load both versions into the workspace
    Import v1 (original) and v2 (opposing party's response) into the workspace. Rename them explicitly: "protocole_v1_ndp.pdf" and "protocole_v2_retour_adverse.pdf" so the model can distinguish them.
  2. 02
    Force pinning of both documents
    In AnythingLLM, pinning both documents to the workspace forces their full inclusion in the context (up to the model's context window size), without going through retrieval. Essential for comparison.
  3. 03
    Check the context window
    Magistral supports 32k tokens by default. Two versions of a 25-page contract generally fit without issue. Beyond that, switch to section-by-section splitting.
Prompt — v1 / v2 comparison
Compare la version 1 (document "protocole_v1_ndp.pdf") et la
version 2 (document "protocole_v2_retour_adverse.pdf") du même
protocole transactionnel.

Ne relève QUE les modifications de fond. Ignore les corrections
purement orthographiques, typographiques ou de mise en forme.

Classe les modifications en quatre catégories :

A. FAVORABLES à notre client (le bénéficiaire de l'indemnité)
B. DÉFAVORABLES à notre client
C. NEUTRES sur l'économie du contrat
D. AJOUTS ou SUPPRESSIONS d'articles entiers

Pour chaque modification :
- Cite l'article ou la section concernée.
- Donne la formulation v1 entre guillemets.
- Donne la formulation v2 entre guillemets.
- Explique en une phrase l'impact juridique réel.

À la fin, propose une liste de 3 à 5 points à NÉGOCIER avec la
partie adverse, classés par priorité.
!
The output is not track changes
The model may miss a subtle change (an “and” becoming “or,” a deadline changing from 30 to 15 days in a long paragraph). For high-stakes contracts, keep a character-by-character diff (for example, using pandoc or Word) as a supplement. The LLM helps prioritize; it does not replace the diff.

#5. Map the risks

Third use: produce a structured risk memo as output, ready to be added to the client file. This is where Magistral's chain of thought becomes an asset: it provides the rationale for the memo.

Prompt — Risk note
Établis une NOTE DE RISQUES sur le contrat chargé, destinée à
être versée au dossier interne du cabinet (pas remise au client
en l'état).

Structure attendue :

1. SYNTHÈSE EXÉCUTIVE (5 lignes max)
   - Nature du contrat
   - Parties
   - Enjeu principal en une phrase
   - Niveau de risque global (faible / modéré / élevé) + justification

2. RISQUES JURIDIQUES IDENTIFIÉS
   Pour chaque risque :
   - Intitulé du risque
   - Clause(s) concernée(s), citées textuellement
   - Probabilité de survenance (faible / modérée / élevée)
   - Impact (faible / modéré / élevé)
   - Disposition de droit applicable ou jurisprudence à vérifier

3. RECOMMANDATIONS DE RÉDACTION
   - 3 à 7 propositions de modification, formulées comme des
     suggestions de rédaction concrètes.

4. POINTS À ÉCLAIRCIR AVEC LE CLIENT avant signature.

Respecte strictement le format. Cite TOUJOURS les passages.
i
Systematic human validation
Every memo produced by this pipeline must be reviewed and signed by the attorney who is responsible for it. The LLM is a background-work assistant, not a signatory. This discipline is what makes the tool compatible with your professional civil liability.

#Quality control and guardrails

Legal hallucination
An LLM can cite a nonexistent article from the French Civil Code or invent case law. Golden rule: verify every article cited by the model on Légifrance before incorporating it into a deliverable.
Text citations
Always systematically verify that passages the model “quotes verbatim” are actually in the contract. It's rare, but it happens—the system prompt instruction greatly reduces the risk but does not eliminate it.
Temperature
For this type of use, stay between 0.1 and 0.3. A higher temperature produces more fluid writing but increases the risk of fabrication.
Privacy on the firm side
Full-disk encryption (BitLocker / FileVault / LUKS), strong authentication for the AnythingLLM session, encrypted backups, and document purging when the case is closed.
Traceability
AnythingLLM keeps conversation history by workspace. Export and archive these logs in the client folder: they provide useful audit evidence if your actions are ever challenged.
Model updates
Follow the Mistral Magistral releases. At least one release per year ensures a model trained on recent legislative changes.
!
Do not substitute for an attorney’s reasoning
This tool speeds up initial triage and mechanical proofreading. It replaces neither legal qualification, litigation strategy, nor the final drafting of a legal document. Its use must be documented in the case file (mention that AI-assisted proofreading was used, along with the model version).

#Go further

This pipeline covers day-to-day contract review. Three natural next steps: build an RAG database from the Légifrance case law relevant to your practice area, strengthen the firm's GDPR and AI Act compliance, and install Mistral Magistral on a second machine for resilience.

Did this guide help you?

Feedback, an error, or a clarification? Let us know—it improves the guide for everyone.