Skip to content
Ask for a Budget
TechnologyFebruary 23, 202615 min readUpdated on November 11, 2026

Local LLM for law: running models on a Mac with Apple Silicon

A practical guide to running LLMs locally on a Mac for legal work in Brazil: model choice, quantization, RAG with official sources, metrics and LGPD.

Local LLM for law: running models on a Mac with Apple Silicon
Índice do artigo
faltam 14 min de leitura

In legal work, "running AI locally" is not hype: it is a strategy for privacy, cost predictability and traceability, as long as you treat it as product and engineering, not as a prompt.

The idea of "sending case files to an LLM so it analyzes, validates and drafts defenses" is tempting. And, if well implemented, it can raise productivity safely.
But in the real world it only works when three things go together:

  1. The right model (not necessarily "the biggest").
  2. RAG + evidence (without it, hallucination risk becomes legal risk).
  3. Governance (LGPD, Brazil's data protection law, an audit trail, human review and clear rules).

This post consolidates the two investigations we did on this topic (local LLMs on a Mac + applying them to Brazilian law) into a reference guide, with technical and legal depth, updated for the current landscape of open-weight models and tools.

Important notice: this content is technical and informational. It does not constitute legal advice. For concrete matters, validate with the responsible attorney and with your organization's compliance team.

Article cover: local LLM for Brazilian law

What you will find here

  • How to think about "better than a GPT" in a measurable way (and when that is possible in specific legal tasks).
  • Why Apple Silicon became a strong platform for local inference (unified memory + bandwidth).
  • What really drives performance: weights, KV cache, context and quantization.
  • Local runtimes: MLX, llama.cpp, Ollama, MLC-LLM, LM Studio, and how to choose.
  • Recommended models (November 2026 review): Qwen3.6 and Qwen3.8, Gemma 4, Muse Glimmer, Llama 4 Scout, DeepSeek and Jurema (Brazilian legal).
  • A "real" architecture for legal work: RAG with official sources (LexML etc.), validation, logs and human review.
  • A checklist for LGPD + governance and how to align with the guidelines of the CNJ (Brazil's National Council of Justice).
  • An implementation playbook (from laptop to "almost production").

1) Before the model: what do you want to automate in legal work?

Most frustration with AI in legal work comes from a poorly answered question: "what exactly do I want the system to do?"

"Analyzing a case" can mean very different things. Examples of (good) tasks:

  • Triage: classify the type of action, procedure, procedural stage, amount in dispute, apparent risk.
  • Extraction: parties, claims, cited grounds, deadlines, documents mentioned.
  • Technical summary: case narrative + events + timeline.
  • Checks: inconsistencies, missing filings, mismatches between claims and documents.
  • Assisted drafting: drafts of answers, motions, notices, clauses and checklists.

And examples of (dangerous) "poorly defined" tasks:

  • "Generate the complete defense and file it" (no evidence, no review, no rules, no audit).

If you define "what goes in" and "what comes out" (including as JSON), you leave the world of the "magic prompt" and enter the world of robust systems.


2) Why a Mac (Apple Silicon) makes sense for local LLMs in 2026

The point is not "the Mac beats everything". The point is: Apple Silicon changed the economics of on-device AI because it combines:

  • Unified memory (CPU/GPU/Neural Engine sharing the same pool).
  • High memory bandwidth, which directly affects inference on large models.
  • A growing ecosystem of optimized runtimes (MLX, Metal, Core ML).

Example (for a sense of scale): the M3 Ultra chip, from 2025, was announced with more than 800 GB/s of bandwidth. On August 25, 2026, Apple announced the Mac Studio with M5 Ultra, with up to 512 GB of unified memory and 1.2 TB/s of bandwidth, and the M5 Max with up to 128 GB. Deliveries started on September 22. The 512 GB configuration was announced for late October and, in November 2026, already appears as a build-to-order option for the M5 Ultra on Apple's specifications page; check the delivery time in the store before planning the purchase. Apple itself markets the machine as able to load the largest open-weight models available; treat that as a manufacturer's promise and measure it in your own case.

The practical consequence: instead of "dedicated GPU + limited VRAM", you work with a large pool of memory and decide how to split that budget between model weights, context cache and the rest of the system.


3) Local LLM performance: what really consumes memory and time

When someone says "it runs on my Mac with 96 GB", they are almost always talking about the weights fitting. But in legal use, the real problem tends to be:

  • long documents (cases with hundreds or thousands of pages),
  • several filings in the same prompt,
  • the need to keep context and citations,
  • and serving multiple users (concurrency).

The math has 3 blocks:

3.1 Weights

This is the model's "base size".
A quick (approximate) calculation for 4-bit quantization is:

  • size (GB) ≈ parameters (billions) × 0.5

That is:

  • 7B → ~3.5 GB
  • 30B → ~15 GB
  • 70B → ~35 GB
  • 109B → ~54.5 GB

And that is just the beginning.

Memory budget for 4-bit weights, with the February 2026 model list

The chart above comes from the first version of this guide, from February 2026, and shows models that section 6 has already replaced (Gemma 3 27B, Qwen3-30B-A3B, Llama 3 70B). The formula works the same way for the current list: Jurema-7B comes to ~3.5 GB, Qwen3.8-27B to ~13.5 GB, Muse Glimmer-30B (~29.6B) to ~14.8 GB, Gemma 4 31B (30.7B) to ~15.4 GB, Qwen3.6-35B-A3B to ~17.5 GB and Llama 4 Scout (109B) to ~54.5 GB.

3.2 KV cache (the "context tax")

The KV cache grows with:

  • model size (layers/heads),
  • the number of tokens in the context,
  • the precision used in the cache (many runtimes use FP16/FP32 in the cache even with 4-bit weights).

In legal work, the KV cache is usually the reason why "it works with short texts but dies on a large case".

3.3 Runtime overhead + buffers (and the operating system)

Even with 96 GB, you do not have 96 GB "free":

  • macOS reserves memory,
  • the runtime reserves buffers,
  • embeddings and indexes also consume memory,
  • and parallel applications compete for resources.

Bottom line: the project is not "running a model". It is designing a memory budget.


4) Local runtimes on the Mac: how to choose (MLX, llama.cpp, Ollama, MLC-LLM, LM Studio)

There are several ways to run a local LLM on Apple Silicon, and the choice changes the result considerably.

Here is the practical (not dogmatic) take:

4.1 MLX (Apple) / mlx-lm (ecosystem)

  • MLX is an open-source Apple framework for research/production on Apple Silicon.
  • The ecosystem includes tools such as mlx-lm to run models, and optimizations such as prompt caching and a rotating KV cache.

When it makes sense:

  • focus on local performance (Apple Silicon),
  • you want programmatic flexibility,
  • you will embed the runtime in your own system.

Watch out for:

  • some optimizations and settings (e.g., "wired" memory limits) require operational care.

4.2 llama.cpp (GGUF)

  • It is the "Swiss Army knife" of local inference, with a large community.
  • GGUF format + a variety of quantizations.
  • Works well on the Mac via Metal.

When it makes sense:

  • you want predictability and broad compatibility,
  • you need aggressive quantization,
  • you want to run on different machines (not just Macs).

4.3 Ollama (fast productization)

  • Focused on "running models as a local service" (CLI + API).
  • Excellent for turning a model into an endpoint quickly.
  • Also works for embeddings (e.g., an OpenAI-compatible endpoint for embeddings).

When it makes sense:

  • you want to stand up a local service quickly,
  • you need standardized endpoints,
  • you want reproducibility via "model packages".

4.4 MLC-LLM (Metal + deployment)

  • An ecosystem focused on compiling/optimizing for devices (including Metal).
  • Useful when you want a more "deployment-oriented" path with runtime integration.

4.5 LM Studio (operations + UX)

  • Helps "glue" local operation together with an interface and distribution.
  • Interesting for teams that do not want to start from the terminal but need a local base.

There is research comparing these approaches on Apple Silicon (latency, throughput, memory use and stability). Use it as a reference to decide methodically, not by personal preference.


5) "Better than the top closed model and faster": how to treat that phrase without the marketing

This question comes up a lot, but it is almost always poorly defined. In the first version of this guide, in February 2026, the comparison that came up most was with GPT 5.2 Pro. The name of the reference model changes every few months; the criterion below does not.

Instead of "better", use an operational criterion:

  • Quality on a specific task (e.g., extracting claims and grounds with 95% precision).
  • Traceability (answering with a citation and an excerpt).
  • Time (TTFT, tokens/s and cost).
  • Privacy (data never leaves the environment).
  • Reliability (predictable, controllable errors).

In legal work, this often happens:

  • a "top" closed model is better at general conversation;
  • a local model + RAG + validation can be better within your scope, because it works with real sources (not "statistical memory") and with output rules.

This is especially true when:

  • the content is Brazilian (legislation, case law and local practice),
  • the goal is a traceable draft,
  • and the system requires checking.

6) Recommended models in 2026 (focused on what matters for legal work)

