GGUF Discovery

Blog & Guides

Back to All Articles

How to Build a Local AI Assistant for Legal Documents

Complete guide to Lawyer Assistant by Hussain Nazary β€” a free, open-source AI that finds clauses & risks instantly, 100% on your computer.

Your legal documents deserve better than Ctrl+F. That's the simple idea behind Lawyer Assistant β€” a free, open-source desktop AI created by Hussain Nazary that reads, searches, and checks your contracts, entirely on your own computer.

Instead of reading through hundreds of pages hunting for payment terms or renewal clauses, you ask a question in plain English and get an instant answer with the exact page number and source text β€” fully verifiable, no hallucinations, and no part of your document ever leaves your machine.

πŸš€ Key Takeaway

Lawyer Assistant is like having a smart assistant who has read all your contracts. Ask anything in natural language, get answers with exact sources, automatically detect risky clauses like unlimited liability or auto-renewal β€” and keep every byte of your data 100% local. No cloud, no subscriptions, no tracking.

🌐 Visit Official Website ⭐ GitHub Repository

Why Your Contracts Deserve Better Than Ctrl+F

Most of us review legal documents the way people searched the web before Google: manually, slowly, and with a real risk of missing the important parts. Here's the problem with how contract review works today:

  • Searching contracts is slow and frustrating β€” Ctrl+F only finds exact text, not meaning.
  • Important clauses get missed β€” buried in dense legalese, buried in page 47.
  • Online AI tools are a privacy risk β€” upload a contract to a web chatbot and your document goes to someone else's server.
  • Professional tools are expensive β€” legal SaaS platforms like Kira or eBrevia are enterprise-priced, and generic AI chat gives unreliable citations.

Lawyer Assistant solves all four at once β€” and it's completely free under the MIT license.

About the Creator: Hussain Nazary

Hussain Nazary is the creator behind Lawyer Assistant, an open-source project that demonstrates how privacy-preserving AI can be powerful, accessible, and completely free. Through the haal-lab organization on GitHub, Nazary has built a sophisticated legal document analysis system that prioritizes user privacy above all else.

🎯 Project Philosophy

The project embodies three core principles that set it apart from commercial legal AI solutions:

  • Privacy-First Design β€” Your documents never leave your machine, period.
  • Open Source Transparency β€” Every line of code is reviewable under the MIT license.
  • True Free Software β€” No freemium model, no enterprise upsells, just free forever.

The official website at lawyers-assistant.github.io serves as the central hub for documentation, downloads, and community resources. Whether you're a solo practitioner, small business owner, or developer looking to build privacy-first AI applications, Lawyer Assistant provides a complete reference implementation.

πŸš€ Ready to Get Started?

Visit the official website for complete documentation and downloads

Visit Lawyer Assistant β†’

What You Can Do With It

πŸ’¬ Ask Questions in Plain English

"What are the payment terms?" Β· "Can I terminate this contract early?" Β· "What are my obligations under this agreement?" The app searches every document in your project and answers with the exact page number, document name, and a preview of the relevant text. Click through to see the full context β€” no guessing, everything verifiable.

⚠️ Find Risky Clauses Automatically

Scan any contract for problems the way a careful paralegal would: unlimited liability, automatic renewal, broad indemnification, vague payment terms, missing termination rights. Each finding is flagged High / Medium / Low risk with a plain-English explanation of why it matters β€” and you can customize your own rule sets via JSON playbooks.

πŸ“„ Work With Any Document Type

PDFs (even scanned image PDFs), Word documents, text files, and images with text. Drop files into your project folder and the app automatically indexes them in the background β€” no manual "upload" button needed.

πŸ—‚οΈ Organized by Project

Work on different cases in separate folders, each with its own documents and search history. No mixing between projects, full isolation.

πŸ”— Every Answer Comes With Its Source

Every response includes the exact document name, the page number, and a preview of the supporting text. For legal work, knowing where an answer came from β€” and being told honestly when it isn't in your documents at all β€” is just as important as the answer itself.

🧠 Visual Pipeline Editor

A drag-and-drop node editor (think n8n or Node-RED) lets you build your search pipeline visually: Search, Rerank, Filter, and Merge nodes you connect yourself. Fine-tune how the app retrieves answers without touching a configuration file.

