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.
#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.
#The stack: Mistral Magistral + AnythingLLM
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.
#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.
#1. Install Mistral Magistral + AnythingLLM
- 01Retrieve Magistral via OllamaA 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.
- 02Test the model in the CLIBefore 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.
- 03Install AnythingLLM DesktopDownload the official installer from useanythingllm.com. Standard installation, automatic launch, setup in 3 screens.
- 04Connect AnythingLLM to OllamaIn 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.
#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.
- 01Create a "Contract Law — Business" workspaceIn 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.
- 02Import the contracts to analyzeDrag 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).
- 03Paste the legal system promptWorkspace Settings → Chat Settings → Prompt. This is where you constrain the model's behavior for professional use.
#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.
#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.
- 01Load both versions into the workspaceImport 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.
- 02Force pinning of both documentsIn 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.
- 03Check the context windowMagistral supports 32k tokens by default. Two versions of a 25-page contract generally fit without issue. Beyond that, switch to section-by-section splitting.
#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.
#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.
#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.
Feedback, an error, or a clarification? Let us know—it improves the guide for everyone.