Below are model "families" that make sense to run locally with a good quality/speed ratio. The models on this list were checked in November 2026 against the official model cards published on Hugging Face. Open models ship every few months, so check the latest version of the family before downloading.

6.1 Qwen3.6-35B-A3B and Qwen3.8-27B: value for money and a huge context

Qwen3.6-35B-A3B, from April 2026, is an MoE model with 35 billion total parameters and only 3 billion active per token. In practice, this tends to help the quality × speed ratio, especially on hardware with limited compute relative to the model's total size. It replaces the Qwen3-30B-A3B this section recommended in the first version.

For those who prefer a dense model, Qwen3.8-27B came out in August 2026. Both have an Apache 2.0 license, a native window of 262,000 tokens (extendable to about 1 million) and read images, which helps with scanned filings.

It is a strong candidate when you want:

  • good general quality,
  • a large context for RAG,
  • acceptable performance on a single machine.

6.2 Llama 4 Scout and Muse Glimmer-30B (Meta)

Llama 4 Scout, from April 2025, is another MoE: 109 billion total parameters, 17 billion active and a context window of 10 million tokens, according to the official model card.
That opens room for "legal discovery" cases and analysis of large volumes, but at a cost in memory and engineering.

In practice, for legal work, the extreme context is useful when:

  • you have many documents and want to reduce retrieval calls,
  • or you want cross-document analysis with less "loss" from chunking.

If the priority is fitting on a laptop, Meta published Muse Glimmer-30B in August 2026, a dense model of about 29.6 billion parameters, with open weights under Apache 2.0 and a 131,000-token window. According to the model card, the 4-bit weights stay under 20 GB and were designed for machines with 24 GB or 32 GB of memory.

6.3 Gemma 4 (31B): a "runnable" size + a large window

Gemma 4 31B, from Google DeepMind, is a dense model with 30.7 billion parameters, an Apache 2.0 license, a 256,000-token window and text and image input. It takes the slot Gemma 3 27B had on this list. The family also includes a 26B MoE (26B A4B) and smaller versions, useful for triage and classification.

It is an interesting choice when:

  • you want a relatively large model that is still "deployable" on a laptop/desktop,
  • and you need a wide window (without going to the extreme of millions).

6.4 DeepSeek: distilled R1 on the laptop, V4 Flash on the Mac Studio

"Reasoning-first" models can be useful for:

  • tasks with logical chaining (legal theses, contradictions, strategy),
  • analysis of arguments and counterarguments,
  • identifying gaps in narratives.

The cost usually shows up as:

  • higher latency,
  • longer answers,
  • the need for control so the output does not turn into a "long-winded legal opinion".

DeepSeek's V4 generation does not fit on a laptop. Its lightest model, DeepSeek-V4-Flash, has 284 billion total parameters (13 billion active), weights under the MIT license and a context of 1 million tokens. By the math in section 3, V4-Flash comes to about 142 GB of weights alone at 4 bits, which is high-memory Mac Studio territory. The other models in the line are even larger: V4.1-Flash exceeds 760 billion parameters (about 380 GB at 4 bits, requiring a Mac Studio with 512 GB, like the top M5 Ultra configuration) and V4-Pro reaches 1.7 trillion (about 850 GB), above even the M5 Ultra's 512 GB. On a smaller machine, the path is still DeepSeek-R1-Distill-Qwen-32B, which is from 2025 but remains available.

6.5 Jurema (Brazilian legal): a model trained for the Brazilian domain

If your focus is Brazilian law, it makes sense to look at models tuned for the domain.

Jurema-7B, published in July 2025 by NeuralMind and Escavador (a Brazilian legal data company), is a fine-tune of Qwen2.5-7B-Instruct for the Brazilian legal domain, with open weights under Apache 2.0. Training used a synthetic dataset, largely questions and answers, derived from curated Brazilian legal documents. On the model card, it beats the base model on the BLUEX, ENEM and OAB evaluations (based on Brazilian university entrance exams, the national high school exam and the bar exam), scoring 0.668 versus 0.533 on OAB. The authors themselves describe it as an early version that may make mistakes or omissions, and not as a substitute for professional legal advice.

It does not replace a larger model at everything, but it can be very good at:

  • legal language,
  • the structure of filings,
  • writing and organization patterns.

7) The architecture that actually works: RAG + evidence + validation

"Sending the whole case" to the model and asking it to "write the defense" is the fastest path to:

  • unfounded answers,
  • invented citations,
  • risk of leaking data,
  • and low reproducibility.

The architecture that works in legal settings is almost always RAG (Retrieval-Augmented Generation) with traceability.

