chandra

datalab-toApache-2.0活跃维护

能识别复杂表格、表单和手写内容的 OCR 模型,保留完整版面布局,适合把扫描件和图片转成结构化文本喂给 RAG 或文档解析流程。

OCR model that handles complex tables, forms, handwriting with full layout.

v0.2.0发布于 2026-03-18 15:16 UTC12,698star +3 / 7 天1,271fork同步于 2026-11-10 17:28 UTC

怎么上手

由 README 提炼,执行前请确认
pip install chandra-ocr
chandra_vllm
chandra input.pdf ./output
硬件要求按 README 说明

README 未说明具体显存要求;vLLM 后端需 GPU(通过 VLLM_GPUS 指定设备),HuggingFace 后端需安装 torch,建议加装 flash attention 提升性能。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

把图片和 PDF 转成带版面结构的 HTML/Markdown/JSON 的 OCR 模型,擅长表格、表单和手写

能识别复杂表格、表单和手写内容的 OCR 模型,保留完整版面布局,适合把扫描件和图片转成结构化文本喂给 RAG 或文档解析流程。

核心能力

  • 输出 Markdown、HTML、JSON 三种格式并保留版面信息
  • 支持 90 多种语言,手写与复杂表格表现突出
  • 能重建表单并识别复选框,提取图片并生成说明
  • 提供 HuggingFace 本地与 vLLM 远程两种推理方式
  • CLI 支持整目录批处理与 PDF 页码范围选择

容易踩的坑

默认推理方式是 vllm,需先启动 vLLM 服务(默认 http://localhost:8000/v1),否则要显式加 --method hf;HuggingFace 后端需额外安装 chandra-ocr[hf];模型权重为修改版 OpenRAIL-M,商业自托管需授权。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.2.0
  1. v0.2.0Chandra OCR 2最新正式版2026-03-18 · 2026-03-18 15:16 UTC

    Announcing Chandra OCR 2 - a 4B parameter OCR model that scores 85.9% on the olmOCR benchmark (state of the art) and 77.8% on our internal 43-language multilingual benchmark. It is smaller and more accurate than Chandra 1 (9B) across every category.

    Highlights

    • 4B parameters (down from 9B), 2x throughput improvement
    • 85.9% olmOCR overall (up from 83.1%)
    • 77.8% multilingual average across 43 languages (up from 69.4%), 72.7% across 90 languages
    • 2 pages/sec on H100 with 96 concurrent requests
    • 15+ layout block types with bounding boxes
    • Structured output for diagrams (Mermaid), charts, and images

    olmOCR Benchmark

    CategoryChandra 1Chandra 2Change
    ArXiv82.2%90.2%+8.0
    Old Scans Math80.3%89.3%+9.0
    Tables88.0%89.9%+1.9
    Multi column81.2%83.5%+2.3
    Overall83.1%85.9%+2.8

    Multilingual

    43-language averages: Chandra 2 77.8%, Chandra 1 69.4%, Gemini 2.5 Flash 67.6%, GPT-5 Mini 60.5%.

    90-language averages: Chandra 2 72.7%, Gemini 2.5 Flash 60.8%.

    Largest improvements in South Asian scripts (Bengali +27.2, Kannada +42.6, Malayalam +46.2, Tamil +26.9, Telugu +39.1). Full 90-language results in FULL_BENCHMARKS.md.

    New Capabilities

    • Layout blocks: text, section-header, caption, footnote, table, form, list-group, image, figure, diagram, equation-block, code-block, chemical-block, bibliography, table-of-contents, page-header, page-footer, complex-block
    • Mermaid diagrams: Flowcharts and process diagrams converted to Mermaid format
    • Chart extraction: Structured data (values, categories, axis labels) from bar/line/pie charts
    • Image captioning: Captions generated from visual content and surrounding context
    • Chemistry detection: Molecular structure descriptions from chemical diagrams

    Install

    pip install chandra-ocr
    
    # With vLLM (recommended)
    chandra_vllm
    chandra input.pdf ./output
    
    # With HuggingFace
    pip install chandra-ocr[hf]
    chandra input.pdf ./output --method hf
    

    Links

  2. v0.1.7Render pdf images properly2025-10-22 · 2025-10-22 13:22 UTC

    这个版本没有写更新说明。

  3. v0.1.6Additional fixes2025-10-21 · 2025-10-21 15:54 UTC

    这个版本没有写更新说明。

  4. v0.1.4VLLM fixes2025-10-21 · 2025-10-21 15:53 UTC

    这个版本没有写更新说明。

  5. v0.1.3Fix attention setting2025-10-21 · 2025-10-21 15:16 UTC

    这个版本没有写更新说明。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Chandra OCR 2

    Chandra OCR 2 is a state of the art OCR model that converts images and PDFs into structured HTML/Markdown/JSON while preserving layout information.

    Try Chandra on Datalab

    Our managed platform uses an improved Chandra and other models, with higher accuracy than the open weights, opt-in zero data retention, SOC 2 Type 2, and custom BAAs.

    If you have high volume workloads, we offer a batch processing service that has processed 1B+ pages in a day at peak — we manage the infrastructure so your workloads finish on time.

    The Datalab API turns documents into verifiable knowledge your agents act on. Every result traces back to its page and position, and one API can parse, extract, fill and edit documents.

    Get started with about 5,000 free convert pages every month (work email) — sign up — takes under 30 seconds — or try Chandra in our public playground.

    Commercial self-hosting requires a license — see Commercial usage. For on-prem licensing, contact us.

    News

    • 3/2026 - Chandra 2 is here with significant improvements to math, tables, layout, and multilingual OCR
    • 10/2025 - Chandra 1 launched

    Features

    • Tops external olmocr benchmark and significant improvement in internal multilingual benchmarks
    • Convert documents to markdown, html, or json with detailed layout information
    • Support for 90+ languages (benchmark below)
    • Excellent handwriting support
    • Reconstructs forms accurately, including checkboxes
    • Strong performance with tables, math, and complex layouts
    • Extracts images and diagrams, and adds captions and structured data
    • Two inference modes: local (HuggingFace) and remote (vLLM server)

    Quickstart

    The easiest way to start is with the CLI tools:

    pip install chandra-ocr
    
    # With vLLM (recommended, lightweight install)
    chandra_vllm
    chandra input.pdf ./output
    
    # With HuggingFace (requires torch)
    pip install chandra-ocr[hf]
    chandra input.pdf ./output --method hf
    
    # Interactive streamlit app
    pip install chandra-ocr[app]
    chandra_app
    

    Benchmarks

    Multilingual performance was a focus for us with Chandra 2. There isn't a good public multilingual OCR benchmark, so we made our own. This tests tables, math, ordering, layout, and text accuracy.

    See full scores below. We also have a full 90-language benchmark.

    We also benchmarked Chandra 2 with the widely accepted olmocr benchmark:

    See full scores below.

    Examples

    TypeNameLink
    MathCS229 TextbookView
    MathHandwritten MathView
    MathChinese MathView
    TablesStatistical DistributionView
    TablesFinancial TableView
    FormsRegistration FormView
    FormsLease FormView
    HandwritingCursive WritingView
    HandwritingHandwritten NotesView
    LanguagesArabicView
    LanguagesJapaneseView
    LanguagesHindiView
    LanguagesRussianView
    OtherChartsView
    OtherChemistryView

    Installation

    Package

    # Base install (for vLLM backend)
    pip install chandra-ocr
    
    # With HuggingFace backend (includes torch, transformers)
    pip install chandra-ocr[hf]
    
    # With all extras
    pip install chandra-ocr[all]
    

    If you're using the HuggingFace method, we also recommend installing flash attention for better performance.

    From Source

    git clone https://github.com/datalab-to/chandra.git
    cd chandra
    uv sync
    source .venv/bin/activate
    

    Usage

    CLI

    Process single files or entire directories:

    # Single file, with vllm server (see below for how to launch vllm)
    chandra input.pdf ./output --method vllm
    
    # Process all files in a directory with local model
    chandra ./documents ./output --method hf
    

    CLI Options:

    • --method [hf|vllm]: Inference method (default: vllm)
    • --page-range TEXT: Page range for PDFs (e.g., "1-5,7,9-12")
    • --max-output-tokens INTEGER: Max tokens per page
    • --max-workers INTEGER: Parallel workers for vLLM
    • --include-images/--no-images: Extract and save images (default: include)
    • --include-headers-footers/--no-headers-footers: Include page headers/footers (default: exclude)
    • --batch-size INTEGER: Pages per batch (default: 28 for vllm, 1 for hf)

    Output Structure:

    Each processed file creates a subdirectory with:

    • <filename>.md - Markdown output
    • <filename>.html - HTML output
    • <filename>_metadata.json - Metadata (page info, token count, etc.)
    • Extracted images are saved directly in the output directory

    Streamlit Web App

    Launch the interactive demo for single-page processing:

    chandra_app
    

    vLLM Server (Optional)

    For production deployments or batch processing, use the vLLM server:

    chandra_vllm
    

    This launches a Docker container with optimized inference settings. Configure via environment variables:

    • VLLM_API_BASE: Server URL (default: http://localhost:8000/v1)
    • VLLM_MODEL_NAME: Model name for the server (default: chandra)
    • VLLM_GPUS: GPU device IDs (default: 0)

    You can also start your own vllm server with the datalab-to/chandra-ocr-2 model.

    Configuration

    Settings can be configured via environment variables or a local.env file:

    # Model settings
    MODEL_CHECKPOINT=datalab-to/chandra-ocr-2
    MAX_OUTPUT_TOKENS=12384
    
    # vLLM settings
    VLLM_API_BASE=http://localhost:8000/v1
    VLLM_MODEL_NAME=chandra
    VLLM_GPUS=0
    

    Commercial usage

    This code is Apache 2.0, and our model weights use a modified OpenRAIL-M license (free for research, personal use, and startups under $2M funding/revenue, cannot be used competitively with our API). To remove the OpenRAIL license requirements, or for broader commercial licensing, visit our pricing page here.

    Benchmark table

    ModelArXivOld Scans MathTablesOld ScansHeaders and FootersMulti columnLong tiny textBaseOverallSource
    Datalab API90.490.290.754.691.683.792.399.986.7 ± 0.8Own benchmarks
    Chandra 286.989.192.151.191.482.193.799.985.8 ± 0.8Own benchmarks
    dots.ocr 1.585.985.590.748.294.085.381.699.783.9dots.ocr repo
    Chandra 182.280.388.050.490.881.292.399.983.1 ± 0.9Own benchmarks
    olmOCR 283.082.384.947.796.183.781.999.682.4olmocr repo
    dots.ocr82.164.288.340.994.182.481.299.579.1 ± 1.0dots.ocr repo
    olmOCR v0.3.078.679.972.943.995.177.381.298.978.5 ± 1.1olmocr repo
    Datalab Marker v1.10.083.869.774.832.386.679.485.799.676.5 ± 1.0Own benchmarks
    Deepseek OCR75.272.379.733.396.166.780.199.775.4 ± 1.0Own benchmarks
    Mistral OCR API77.267.560.629.393.671.377.199.472.0 ± 1.1olmocr repo
    GPT-4o (Anchored)53.574.570.040.793.869.360.696.869.9 ± 1.1olmocr repo
    Qwen 3 VL 8B70.275.145.637.589.162.143.094.364.6 ± 1.1Own benchmarks
    Gemini Flash 2 (Anchored)54.556.172.134.264.761.571.595.663.8 ± 1.2olmocr repo

    Multilingual benchmark table

    The table below covers the 43 most common languages, benchmarked across multiple models. For a comprehensive evaluation across 90 languages (Chandra 2 vs Gemini 2.5 Flash only), see the full 90-language benchmark.

    LanguageDatalab APIChandra 2Chandra 1Gemini 2.5 FlashGPT-5 Mini
    ar67.6%68.4%34.0%84.4%55.6%
    bn85.1%72.8%45.6%55.3%23.3%
    ca88.7%85.1%84.2%88.0%78.5%
    cs88.2%85.3%84.7%79.1%78.8%
    da90.1%91.1%88.4%86.0%87.7%
    de93.8%94.8%83.0%88.3%93.8%
    el89.9%85.6%85.5%83.5%82.4%
    es91.8%89.3%88.7%86.8%97.1%
    fa82.2%75.1%69.6%61.8%56.4%
    fi85.7%83.4%78.4%86.0%84.7%
    fr93.3%93.7%89.6%86.1%91.1%
    gu73.8%70.8%44.6%47.6%11.5%
    he76.4%70.4%38.9%50.9%22.3%
    hi80.5%78.4%70.2%82.7%41.0%
    hr93.4%90.1%85.9%88.2%81.3%
    hu88.1%82.1%82.5%84.5%84.8%
    id91.3%91.6%86.7%88.3%89.7%
    it94.4%94.1%89.1%85.7%91.6%
    ja87.3%86.9%85.4%80.0%76.1%
    jv87.5%73.2%85.1%80.4%69.6%
    kn70.0%63.2%20.6%24.5%10.1%
    ko89.1%81.5%82.3%84.8%78.4%
    la78.0%73.8%55.9%70.5%54.6%
    ml72.4%64.3%18.1%23.8%11.9%
    mr80.8%75.0%57.0%69.7%20.9%
    nl90.0%88.6%85.3%87.5%83.8%
    no89.2%90.3%85.5%87.8%87.4%
    pl93.8%91.5%83.9%89.7%90.4%
    pt97.0%95.2%84.3%89.4%90.8%
    ro86.2%84.5%82.1%76.1%77.3%
    ru88.8%85.5%88.7%82.8%72.2%
    sa57.5%51.1%33.6%44.6%12.5%
    sr95.3%90.3%82.3%89.7%83.0%
    sv91.9%92.8%82.1%91.1%92.1%
    ta82.9%77.7%50.8%53.9%8.1%
    te69.4%58.6%19.5%33.3%9.9%
    th71.6%62.6%47.0%66.7%53.8%
    tr88.9%84.1%68.1%84.1%78.2%
    uk93.1%91.0%88.5%87.9%81.9%
    ur54.1%43.2%28.1%57.6%16.9%
    vi85.0%80.4%81.6%89.5%83.6%
    zh87.8%88.7%88.3%70.0%70.4%
    Average80.4%77.8%69.4%67.6%60.5%

    Full 90-language benchmark table

    We also have a more comprehensive evaluation covering 90 languages, comparing Chandra 2 against Gemini 2.5 Flash. The average scores are lower than the 43-language table above because this includes many lower-resource languages. Chandra 2 averages 72.7% vs Gemini 2.5 Flash at 60.8%.

    See the full 90-language results.

    Throughput

    Benchmarked with vLLM on a single NVIDIA H100 80GB GPU using a diverse mix of documents (math, tables, scans, multi-column layouts) from the olmOCR benchmark set. This set is significantly slower than real-world usage - we estimate 2 pages/s in real-world usage.

    ConfigurationPages/secAvg LatencyP95 LatencyFailure Rate
    vLLM, 96 concurrent sequences1.4460s156s0%

    Credits

    Thank you to the following open source projects: