8000 GitHub - michals/laicat: LAICAT (Local AI CAT) is an open-source, AI-powered Computer-Assisted Translation (CAT) assistant designed for technical document translation. · GitHub
[go: up one dir, main page]

Skip to content
michalsPublic

About

LAICAT (Local AI CAT) is an open-source, AI-powered Computer-Assisted Translation (CAT) assistant designed for technical document translation.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

23 Commits

Folders and files

Repository files navigation

LAICAT (Local AI CAT) 🌐🤖

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).

LAICAT Interactive Document Translation Interface


🌟 Key Features

  • 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 PyMuPDF text 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 in doc.json and passed directly to translategemma inside 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 sudo requirement.

📐 Architecture Overview

┌──────────────────────────────────────────────────────────────┐
│                    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)    │
└──────────────────────────────────────────────────────────────┘

📄 Technical Deep-Dives & Engineering Notes


⚙️ Prerequisites & Setup

1. System Requirements

  • 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
  • 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

2. Configuration

Create your local untracked configuration file from the template:

make config

This 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.

3. Install Dependencies

make install

🚀 Running LAICAT

Development Server

Start the development server with live reload:

make dev

Open your web browser at http://localhost:8528 (or your configured LAICAT_PORT).


🐧 Linux Systemd User Service Installation

Install and run LAICAT as a background user service on Linux (autostarts upon user login, zero sudo required):

make systemd-install

After installation, the terminal will display status details and the bookmark URL: 📌 Open and bookmark the app at: http://localhost:8528

Service Commands

  • Check Status: make systemd-status (or systemctl --user status laicat.service)
  • View Logs: make systemd-logs (or journalctl --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.)


🧪 Testing

Execute the automated test suite:

make test

About

LAICAT (Local AI CAT) is an open-source, AI-powered Computer-Assisted Translation (CAT) assistant designed for technical document translation.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0