Recommended architecture: local LLM + RAG

7.1 What goes into the index (it is not "everything")

A typical (well-built) legal index separates:

  • Case documents (filings, exhibits, decisions).
  • Official normative sources (laws, decrees, resolutions).
  • Selected case law (with date, court, deciding body, headnote + full text where applicable).
  • Internal content (filing templates, standard clauses, company policy).

And it versions everything:

  • "which law was in force",
  • "which standard clause was active".

7.2 Embeddings: a pragmatic choice

To retrieve well in Portuguese (and in legal text), you want embeddings that are:

  • strong in multilingual/Portuguese text,
  • able to handle long text,
  • reasonably cheap to compute.

Models such as BGE-M3 (embeddings) are used because they support many languages and longer documents.
In many stacks, FAISS serves as the vector indexing base thanks to its maturity and efficiency.

7.3 Citation as a product requirement (not a "nice to have")

Define a contract on the model's output such as:

  • "every relevant legal statement must point to an excerpt of the retrieved corpus"
  • "if there is no evidence, answer 'not found' and suggest where to look"
  • "return document ID + excerpt + page/offset when possible"

That changes everything:

  • the model becomes a research assistant,
  • not an "oracle".

8) Brazilian sources and open data: where your RAG should look

From a legal and technical standpoint, prefer sources that are:

  • official,
  • stable,
  • and highly traceable.

8.1 LexML and open legislation data

LexML standardizes the identification of legal norms (the URN many collections use as a key), but the full text lives on the source sites. For the text, three paths appear in most projects: Planalto (the Brazilian Presidency's official legislation site), with compiled federal legislation for reading; the normas.leg.br portal, from Brazil's Congress, with a public interface that delivers the text article by article; and open collections already converted to text, such as the ctresb/leis repository, with more than 1 million documents in October 2026.

A converted collection saves months of collection work, but it inherits the compilation date of its source. In the check we did in October 2026, some federal laws marked as in force did not include recent amendments. Use the collection to find the norm and check the wording on Planalto before citing it. The details, with the method, are in An open database of Brazil's laws: can it be used for legal AI?.

8.2 Datasets and utilities (NER, classification etc.)

For automations such as:

  • identifying parties, numbers, agencies, amounts, dates,
  • classifying the type of action and subject,

datasets like LeNER-Br (NER on legal documents) help a lot, even if you are not going to "train the LLM" but rather train auxiliary components.

8.3 Benchmarks in Portuguese (including the OAB exam)

To measure "does the model understand legal Portuguese?", benchmarks help.

The Open Portuguese LLM Leaderboard and evaluation suites include tasks such as:

  • BLUEX (comprehension, based on Brazilian university entrance exams),
  • ENEM (Brazil's national high school exam),
  • and datasets of questions from the OAB Exam, Brazil's bar exam (with their limitations and "test-taking" bias).

9) LGPD + governance: what changes when you put case files into an AI pipeline

Even when running locally, you are still processing personal data (and sometimes sensitive data).
Local-first reduces the risk surface but does not eliminate obligations.

Below is a practical (not exhaustive) checklist:

9.1 Minimum LGPD checklist for a legal LLM

  • A defined legal basis for processing (and internal documentation).
  • Minimization: index only what is necessary (and with retention policies).
  • Redaction/masking of PII when the goal does not require data "in the clear".
  • Access controls (per client/case profile).
  • Careful logging: logging "metadata" is different from logging "full content".
  • Encryption at rest (disk) and in transit (if there is a network).
  • Audit trails: who queried what, and when.
  • A cleanup/purge routine (data retention).
  • A human review policy before any external use.

9.2 AI guidelines in the Judiciary (CNJ): why they matter even outside the courts

The CNJ (Brazil's National Council of Justice) has been advancing rules and guidelines on the responsible use of AI in the Judiciary, reinforcing principles such as transparency, governance and risk mitigation.

Even if your system is for a law firm or company, it is worth aligning with these principles, because:

  • they become the ecosystem's "regulatory expectation",
  • and they help justify technical decisions to clients and compliance.

10) Train or not train? RAG first, LoRA later

Many people start with fine-tuning, but in legal work it is usually the other way around:

  1. Well-built RAG (official source + good indexing + citations + validation)
  2. Then, if necessary, LoRA / fine-tuning for:
    • writing style,
    • the structure of filings,
    • team preferences (without "inventing law").

10.1 What makes sense to train

  • Formatting and style (filing patterns).
  • Structure (mandatory topics per type of action).
  • "Rubrics" and checklists.
  • Auxiliary classifiers.

What does NOT make sense (in most cases):

  • trying to "teach legislation" through fine-tuning and expecting it to replace the source.

Laws change. Case law changes.
RAG solves updates; fine-tuning does not.

10.2 Synthetic data: useful, but with method

For Brazilian Portuguese, there is research showing that synthetic data can help in SFT, but it requires rigorous evaluation and care with bias.


11) Quality pipeline: what separates a "demo" from a "legal product"

