akshara-vision terminal document orchestration
akv --version 1.0.0
=================================================================================
                     _    _  __ ____  _   _    _    ____      _
                    / \  | |/ // ___|| | | |  / \  |  _ \    / \
                   / _ \ | ' / \___ \| |_| | / _ \ | |_) |  / _ \
                  / ___ \| . \  ___) |  _  |/ ___ \|  _ <  / ___ \
                 /_/   \_\_|\_\|____/|_| |_/_/   \_\_| \_\/_/   \_\
                                              V I S I O N
                              Restore. Read. Preserve.
=================================================================================

A local-first, vendor-agnostic document intelligence CLI & grounded chat workbench

01 / The Context The Problem Space
The Disconnection

Why raw model outputs fall short in document digitization.

Vision language models and LLMs are excellent at OCR correction and translation, but integrating them directly into bulk archival pipelines fails on practical execution.

Workflows are fragile. A network drop can ruin a multi-hour book extraction, dense scans trigger context truncation, and models ignore layout structural metadata entirely.

Ad-Hoc Model Calls Akshara Vision Engine
Fragile Pipelines API failures or terminal exits abort progress; no state preservation. Resumable Stages Continuous page checkpoints guarantee no data loss on interruption.
Raw Text Clutter Extracts plain strings without layout tags, figures, or roles. Structure Normalization Builds normalized layout trees mapping columns, headers, and figures.
Vendor Lock-in Hardcoded connections restrict migration between platforms. Model-Agnostic Routing Uniform routing across local GGUF offline engines or cloud APIs.
02 / Document Intelligence Layout Normalization
Semantic Structure Trees

Akshara Vision does not treat scans as plain text blocks.

Every page is parsed hierarchically, extracting reading orders, column estimates, local geometry, and semantic document roles.

Execution Modes & Tradeoffs
Quality Full pipeline: local layout parse + block-guided LLM restoration + vision crop verification. Best accuracy for damaged pages.
Balanced Saves time: local layout parse + direct block-guided text restoration. Skips costly iterative layout reviews.
Fast Max speed: bypasses block mapping, visual segment prompting, role classification, and crops. Fast pure text extraction.
Stage 1
Local Page Segmentation Detects page geometry (columns, coordinates) using local engine backends.
Stage 2
Reading Order Sort Orders blocks sequentially to prevent text column mixing.
Stage 3
Block-Guided LLM Restoration Reconstructs damaged text segment-by-segment using [BLOCK x] tags.
Stage 4
Extraction & Exporters Parses CSV tables, crops visual figures, and generates MD/DOCX/EPUB/PDF.
03 / Grounded Chat Conversational Review
Interactive Verification

Grounded Q&A over run manifests and raw layout files.

Ask questions directly over processed run directories. All answers are strictly grounded in indexed source text chunks, maintaining absolute audit trails.

  • Vision Mode Support Supports direct discussions over raw images (signboards, charts, tables) or page-specific queries inside PDFs without full corpus pre-indexing.
  • Dynamic Re-querying Re-opens and queries the source visual image directly if the indexed OCR text is incomplete or ambiguous.
  • Local Diagnostic Commands Index search using terminal shortcuts: `/sources` to list segments, `/find` to search keywords, and `/open` to view specific chunks offline.
akv chat --session S1
$ akv chat examples/sample.txt
[i] Running grounded chat over examples/sample.txt
[i] Type /exit or Ctrl+D to end.

akv chat › /find land grant
[i] Found 2 matches in sources:
  * Page 3 (Paragraph block 1)
  * Page 7 (Footnote block 4)

akv chat › What year was the land grant executed?
The land grant was executed in 1823 during the reign of Serfoji II (Page 3).
04 / Auditing Visual Layout Review
Human-In-The-Loop Validation

Auditing layout nodes, block confidence, and figure crops.

Run folders can be reviewed visually inside the terminal or compared side-by-side inside a browser to verify rendering and layout composition.

Terminal Preview

Visual Block-Map

Plots text columns and figure regions directly in a terminal-native layout preview screen before generating exports.

Browser Reports

Comparison Views

`akv compare` compiles a side-by-side visual report of raw pages and restored text to review image crops and layout flow.

Asset Control

Review Markdown

Saves a readable `layout_review.md` in the run directory. Delete incorrect figure crop assets locally to skip them automatically.

05 / Capabilities Feature Overview
Key Architectural Strengths

A production-ready framework for digital preservation.

Model Routing

Backend Agnostic

Routes queries transparently. Run offline local models (Ollama, LM Studio, Jan, llama.cpp) for privacy and zero cost, or scale out to cloud APIs (Gemini, OpenRouter, Anthropic).

Local GGUF Cloud APIs
Resumable Runs

Fault-Tolerant Stages

Writes page/chunk stage checkpoints. Interruptions (Ctrl+C, network crash) do not force re-processing. Simply run resume to recover completed pages and compile state.

Zero-Loss Staged Runs
Structure Engine

Document Intelligence

Caches `layout_tree`, `semantic_units`, and `layout_profile`. Detects footnotes, running headers, table of contents, contributors, and page boundaries for clean formatting.

Layout trees Page roles
Publication Delivery

Rich Exporters

Builds structured book packages. Outputs clean copy-paste text, formatted Markdown, HTML, DOCX, publication-ready EPUB files, and formatted PDF documents.

EPUB & DOCX Styled PDF
06 / Operations Architecture & Quality Standards
Extensible Integration Architecture

Engineered for durability, speed, and auditability.

Built with a modular backend routing layer, abstract layout interfaces, and extensible file exporters.

Ensures high runtime reliability and seamless integration with existing archival pipelines.

  • Automated Quality Assurance Maintains an extensive verification suite with 119 unit tests passing in under 3 seconds to guarantee parser, state machine, and exporter consistency.
  • Flexible PDF Composition Exports PDF files using two distinct layout engines: headlessly printing through `weasyprint` or headless Chromium when installed to guarantee publication-quality rendering.
  • Metadata Anonymity All metrics, profiles, and structural layout logs remain strictly in the local run manifest folder, keeping all files private and local-first.