LAICAT (Local AI CAT) is an open-source, AI-powered Computer-Assisted Translation (CAT) assistant designed to help technical translators work efficiently with complex documents, scans, and PDFs.
It combines CPU-efficient Document Layout Analysis (DLA), automatic CV page deskewing, and interactive visual frame overlays with local/hosted LLM translation (via Ollama).
- Two-Stage OCR & Translation Pipeline: Combines vision-based OCR (
minicpm-v4.5:q4_K_M) for text extraction from cropped document regions with LLM contextual translation (translategemma:27b-it-q4_K_M). Features explicit language dropdown guards and automatic language pairing. - Document Layout Analysis (DLA): Automatically segments document pages (PDFs or image scans) into clickable structural blocks (paragraphs, tables, callouts, columns, captions) using
PyMuPDFtext block parsing and OpenCV morphological segmentation. - Automatic Page Deskewing: Built-in computer vision pipeline that automatically detects and straightens slightly rotated page scans prior to layout analysis.
- Interactive Visual Overlay:
- Red Outline: Original document frame (pending processing).
- Orange Outline: OCR complete (editable original text in popover).
- Green / Blue Outline: Clean, editable, copyable translated text snippet.
- Interactive popover editor for both original source snippet text and translated text.
- Human Translator Hints & Domain Context Injection (
💡): Allows human translators (app operators) to enter domain-specific instructions, acronym expansions, or glossary rules (e.g., medical or legal terminology notes). Hints are persisted indoc.jsonand passed directly totranslategemmainside structured JSON prompt context blocks. Features an illuminated amber active badge on the navbar💡button when hints are active. - Document Statistics & Character Estimations: Interactive popup modal (
📄stats button) calculating total source OCR character counts, target translated character counts, enabled frame statistics, and estimated standard pages (CHARS_PER_PAGE = 1800). - Dual Progress Bars & Priority Queue: Built-in async priority request queue that handles OCR tasks (high priority) and Translation tasks (normal priority) with real-time status reporting and centered sub-bar progress visualizers.
- In-App User Guide: Access complete user documentation served directly from the backend at
/docs/userdoc.html. - CPU-First & Multi-Platform: Runs fast on unprivileged CPU-only hardware (Linux Ubuntu i5 CPU boxes) and macOS (Apple Silicon M-series) without requiring dedicated CUDA GPUs.
- Background Systemd Integration: Out-of-the-box systemd user service deployment for Linux environments with autostart on user login and zero
sudorequirement.
┌──────────────────────────────────────────────────────────────┐
│ Web Browser (Frontend) │
│ - Interactive PDF / Scan Page Renderer │
│ - Clickable CSS Overlay Frames & Popover Text Editors │
│ - Source / Target Language Selectors (PL ↔ CS) │
│ - Dual Progress Tracking (OCR & Translation Stages) │
└──────────────────────────────┬───────────────────────────────┘
│ REST API
┌──────────────────────────────▼───────────────────────────────┐
│ FastAPI Backend (Python) │
│ │
│ ┌────────────────────────┐ ┌──────────────────────────┐ │
│ │ Document Ingestion │ │ Layout & OpenCV Deskew │ │
│ │ - PDF to PNG pages │───>│ - Automatic Page Tilt │ │
│ └────────────────────────┘ │ Correction & DLA │ │
│ └────────────┬─────────────┘ │
│ │ │
│ ┌──────────────────────────────────────────▼─────────────┐ │
│ │ Local Filesystem Persistence (`.data/<doc_id>/`) │ │
│ │ - doc.json (Metadata & persisted languages) │ │
│ │ - page_XXX.png (Rendered high-DPI page images) │ │
│ │ - page_XXX.json (Bounding boxes, OCR text & cache) │ │
│ └──────────────────────────┬─────────────────────────────┘ │
│ │ │
│ ┌──────────────────────────▼─────────────────────────────┐ │
│ │ In-Memory PriorityQueue (concurrency=1) │ │
│ │ Priority 1: OCR Tasks | Priority 2: Translate Tasks │ │
│ └──────────────────────────┬─────────────────────────────┘ │
└─────────────────────────────┼────────────────────────────────┘
│ HTTP API (Streaming Ollama Requests)
┌─────────────────────────────▼────────────────────────────────┐
│ Ollama Server (OLLAMA_HOST:11434) │
│ - OCR Model: minicpm-v4.5:q4_K_M (Vision Image -> Text) │
│ - Translation Model: translategemma:27b-it-q4_K_M (Text) │
└──────────────────────────────────────────────────────────────┘
- Automatic Page Deskewing Algorithm: Detailed breakdown of the OpenCV morphological line-merging and affine rotation transform pipeline used to straighten scanned pages.
- MVP Architecture Specifications: Storage design, filesystem structure, priority queue specs, and two-stage OCR pipeline architecture.
- Python 3.11+
- uv (Fast Python package manager, required for runner & dependency sync):
- Standalone script:
curl -LsSf https://astral.sh/uv/install.sh | sh - Homebrew (macOS/Linux):
brew install uv - PyPI:
pip install uv
- Standalone script:
- Ollama running locally or accessible over your network with pulled models:
- OCR Model:
ollama pull minicpm-v4.5:q4_K_M - Translation Model:
ollama pull translategemma:27b-it-q4_K_M
- OCR Model:
Create your local untracked configuration file from the template:
make configThis generates app/config.py. Open app/config.py to customize parameters such as OLLAMA_HOST, LAICAT_PORT (default 8528), DEFAULT_OCR_MODEL, DEFAULT_TRANSLATION_MODEL, or layout merge parameters.
make installStart the development server with live reload:
make devOpen your web browser at http://localhost:8528 (or your configured LAICAT_PORT).
Install and run LAICAT as a background user service on Linux (autostarts upon user login, zero sudo required):
make systemd-installAfter installation, the terminal will display status details and the bookmark URL:
📌 Open and bookmark the app at: http://localhost:8528
- Check Status:
make systemd-status(orsystemctl --user status laicat.service) - View Logs:
make systemd-logs(orjournalctl --user -u laicat.service -f) - Uninstall Service:
make systemd-uninstall
(Optional: Run loginctl enable-linger $USER if you wish the service to start automatically at system boot prior to graphical desktop login.)
Execute the automated test suite:
make test