OCRia-nano-1: 8.1M-Parameter CPU OCR & LayoutNet Pipeline for Agentic RAG

OCRia-nano-1 is LlamaIndex's 8.1M-parameter CPU-first document parsing pipeline distilled from the 4B OCRia-1 VLM (1/500th the size). Combining a 3.9M multi-script ONNX OCR stack with a 4.27M LayoutNet table/layout transformer inside LiteParse, it parses 27.8 pages/second on 16 vCPUs and runs natively in Node.js, Python, and browser WebAssembly.
OCRia-nano-1: 8.1M-Parameter CPU OCR & LayoutNet Pipeline for Agentic RAG: OCRia-nano-1 is LlamaIndex's 8.1M-parameter CPU-first document parsing pipeline distilled from the 4B OCRia-1 VLM (1/500th the size). Combining a 3.9M multi-script ONNX OCR stack with a 4.27M LayoutNet table/layout transformer inside LiteParse, it parses 27.8 pages/second on 16 vCPUs and runs natively in Node.js, Python, and browser WebAssembly. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.
- 500x Distillation Without GPU Dependency: Packs a full detector, script router, 4 CTC recognizers, and LayoutNet into 8.1M parameters (60–75 MB download with ONNX Runtime).
- 27.8 Pages/s Throughput on 16 vCPUs: Runs 426 ms mean per page on a single CPU core—nearly 2x faster than LiteParse + Tesseract (751 ms) while lifting ParseBench-2 from 48.7 to 59.2.
- LayoutNet Joint Table & Structure Extraction: A 4.27M-parameter 6-layer transformer + CNN parses colspan/rowspan tables, headings, lists, and removes noisy page headers/footers.
- 4-Way Script Routing (20+ Scripts): Routes each detected line crop to Latin (791 chars, int8), CJK, RTL (Arabic/Hebrew), or World-script (~17 scripts) recognizers and fixes upside-down lines.
- Zero-Server WASM & CLI Execution: Runs via `lit` CLI, Python, Node.js, or `@llamaindex/liteparse-wasm` (`1.5 MB` Latin-only footprint) inside air-gapped Smoke Monkey Harness workspaces.
import { createAgent } from '@smoke-monkey/harness';import { LiteParse, models } from '@llamaindex/liteparse';// Pre-parse scanned PDFs locally on CPU with OCRia-nano-1 before agent reasoningasync function parseDocumentLocally(pdfPath: string) {models.pull('ocria-nano');const parser = new LiteParse({ocrBackend: 'ocria-nano',outputFormat: 'markdown',});return parser.parse(pdfPath);}const ragAgent = createAgent({agentId: 'ocria-document-analyst',provider: 'anthropic',model: 'claude-sonnet-4-5',workspacePath: process.cwd(),tools: ['filesystem', 'search', 'terminal'],permission: 'ask-default',});ragAgent.on('permission.required', (event) => {const allowed = ['read_file', 'write_file', 'grep', 'glob'];ragAgent.resolvePermission(event.data.toolCallId,allowed.includes(event.data.toolName) ? 'allow' : 'deny');});async function main() {const parsed = await parseDocumentLocally('./docs/q3-balance-sheet.pdf');const res = await ragAgent.run(`Extract structured Markdown tables and flag anomalies from this OCRia-nano-1 output:\n\n${parsed.text.slice(0, 12000)}`);console.log('Analysis complete:', res.status);}main().catch(console.error);
Watch: Related Video Guides
Building the Document Context Layer for AI Agents — Jerry Liu, LlamaIndex
How to Build Your Own (DIY) Document Parsing Agent from Scratch
What Is OCRia-nano-1? Modular 8.1M-Parameter CPU OCR Architecture
OCRia-nano-1 is LlamaIndex's 8.1M-parameter CPU document-parsing pipeline inside LiteParse, distilled 500x from the 4B-parameter OCRia-1 vision-language model. By pairing a 3.9M-parameter multi-script ONNX OCR stack with LayoutNet—a 4.27M-parameter joint table and layout transformer—it turns scanned PDFs into structured Markdown and bounding-box JSON without GPUs.
Instead of passing full-page images through a heavy autoregressive VLM, LiteParse renders pages at 250 DPI, executes seven specialized ONNX/binary modules (60–75 MB total with ONNX Runtime, verified by pinned SHA-256), and merges native PDF text layers with OCR output before reconstructing tables and reading order.
Seven-Model Component Breakdown (8.1M Total Parameters)
| Module | Artifact File | Technical Role | Parameters |
|---|---|---|---|
| Line Detector | det.onnx | Depthwise-separable segmentation map of text lines | 0.08M |
| Script Router | router.onnx | Routes each line crop to 1 of 4 recognizers + detects upside-down text | 0.04M |
| Latin Recognizer | rec_latin.onnx | Int8 CTC recognizer covering 791 Latin/accented characters | 0.80M |
| World-Script Recognizer | rec_world.onnx | CTC recognizer covering ~17 additional scripts | 0.98M |
| RTL Recognizer | rec_rtl.onnx | CTC recognizer for Arabic and Hebrew right-to-left scripts | 0.71M |
| CJK Recognizer | rec_cjk.onnx | CTC recognizer for Chinese, Japanese, and Korean | 1.27M |
| LayoutNet | tablenet.bin / .onnx | 6-layer transformer + CNN branch for tables (colspan/rowspan) & 13 layout classes | 4.27M |
ParseBench-2 Accuracy & Single-Core vs. 16-vCPU Throughput
Evaluated across 300 random ParseBench pages on a 16-vCPU host (one worker per core), LiteParse + OCRia-nano-1 scores 59.2 on ParseBench-2 (+10.5 points over Tesseract) and 74.8 on OmniParseBench while sustaining 27.8 pages/second (426 ms mean / 862 ms P90 on 1 core).
CPU Document Parser Comparison (16 vCPUs, 1 Worker/Core)
| CPU System | ParseBench-2 | OmniParseBench | olmOCR-bench | BHL CER ↓ | Throughput (pages/s) | 1-Core Latency (Mean / P90) |
|---|---|---|---|---|---|---|
| LiteParse + OCRia-nano-1 | 59.2 | 74.8 | 60.9 | 0.048 | 27.8 | 426 ms / 862 ms |
| Indra 1.1.2 | 55.1 | 70.9 | 60.8 | 0.062 | 29.6 | 440 ms / 871 ms |
| Marker 2.2.0 (fast) | 52.5 | 69.8 | 60.8 | 0.067 | 24.7 | 578 ms / 1,111 ms |
| LiteParse (Tesseract) | 48.7 | 42.3 | 45.7 | 0.275 | 14.2 | 751 ms / 2,420 ms |
| LiteParse + PP-OCRv6 small | 59.9 | — | — | — | 5.7 | 1,963 ms / 4,988 ms |
Look closely at the ParseBench-2 breakdown: OCRia-nano-1 jumps Tables from 36.2 (Tesseract) and 47.6 (Indra) to 59.5, and Layout from 49.4 to 72.4. Note that dense Charts remain a GPU VLM domain (3.1 vs 77.4 for the 4B OCRia-1 teacher in LlamaParse), so route chart-heavy pages selectively.
Running OCRia-nano-1 in CLI, Python, Node.js & Browser WebAssembly
LiteParse executes OCRia-nano-1 natively via ONNX Runtime on Linux, macOS, and Windows, and compiles to browser/edge WebAssembly using Sonos's tract engine. Trimming the bundle to { scripts: ['latin'], layout: false } shrinks the WASM model download to 1.5 MB.
# CLI installation & one-time SHA-256 verified model pull (60-75 MB)
npm i -g @llamaindex/liteparse # or: pip install liteparse | cargo install liteparse
lit models pull ocria-nano
# Convert scanned PDF to Markdown with LayoutNet tables & stripped headers/footers
lit parse ./contracts/vendor-msa.pdf --format markdown
# Extract JSON layout blocks + bounding boxes for RAG chunking
lit parse ./contracts/vendor-msa.pdf --format json --extract-blocks --dpi 250For edge workers and zero-backend web apps, initialize @llamaindex/liteparse-wasm directly:
import init, { LiteParse, OcriaNano } from '@llamaindex/liteparse-wasm';
await init();
const ocria = await OcriaNano.fromUrl({ scripts: ['latin'], layout: true });
const parser = LiteParse.withOcriaNano({ ocrEnabled: true, outputFormat: 'markdown' }, ocria);
const doc = await parser.parse(pdfUint8Array);OCRia-nano-1 Commercial License Threshold
While LiteParse (Apache 2.0) and ONNX Runtime (MIT) are permissive, OCRia-nano-1 weights use the RAIL-M-based OCRia-nano-1 Model License: free for research, personal use, and organizations under $2M annual revenue and $2M total funding, but requiring a commercial license above those limits or in competing OCR products.
Hybrid CPU-First Agentic RAG Pipelines in Smoke Monkey Harness
In Smoke Monkey Harness, OCRia-nano-1 eliminates GPU cold starts and external OCR SaaS egress during agentic document ingestion. By converting PDFs to clean Markdown locally at 426 ms/page before tokens ever hit your reasoning LLM, you preserve privacy and avoid vision-token billing overhead.
- Strip Boilerplate Before Embedding: Enable default header/footer stripping (
--keep-headers-footersoff) so repeated legal footers and page numbers do not pollute vector similarity search. - HTML Table Fallback for Complex Spans: LayoutNet automatically emits HTML
<table>withcolspanandrowspanwhenever Markdown tables cannot capture merged financial headers. - Selective GPU Escalation: Inspect
--extract-blocksJSON output in Smoke Monkey Harness; if LayoutNet tags a block asfigureor chart-dense, escalate only that cropped bounding box to a multimodal VLM while keeping 95% of text and tables on free CPU cores.
Frequently Asked Questions
Q:How large is OCRia-nano-1 and can it run without a GPU?
OCRia-nano-1 totals 8.1M parameters across seven ONNX/binary models (3.9M OCR stack + 4.27M LayoutNet), downloading as 60-75 MB including ONNX Runtime. It runs completely on CPU at 27.8 pages/s on 16 vCPUs (426 ms/page on 1 core).
Q:Can OCRia-nano-1 run inside a web browser or Cloudflare Worker?
Yes. Through @llamaindex/liteparse-wasm and the tract inference runtime, OCRia-nano-1 executes client-side in WebAssembly (~1-4 s per scanned page on a laptop) and can trim downloads to 1.5 MB for Latin-only text.
Q:How does OCRia-nano-1 handle non-Latin documents?
The 0.04M-parameter router.onnx inspects every detected line crop and dispatches it to specialized CTC recognizers for Latin (791 chars), CJK (Chinese/Japanese/Korean), RTL (Arabic/Hebrew), or World (~17 scripts), while flagging upside-down text.
Q:Where does OCRia-nano-1 fall short compared to 4B VLMs like OCRia-1?
While OCRia-nano-1 scores 59.5 on ParseBench-2 Tables and 72.4 on Layout, it scores 3.1 on Charts compared to 77.4 for the 4B OCRia-1 teacher. Use LayoutNet block classifications to escalate chart figures to a VLM when needed.
Q:Is OCRia-nano-1 free for commercial SaaS products?
It is free for research, personal use, and companies under $2M annual revenue and $2M total funding, excluding competing OCR/document-parsing services. Larger enterprises must license it from LlamaIndex.
Related Alternatives & Comparisons
LlamaIndex Agent Alternative: Lightweight Code Engineering & Tool Sandbox
LangChain TypeScript Alternative: Zero Dependencies & Deterministic Loops
9 Best Free Open Source ChatGPT Alternatives in 2026 (Self-Hosted & Local)
Related Architecture Guides
View all guidesBest Open Source Coding Agents in 2026: Free, Local & Fully Hackable Harnesses
MCP Server Security Best Practices: Hardening Model Context Protocol Agents in 2026
Open Source Coding Agent Harness: Build a Forkable, Local AI Engineering Runtime
Build with Smoke Monkey Harness
Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.