Relja Bulajić← All systems

Case 03 / 08 · Private AI model

Bastion

An AI model trained on the client's own documents, running on their own server. Nothing leaves the building.

The problem

Sending every invoice, contract and customer file to an outside AI company is a risk many businesses will not take. General models also get industry paperwork wrong, and the API bill grows with every document.

How it works

Six steps,one system.

  1. 01Collect and clean
  2. 02Label
  3. 03Train
  4. 04Test against GPT
  5. 05Deploy on site
  6. 06Run and improve
bastion · runStep 01 · Collect and clean

Dataset · client archive

Rate confirmations18,420
Bills of lading14,906
Invoices6,731
Personal data masked

"Call [NAME] at [PHONE]"

40,057 past documents, cleaned. The model learns the format, not the people.

Simulated run · illustrative data

Thousands of the client's past documents are collected, cleaned, and stripped of personal data.

Inside

What I built,layer by layer.

01

Trained on their own work

An open model (Qwen, Llama) is fine-tuned with LoRA on the client's real documents, so it learns their brokers, formats and abbreviations.

02

Tested before it ships

Every new version is scored on documents it has never seen. It only replaces the old one if it is better on every field.

03

Runs where the data lives

One GPU server or Mac Studio in the client's office. A cloud model is only a backup, and only for documents the client allows.

Engineering decisions

01

Small and specialised beats big and general

A 7B model trained on one job outperforms a frontier model that has never seen a rate confirmation, at a hundredth of the cost.

02

Personal data removed first

Names, phone numbers and account numbers are masked before training, so the model learns the format, not the people.

03

Every answer has a confidence

Low-confidence fields go to a person instead of guessing, and each correction becomes training data for the next version.

Scale of the codebase

98.6%

fields read correctly, GPT 91%

$0.0004

per document, API was $0.02

1

machine on site, no internet needed

0

documents sent outside

Qwen 2.5LlamaLoRAMLXPyTorchvLLMOllamaPostgreSQLQwen 2.5LlamaLoRAMLXPyTorchvLLMOllamaPostgreSQL

Designed, trained, evaluated and deployed end to end: the data pipeline, the training runs, the test set, the on-site server and the fallback to a cloud model.

Next case

LaunchPilot →