Project
Local AI Document Analyzer
Document AI that reads, structures and answers, with the files kept on my own PC.
Where it runs: On my own computer
- Platforms
- Windows (local only)
The problem
AI can read a scanned contract, pull the articles out of a law or answer a question about a security standard in seconds. Most tools that do this want the document uploaded to a cloud service first. In security work that often ends the conversation, because the documents are confidential. I wanted a concrete answer to one question: can AI do this work without the documents leaving the building?
What it does
Local AI Document Analyzer (working name DocForge, the name you see in the screenshots) is a document pipeline that runs on my own PC, in Greek and English. It cleans up phone photos of pages, reads PDFs, Word, PowerPoint, Excel and text files, and turns them into Markdown and structured JSON that my other tools and AI agents can read. It writes summaries, reads invoices into an Excel workbook and answers questions about the processed documents with citations to the article or section and page. Reading, OCR, structuring, summaries, search and answers all run on local models. I use it for my own documents, such as contracts, and to turn legislation and security standards into structured data.
How it works
Drop files in
Into the chat, a one-job Tools page or a watch folder. Office files open read-only with macros disabled.
Each page is read the right way
A page with a real text layer is read directly. A scanned page goes to a local OCR model. If the OCR result looks wrong (mixed alphabets, too many non-words), a larger local vision model reads the page again and the page is marked low confidence.
Structure comes from rules, not from AI
Laws are split into articles, chapters and definitions, with checks on the numbering. Standards are split into sections and requirements. Everything becomes search chunks that carry their place in the document and their page number.
Local models summarise and answer
Answers are written only from the passages found, with numbered citations.
Results stay in a folder on the PC
Markdown, JSON, chunks, summaries and, for invoices, an Excel workbook.
Key features
Local by rule, not by setting
The list of tasks that may ever use a cloud model is written in the code, and it has three entries. They are understanding a typed request, polishing an abstract the local model already wrote, and turning an invoice question into a filter. All three are off by default. OCR, page images, document text, invoices, embeddings and questions about documents always use local models, whatever the settings say. Every cloud attempt is logged with the exact text, refused attempts included.
Every page read the right way
Each PDF page is checked on its own: text layer, local OCR, or a second reading by a larger local vision model when the OCR looks doubtful. Doubtful pages are flagged as low confidence instead of being passed off as clean text. Greek text gets extra checks against a Greek word list and for Latin or Cyrillic look-alike letters.
Laws and standards as structured data
Dedicated parsers turn a law into articles, paragraphs, chapters, recitals and definitions, and a standard into numbered sections and requirements, as JSON and Markdown. The parsers work on standards I already hold; the tool does not include or share any standard text. On public documents they found 58 of 58 articles in a Greek law from the Government Gazette and 85 of 85 articles in the EU AI Act. They also processed all 492 pages of NIST SP 800-53.
Answers with citations
Questions are answered from a local index that combines Greek-aware keyword search with multilingual embeddings. A Greek question can find an English article. I tested it on 21 questions about a Greek law, the AI Act, NIST and OWASP material. Each time, the right article was among the passages given to the model and the answer cited it. For invoice questions the model only builds the filter, such as vendor, dates and sum; the code does the arithmetic.
Phone photos to clean scans
See the picturesA photo of a page is cropped, straightened to A4 or Letter, flattened if the page is curved, and cleared of shadows, then saved as images and a PDF. On the test photos, cleanup never made OCR worse.
Invoices to Excel, with checks
A local vision model reads each invoice into a strict format. Then the code checks the Greek VAT number (ΑΦΜ) checksum, the line arithmetic, the totals and the VAT rates. Problems are flagged, not hidden. A review screen lets you correct a field before it goes into the Excel workbook, which is updated in place, not recreated.
In pictures
Phone photo to clean scan
- Screenshot to follow
A question about the EU AI Act, answered locally with citations to article and page. - Screenshot to follow
The Activity page shows which tasks may use the cloud and every cloud request made. - Screenshot to follow
How each page is read. - Screenshot to follow
A law article as structured JSON, ready for other tools. - Screenshot to follow
Reviewing a fictional invoice before it goes into the Excel workbook.
Security and privacy
In plain terms: the documents stay on the PC. Only short pieces of text can leave, only if I switch a cloud task on, and every attempt is written down.
- Always local: full document text, page images, scans, OCR, invoice files, structuring, summaries of sections, search embeddings and questions about documents. This is fixed in the code. No setting can change it.
- May leave, only if switched on per task: a typed request with the names of attached files, an abstract the local model already wrote, or an invoice question with the vendor names and date range it needs. The cloud side is a hosted model API. All three are off by default.
- Checked before sending: plain text only, no images and no encoded files, and a size cap set at 8,000 characters, so a whole document never fits. If a check fails, nothing is sent and the local model answers instead. If the cloud is down, the local model answers too.
- Logged: every cloud attempt is logged with its time, task, model, result and the exact text sent. Refused attempts are logged with the reason. The Activity page shows the log and which tasks have the cloud switched on. The log holds the exact text sent, so it is as sensitive as that text, and it stays on the PC.
- So far, never used: no cloud key is set on the PC. The cloud path is tested with a simulated network, not with a real request.
- The interface answers only on the PC itself. It refuses requests that name another host (protection against DNS rebinding) and form posts from other websites. A strict content security policy applies, and fonts and scripts load from the PC, never from the internet. Files are served only from the output folder.
- Limits: single user and no login, so anyone who can use the PC can use the app. Results and the log are ordinary files on the PC, protected by the PC's own account controls and by disk encryption, on the internal disk and on the external drives I use for copies.
- The code repository holds code only. Documents, results and test material are kept out of it.
Under the hood
A Python app with FastAPI serves a local page written in plain JavaScript, with no framework. The heavy document parsers run in their own environments. LM Studio and a llama.cpp server serve the models on the PC: an OCR model, two language and vision models (a smaller one for bulk work, a larger one for hard pages and abstracts) and a multilingual embedding model for Greek and English search. A single job queue and a model manager keep everything within the 32 GB of one RTX 5090 workstation, so a question never unloads a model a running job needs. There is no database: results are files and JSON on disk.
The models were chosen by benchmark. Several OCR models were rejected because they lost Greek accents or invented words, which is not acceptable for legal text. The code has 101 automated tests in 14 files, five of them for the cloud rule. Each build phase also ended with an acceptance run on the real models.
Limits:
- Windows with an NVIDIA graphics card only.
- Invoice accuracy has been measured on too few invoices to publish a figure.
- Real phone photos and real scanned laws in the test set are few; part of the scan testing uses generated pages.
- Pictures inside Word and PowerPoint files are skipped, so text in them is not read.
- Answers come from the smaller local model. It cites correctly, but can over-generalise from the passages it is given.
- The cloud path has never made a real request.
Stack
- Python
- FastAPI
- Plain JavaScript
- Docling
- OpenCV
- LM Studio
- llama.cpp