Real-World Use Cases

Lawyer Assistant isn't just a tech demoβ€”it's a practical tool being used by real people to solve real legal document challenges. Here are the most common use cases:

🏒 Small Business Owners

The Challenge: Reviewing vendor contracts, client agreements, and terms of service without paying hundreds per hour for legal review.

The Solution: Upload all your contracts to Lawyer Assistant and ask questions like "What are my termination rights?" or "Are there any auto-renewal clauses?" Get instant answers with exact citations you can verify yourself.

πŸ‘¨β€πŸ’Ό Freelancers & Consultants

The Challenge: Understanding client contracts before signing, especially payment terms, IP ownership, and liability clauses.

The Solution: Run the compliance scanner to automatically flag risky clauses like unlimited liability, unclear payment terms, or unfavorable IP transfers. Get a plain-English risk assessment in seconds.

πŸŽ“ Law Students & Researchers

The Challenge: Analyzing large volumes of case law, statutes, or legal documents for research without expensive legal databases.

The Solution: Create project folders for different research topics, index all relevant documents, and use semantic search to find connections across your entire document collection.

🏠 Property & Real Estate

The Challenge: Understanding lease agreements, property management contracts, and HOA bylaws.

The Solution: Search across multiple property documents simultaneouslyβ€”ask "What are the maintenance responsibilities?" and get answers from every lease in your portfolio with exact references.

πŸ’Ό Paralegals & Legal Support Staff

The Challenge: Preliminary document review and due diligence work that's time-consuming but doesn't require attorney-level expertise.

The Solution: Pre-screen documents for common issues, extract key terms and dates, and prepare summaries for attorney reviewβ€”all while maintaining strict client confidentiality with local processing.

Want to see these use cases in action? Visit lawyers-assistant.github.io for video tutorials and example workflows.

How It Works: Local Retrieval + AI Answers

The magic is a classic RAG (Retrieval-Augmented Generation) pipeline, run entirely on your hardware in local mode:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ LAWYER ASSISTANT β€” ARCHITECTURE β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Your │──▢│ Retrieval │──▢│ LLM β”‚ β”‚ β”‚ β”‚ Documents β”‚ β”‚ Pipeline β”‚ β”‚ Answer β”‚ β”‚ β”‚ β”‚ (local) β”‚ β”‚ BGE-M3 + ChromaDB β”‚ β”‚ Ollama or β”‚ β”‚ β”‚ β”‚ PDF, DOCX, β”‚ β”‚ BM25 + Reranker β”‚ β”‚ Cloud API β”‚ β”‚ β”‚ β”‚ Images... β”‚ β”‚ β”‚ β”‚ +citationsβ”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Compliance Scanner β”‚ β”‚ β”‚ β”‚ Clause classification ──▢ Playbook rules ──▢ Flags β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • Hybrid search β€” semantic (BGE-M3 embeddings) + keyword (BM25) matching, with AI reranking on top, so legal terminology is handled correctly.
  • Local vector store β€” ChromaDB keeps your index on disk, in your folder.
  • No hallucination policy β€” when the answer isn't in your documents, the app says so honestly instead of inventing one. For legal work, that honesty is a feature, not a bug.

πŸ”§ Technology Stack Deep Dive

For developers and technical users, here's what powers Lawyer Assistant under the hood:

  • Embedding Model: BGE-M3 (BAAI General Embedding) for multilingual semantic search
  • Vector Database: ChromaDB for efficient similarity search with metadata filtering
  • Keyword Search: BM25 (Best Matching 25) algorithm for precise term matching
  • LLM Backend: Ollama for local inference (supports 100+ models including Llama, Mistral, Gemma)
  • Document Parsing: OCR-enabled PDF/image processing for scanned documents
  • API Support: REST + SSE (Server-Sent Events) for streaming responses

Learn more about the architecture on the GitHub repository or visit lawyers-assistant.github.io for detailed documentation.

Building Your Own Legal AI: Step-by-Step Tutorial

Want to build a similar system for your specific needs? Here's how Lawyer Assistant's architecture can serve as a blueprint for building local AI applications:

