Skip to content
Nawap BastolaAI engineer
All work02 of 062025 — 26Private AI

On-Prem Legal AI

A private AI workspace for legal teams that runs on hardware in their own office, so documents and questions never leave the building.

My role
AI engineer
For
Early stage on premise AI hardware company
When
2025 to 2026
Status
Delivered, engagement wrapped 2026
Stack
OllamaOpen WebUIRAGMCP
On-Prem Legal AI · 1:33Silent walkthrough

The 93 second recording walks through model management, a document collection, a cited answer, a workflow, the audit log and the system console. The names and documents in it are synthetic.

01

The situation

Law firms and clinics cannot paste privileged documents into a public chatbot. So they either skip AI and lose the productivity, or use it anyway and accept the risk. Both options are bad, and this product existed to close the gap with a preconfigured computer, roughly the size of a thick book, that ships with local models and a browser interface reachable from any device in the office.

The idea we kept coming back to was network accessed intelligence. Where a NAS made files a shared network resource, this makes inference a shared, governed, auditable resource the firm owns. My job was the software side of that promise. Deployment, hardening, the interface, and the retrieval layer for legal documents.

02

How it works

The diagram is the pipeline. The frames below it are taken from the recording.

  1. StoreLocal modelsOllama serves open models such as Llama, Mistral, Qwen and Gemma. Admins pull new ones from the settings page.
  2. StoreDocument collectionsPDF, Word, Outlook messages and spreadsheets are parsed, chunked and embedded into a local vector store.
  3. RetrievalA question pulls the relevant passages from the collections the user is allowed to see.
  4. Cited answerThe model answers with citations that open the exact passage, its page and a relevance score.
  5. Tools and workflowsMCP servers and n8n workflows extend the assistant without sending data off the machine.
  6. GateAudit logEvery prompt, retrieval, upload and workflow run is logged with user and timestamp.
  7. GateAir gap switchA kill switch cuts WAN traffic while models, knowledge and workflows keep running on the LAN.
Settings page pulling a model from Ollama with a progress bar and two models already ready

Manage models from the browser

Admins pull models by name from the settings page and watch the download. The box runs as many as it has room for.

Document collection listing agreements, spreadsheets and board minutes with extracted text preview

Build a document collection

A data room takes any mix of formats. Each file is parsed, chunked and embedded locally, and access stays scoped to the group you grant.

Chat answer about termination rights with a citation popover showing the source passage and page

Check the answer against the source

Opening a citation shows the exact passage, its page and a relevance score, so a lawyer can verify the claim without reading logs.

Workflow canvas with a chat trigger connected to a local AI agent node

Automate without leaving the box

Workflows are built visually in the bundled n8n instance and call the local model, so an intake or conflict check runs on the same hardware.

Audit trail table with time, level, user and message for prompts, uploads and workflow runs

Keep an audit trail

The admin log records every prompt, retrieval, upload and workflow run with the user who triggered it.

Dark system console with GPU temperature and load dials, tokens per second, storage and an internet kill switch

Watch the machine

A separate console shows GPU load, inference throughput, storage and network, with a kill switch that cuts WAN traffic while everything keeps running on the LAN.

03

Decisions that mattered

  1. Build on Open WebUI, then own the fork

    Starting from a proven interface bought the chat, document and admin surfaces. The fork added audit logging, a monitoring dashboard, offline bundles and hardened MCP tool execution.

  2. Lawyer readable first, telemetry second

    Show which documents an answer used before showing anything about tokens or retrieval scores. The detailed logs stay available but one click away.

  3. Harden like a public server

    Fail2Ban, AppArmor, HSTS, a strict content security policy and nosniff headers, even though the box lives on an office network.

  4. A retry loop for models without native tool calling

    Smaller local models do not all support function calling, so tool use runs through a ReAct style loop that retries and shows each call in the interface.

04

Where it landed

Local model management, document collections with cited answers, workflows and an audit trail on hardware the customer owns. The point of the product held. Models, documents and answers stayed on the box.

What holds
  • Local models, no cloud accounts
  • Answers open the passage they came from
  • Audit log and air gap switch for compliance conversations
What stayed open
  • Legal retrieval quality was still open work when the engagement ended. Evaluating legal specific embeddings and OCR quality for scanned filings was on the list, so this page makes no clause level accuracy claims.
  • Multi user load and multi GPU concurrency were not validated.
  • The client stays unnamed here.
05

Notes from the build

Written in my own words, after the fact. Opinions, not claims.

This ran alongside the BusinessFrame work for the same client, and it pulled me toward the operations side of AI. Getting a model to answer is the easy part. Getting a box to a law firm that keeps working without anyone from us on site, that a paralegal can administer, and that a compliance officer will sign off on is the actual product.

The note I kept coming back to in my own list was make it lawyer readable. A retrieval score means nothing to the person reading the answer. They want to know which document it came from and whether they can trust the passage. That reordered the whole interface.

I would want an evaluation set of real legal questions with known answers before I called the retrieval done. We never got there, and I would rather say that than claim it.

Nawap Bastola · 2025 to 2026