Without evaluation, you are in the dark.

A minimum quality pipeline includes:

  • a dataset of (anonymized) cases + well-defined tasks,
  • automatic measurement,
  • and human sample review.

Quality pipeline in legal work

11.1 Metrics that matter (legal)

  • Extraction precision (parties, claims, deadlines).
  • Coverage (how many relevant points were captured).
  • Citation precision (does the excerpt really support the statement?).
  • "I don't know / not found" rate (ideally not zero).
  • Time:
    • TTFT (time-to-first-token),
    • tokens/s,
    • total time per task.

12) Implementation playbook on the Mac (from zero to useful)

Below is an "engineering" roadmap, independent of the stack.

12.1 Define the input and output contract

Input:

  • a folder of documents (PDF/DOCX),
  • case metadata (client, number, stage, court).

Output (example):

  • JSON with:
    • summary,
    • list of claims,
    • timeline,
    • risks,
    • citations (doc_id, page/excerpt).

12.2 Choose a runtime for the MVP

If you want MVP speed:

  • Ollama (local service) or LM Studio (UX).

If you want to control performance and details:

  • MLX / mlx-lm or llama.cpp.

12.3 Start with a "runnable", reliable model

Start with:

  • 7B to 14B for the pipeline and validation,
  • then move up to 27B to 32B,
  • and only then evaluate 70B+.

12.4 Simple RAG (first), hybrid (later)

Phase 1:

  • embeddings + FAISS
  • top-k with metadata filtering

Phase 2:

  • hybrid (BM25 + vector)
  • re-ranking
  • heuristics per document type (decision, petition, contract etc.)

13) Common mistakes (that become legal problems or bad products)

  • "The model knows the law": no. It predicts text. Without a source, it invents with confidence.
  • Indexing everything without separation: mixes cases and creates logical leakage.
  • No versioning: you do not know "which base" generated the text.
  • No citations: you cannot audit.
  • No human review: you turn AI into operational risk.
  • No access control: you create confidentiality risk.

14) Final checklist for safely launching a local legal LLM

  • Tasks defined (input/output, success criteria).
  • RAG with official sources and versioning.
  • Mandatory citations in every relevant answer.
  • Automatic validation (structure, citations, consistency).
  • Observability (metadata logs + audit).
  • LGPD controls (access, retention, encryption).
  • Human review as a formal step.
  • Metrics (quality + time) running on a test dataset.

15) If you want to implement this at production level

If your goal is to build a local-first system for legal work (RAG, models, governance, performance and an audit trail), this is a product + engineering + compliance project.

We help design and implement:

  • local-first architecture (Mac / Linux / servers),
  • ingestion and indexing pipelines (cases, contracts, case law),
  • RAG with validation and traceability,
  • evaluation and metrics (quality and performance),
  • security, LGPD and governance.

See our services


References and recommended reading (selection)

Hardware / Apple Silicon

Runtimes and tools (local)

Models (open-weight)

RAG, embeddings and indexing

Brazil: governance / LGPD / guidelines

Evaluation in Portuguese (benchmarks)

Also read

macOS runners in CI: Intel vs Apple Silicon, costs and pitfallsRAG in practice: what decides whether the assistant is right or makes things upRegression testing for prompts and RAG: how to keep AI from getting worse
Previous post
MFA/2FA for clients: a secure account that never blocks your app release
Next post
Git CI/CD guide for small teams: performance, cache and runners
Newsletter

One email a month, no noise

What we learn shipping custom software and applied AI.

Related articles

macOS runners in CI: Intel vs Apple Silicon, costs and pitfalls5 min · Technology
RAG in practice: what decides whether the assistant is right or makes things up11 min · Technology
Regression testing for prompts and RAG: how to keep AI from getting worse3 min · Technology
The AI ecosystem for building software: how the pieces connect6 min · Technology
Cerebras model for fast RAG: which one to use and what the pipeline needs12 min · Technology

Accelerate your business with X-Apps

Ask for a Budget
X-Apps is an IT provider partner and advised by
Gartner
Receive our e-mails
News on software and applied AI.
Follow X-Apps