Step 1: Document Ingestion Pipeline

1. Watch project folder for new files
2. Parse documents (PDF, DOCX, images via OCR)
3. Split into chunks (with overlap for context)
4. Generate embeddings using BGE-M3
5. Store in ChromaDB with metadata (filename, page number, chunk position)

Step 2: Hybrid Search Implementation

1. User asks a question
2. Generate embedding for the question (semantic search)
3. Perform BM25 keyword search in parallel
4. Combine results using Reciprocal Rank Fusion
5. Re-rank top candidates using cross-encoder
6. Return top N most relevant chunks

Step 3: Answer Generation with Citations

1. Take retrieved chunks as context
2. Construct prompt with source attribution requirements
3. Send to LLM (Ollama locally or API)
4. Parse response and extract cited sources
5. Format answer with clickable page numbers
6. Display source preview for verification

The complete implementation is available at github.com/haal-lab/Lawyer-Assistant under the MIT licenseβ€”use it as a starting point for your own projects.

Two Modes: Local & Cloud

Local Mode (100% Private) API Mode (Faster Answers)
LLM Ollama β€” runs on your GPU/CPU, 100+ models Claude, ChatGPT, DeepSeek, Groq, Gemini + 13 providers
Search βœ… Local (always) βœ… Local (always)
Documents βœ… Never leave your machine βœ… Never leave your machine
Offline βœ… Yes ❌ Needs internet for the LLM
Setup Install the app only Paste an API key

Here's the crucial privacy detail about API mode: even when you use ChatGPT or Claude, only the tiny piece of text needed to answer the current question is sent β€” never your full documents. Your files stay on your computer in both modes.

πŸ”’ Privacy & Security, By Design

  • No telemetry, no analytics, no tracking β€” nothing phones home.
  • Open source (MIT) β€” you can read every line of code and verify the privacy claims yourself.
  • Safe by design β€” the app only touches the folders you choose.

Lawyer Assistant vs. The Alternatives

Feature Lawyer Assistant Generic AI Chat Legal SaaS Tools
100% local / private βœ… Yes (local mode) ❌ Cloud-only ❌ Cloud-only
Works offline βœ… Yes (local mode) ❌ No ❌ No
Source citations βœ… Every answer + page ⚠️ Sometimes, unreliable ⚠️ Limited
Compliance scanning βœ… Built-in + custom playbooks ❌ No ⚠️ Extra cost, enterprise only
Hybrid search βœ… Dense + Sparse + Reranker ⚠️ Semantic only ⚠️ Keyword only
Visual pipeline editor βœ… Drag & drop ❌ No ❌ No
Multi-format support βœ… PDF, DOCX, images, text ⚠️ Limited ⚠️ PDF only (most)
Open source βœ… MIT license ❌ Closed ❌ Closed
No subscription βœ… Free forever ❌ $20–200/month ❌ $$$-$$$$
REST API for automation βœ… REST + SSE streaming ⚠️ API-only, no desktop ❌ No

Getting Started with Lawyer Assistant

Setting up your own local AI legal assistant takes less than 15 minutes. Here's the complete walkthrough:

πŸ“₯ Installation Process

  1. Download the installer from lawyers-assistant.github.io or the GitHub releases page.
  2. Run the installer β€” launch.bat on Windows, launch.sh on Mac/Linux.
  3. Wait for initial setup β€” the app automatically downloads required AI models (BGE-M3 embeddings + your chosen LLM). This takes 5–10 minutes on first run.
  4. Choose your mode:
    • Local Mode: Install Ollama for 100% offline operation
    • API Mode: Connect to Claude, ChatGPT, DeepSeek, or other providers
  5. Create a project β€” Click "Work in a folder" and select where your documents live.
  6. Add documents β€” Drop PDFs, DOCX files, or images into the folder. Indexing happens automatically in the background.
  7. Start asking questions β€” Type questions like "What are the payment terms?" and get instant, cited answers.

βœ… Pro Tip: Start with a Test Document

Before uploading sensitive contracts, test the system with a sample document like a Creative Commons license or public domain contract. This lets you understand how the search works and verify accuracy before committing real legal documents.

200+
Features
13
AI providers
7
CLI tools
6
File formats
$0
Subscriptions

πŸ’» Hardware Requirements

The recommended setup is 16GB RAM + an 8GB graphics card (NVIDIA, AMD, or Apple M-series), with ~14GB of disk space. The app also runs in CPU-only mode on 8GB RAM with slower searches, and it's been tested on laptops with 8–16GB of RAM.

Configuration Performance Use Case
8GB RAM, CPU only 3-5 seconds per query Light usage, small document sets
16GB RAM, 8GB GPU 1-2 seconds per query Recommended for regular use
32GB+ RAM, 16GB+ GPU <1 second per query Heavy use, large document collections

Need detailed setup instructions? Visit the comprehensive guide at lawyers-assistant.github.io

Frequently Asked Questions

❓ Is Lawyer Assistant really free?

Yes, completely. It's open source under the MIT license with no subscriptions, freemium tiers, or hidden costs. Download, use, modify, and distribute freely.

❓ How does it handle attorney-client privilege?

Your documents never leave your machine. In local mode, everything runs offline. Even in API mode, only small text snippets needed for answers are sentβ€”never full documents. This makes it suitable for confidential legal work, though you should always consult your jurisdiction's specific rules.

❓ Can I use this for client work as a lawyer?

It's a tool, not legal advice. Lawyer Assistant helps with document search and analysis, but all outputs should be reviewed by a qualified attorney. Think of it as a smart search assistant, not a replacement for human legal judgment.

❓ What languages does it support?

BGE-M3 supports 100+ languages. While optimized for English legal documents, the underlying embedding model works with multilingual text. The LLM's language support depends on which model you choose (Ollama offers many multilingual options).

❓ How accurate is the clause detection?

Every answer includes verifiable sources. The hybrid search (semantic + keyword + reranking) provides high accuracy for legal terminology. Since every response shows the exact page number and text preview, you can verify accuracy immediately.

❓ Can I integrate this with my existing tools?

Yes, via the REST API. Lawyer Assistant includes a REST API with SSE streaming for integration with other applications. Full API documentation is available at github.com/haal-lab/Lawyer-Assistant.

❓ Where can I get support?

Community support is available on GitHub. Check the Issues page for troubleshooting, or visit lawyers-assistant.github.io for documentation and guides.

For Developers

Lawyer Assistant is fully open source under the MIT license:

git clone https://github.com/haal-lab/Lawyer-Assistant.git
cd Lawyer-Assistant
npm install
npm run dev
  • Stack β€” desktop app with a backend, frontend, and full test suite (pytest + npm run typecheck).
  • REST API with SSE streaming, for automation and integration.
  • 75+ configuration options and custom compliance rule sets.
  • 25+ documentation pages covering architecture, API reference, GPU memory management, and troubleshooting.
  • Benchmarking system β€” a 200-question legal dataset with performance charts.
⭐ View on GitHub Read the Docs

πŸ’Ž Summary: Build Your Own Privacy-First Legal AI

Lawyer Assistant by Hussain Nazary proves that serious AI tools don't have to trade away your privacy. It combines a genuinely useful RAG pipeline β€” hybrid search, AI reranking, source citations, and a compliance scanner β€” with a hard rule that your documents never leave your machine. In local mode it runs completely offline via Ollama; in API mode it sends only the snippet needed for the answer.

For anyone who handles contracts β€” freelancers, small businesses, students, or professionals β€” it's the local-first answer to document AI, and it's completely free. Try it out, and if it helps you, give the project a star to help others find it.

πŸš€ Get Started Today

Visit Official Website View on GitHub

Created by Hussain Nazary β€’ MIT Licensed β€’ 100% Free Forever

Related Resources

πŸ“š Official Documentation

Complete setup guides, API reference, and troubleshooting.

Visit lawyers-assistant.github.io β†’

⭐ GitHub Repository

Source code, issues, discussions, and contributions.

Explore on GitHub β†’

πŸ› οΈ Local AI Setup Guides

Learn about running AI models locally with Ollama and ChromaDB.

Browse Local AI Zone β†’

πŸ“° Stay Updated

Follow the latest developments in local AI and privacy-first tools

Read More Articles
Back to All Articles