Surya is a document OCR and layout vision-language model with CLI and Python APIs. It runs layout detection, text recognition, reading order, and table HTML output for images and PDFs in many languages.
Overview
Surya is a 689M-parameter vision-language model focused on document intelligence: optical character recognition, page layout analysis, reading order, and table structure. A lightweight surya-ocr client orchestrates inference through backends such as vLLM in Docker or Podman, llama-server from llama.cpp on CPU or Apple Silicon, or mlxvlm.server on Apple Silicon, and can auto-start a compatible server on first use or attach to an existing OpenAI-compatible endpoint.
Layout analysis labels regions such as tables, pictures, section headers, equations, and forms, then orders them for reading. OCR returns block-level text as HTML, including KaTeX-compatible LaTeX for equations inline with prose. Table recognition outputs HTML tables with colspan and rowspan for merged cells. Commands accept images, PDFs, or folders, support page ranges, optional saved visuals, and JSON results with polygons, bounding boxes, labels, and confidence scores.
The suryagui command opens an interactive browser viewer to drop PDFs or images and inspect layout boxes, reading order, rendered math, HTML tables, and JSON across full-page OCR, block OCR, layout, and table modes. Settings can be overridden with environment variables; optional keep-server flags avoid reloading the model between consecutive CLI runs.
Throughput depends on the chosen backend and hardware; example GPU rates illustrate typical performance, and tuning concurrency, DPI, and MTP affects latency tradeoffs. Model weights ship under a modified license distinct from the Apache-licensed code, with broader commercial terms through Datalab pricing. Datalab also offers a managed API platform built on Surya and related models for hosted document conversion and extraction.
Key features
- Multilingual OCR across 90+ languages
- Layout analysis with reading order
- HTML table output with merged cells
- Equations as KaTeX-compatible LaTeX in HTML
- PDF and image batch processing
- vLLM, llama.cpp, or MLX inference backends
- Interactive browser viewer for results
- JSON output with boxes and confidence
Use cases
- OCR for scanned or born-digital PDFs
- Extracting structured tables from documents
- Layout-aware text for RAG pipelines
- Inspecting OCR and layout in a browser UI
- Shell pipelines via JSON on stdout