Memory & RAG
~8 min readUpdated: November 2026

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

OCRia-nano-1 8.1M parameter CPU OCR and LayoutNet pipeline diagram showing script routing and LiteParse ONNX WebAssembly execution

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.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

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.

Key Architectural Takeaways
Quick Implementation Exampleocria-nano-rag-agent.ts
ocria-nano-rag-agent.tstypescript
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 reasoning
async 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);
Video Guides

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)

ModuleArtifact FileTechnical RoleParameters
Line Detectordet.onnxDepthwise-separable segmentation map of text lines0.08M
Script Routerrouter.onnxRoutes each line crop to 1 of 4 recognizers + detects upside-down text0.04M
Latin Recognizerrec_latin.onnxInt8 CTC recognizer covering 791 Latin/accented characters0.80M
World-Script Recognizerrec_world.onnxCTC recognizer covering ~17 additional scripts0.98M
RTL Recognizerrec_rtl.onnxCTC recognizer for Arabic and Hebrew right-to-left scripts0.71M
CJK Recognizerrec_cjk.onnxCTC recognizer for Chinese, Japanese, and Korean1.27M
LayoutNettablenet.bin / .onnx6-layer transformer + CNN branch for tables (colspan/rowspan) & 13 layout classes4.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 SystemParseBench-2OmniParseBencholmOCR-benchBHL CER ↓Throughput (pages/s)1-Core Latency (Mean / P90)
LiteParse + OCRia-nano-159.274.860.90.04827.8426 ms / 862 ms
Indra 1.1.255.170.960.80.06229.6440 ms / 871 ms
Marker 2.2.0 (fast)52.569.860.80.06724.7578 ms / 1,111 ms
LiteParse (Tesseract)48.742.345.70.27514.2751 ms / 2,420 ms
LiteParse + PP-OCRv6 small59.9———5.71,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.

bash
# 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 250

For edge workers and zero-backend web apps, initialize @llamaindex/liteparse-wasm directly:

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

  1. Strip Boilerplate Before Embedding: Enable default header/footer stripping (--keep-headers-footers off) so repeated legal footers and page numbers do not pollute vector similarity search.
  2. HTML Table Fallback for Complex Spans: LayoutNet automatically emits HTML <table> with colspan and rowspan whenever Markdown tables cannot capture merged financial headers.
  3. Selective GPU Escalation: Inspect --extract-blocks JSON output in Smoke Monkey Harness; if LayoutNet tags a block as figure or chart-dense, escalate only that cropped bounding box to a multimodal VLM while keeping 95% of text and tables on free CPU cores.
Google Search Questions & Answers

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

Related Architecture Guides

View all guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness