document-ocr
Convert scanned PDFs and document images into clean Markdown using docling for layout (figures, tables, reading order) plus a vision-language OCR model. Use when a user needs high-quality OCR of scanned documents, historical literature, or photographed pages — preserving multi-column reading order, diacritics, special characters, and figures. Supports local vLLM/Ollama servers and cloud vision APIs (OpenAI, Anthropic). Assumes an OCR backend already exists.
Best use case
document-ocr is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Convert scanned PDFs and document images into clean Markdown using docling for layout (figures, tables, reading order) plus a vision-language OCR model. Use when a user needs high-quality OCR of scanned documents, historical literature, or photographed pages — preserving multi-column reading order, diacritics, special characters, and figures. Supports local vLLM/Ollama servers and cloud vision APIs (OpenAI, Anthropic). Assumes an OCR backend already exists.
Teams using document-ocr should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/document_ocr/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How document-ocr Compares
| Feature / Agent | document-ocr | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Convert scanned PDFs and document images into clean Markdown using docling for layout (figures, tables, reading order) plus a vision-language OCR model. Use when a user needs high-quality OCR of scanned documents, historical literature, or photographed pages — preserving multi-column reading order, diacritics, special characters, and figures. Supports local vLLM/Ollama servers and cloud vision APIs (OpenAI, Anthropic). Assumes an OCR backend already exists.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Document OCR (docling + vision-language model)
## Purpose
Turn scanned PDFs and document images into clean, structured **Markdown** with
figures preserved. The pipeline combines:
1. **docling** — detects layout (figures, tables, multi-column reading order) on
each page, entirely on CPU.
2. **A vision-language model (VLM)** — transcribes each full page to Markdown,
preserving reading order, diacritics, ligatures, special characters (♂ ♀ ½ æ,
Greek/Latin), equations (LaTeX), and tables (HTML).
docling supplies reliable figure/table crops; the VLM supplies high-quality
text. Born-digital PDFs are detected and extracted directly (no server needed).
Adapted from Bruno de Medeiros' OntoMorphoGrapher proof-of-concept, where the
`olmocr-docling` backend processed an 18-PDF historical-entomology corpus
(1833–2015, 5 languages) with no catastrophic failures.
## When to use this skill
Use when:
- A user has **scanned PDFs or photographed/image pages** needing accurate OCR.
- Figures and multi-column reading order must be preserved.
- The text has diacritics, special characters, or non-English content.
Do **not** use when:
- The PDF is already born-digital and reads fine (this tool handles it via the
fast path, but you may not need it at all).
- The goal is extracting *structured fields* into a database — that is the
`extract-from-pdfs` skill, which can run **downstream** of this one.
## ⚠️ Prerequisites — an OCR backend must already exist
**This skill does not start or manage any server. Standing one up is out of
scope.** Before running, the user must have **one** of:
- a running **OpenAI-compatible server** (vLLM/SGLang/LM Studio/llama.cpp) with a
vision model — best with olmOCR-2 (`--backend olmocr-docling`);
- a running **Ollama** server with a vision OCR model (`--backend ollama`);
- a **cloud API key** — Anthropic (`--backend anthropic-docling`) or OpenAI
(`--backend vlm-docling` pointed at the OpenAI base URL).
Always **remind the user of this requirement** and confirm which backend they
have. For example setup commands (illustrative, not maintained), see
`references/server_setup.md`. The born-digital PDF fast path needs no backend.
## Setup
```bash
conda env create -f environment.yml
conda activate document_ocr
```
Then make the backend reachable (pick one):
```bash
export OCR_HOST=http://YOUR_HOST:30001 # vLLM / Ollama / OpenAI-compatible
# or
export ANTHROPIC_API_KEY=sk-ant-... # cloud Claude
# or
export OPENAI_API_KEY=sk-... # cloud OpenAI
```
## Choosing a backend
| `--backend` | What it uses | Needs |
|--------------------|-------------------------------------------|-------|
| `olmocr-docling` ★ | docling figures + olmOCR-2 (vLLM) | `--host` |
| `vlm-docling` | docling figures + any VLM (OpenAI-compat) | `--host` (+ `--api-key` for cloud) |
| `anthropic-docling`| docling figures + Claude (cloud) | `--api-key` / `ANTHROPIC_API_KEY` |
| `ollama` | full-page DeepSeek-OCR (Ollama) | `--host` |
| `docling` | docling layout + per-region OCR | `--host` |
★ Recommended. See `references/backends.md` for the full matrix, why full-page
beats per-region OCR, model defaults, and tuning notes.
## Workflow
1. **Confirm the backend** (see Prerequisites). Ask the user which one they have
and the host/model or API key. Do not assume a server is running.
2. **Gather inputs**: a PDF, an image (`.png/.jpg/.jpeg/.tif/.tiff`), or a
directory of them. Ask where output should go.
3. **Classify first** (free, no server):
```bash
python scripts/ocr_document.py --input docs/ --dry-run
```
This labels each PDF `DIGITAL` or `NEEDS_OCR` so the user knows what will hit
the server.
4. **Run OCR**:
```bash
python scripts/ocr_document.py \
--input docs/ --output-dir out/ \
--backend olmocr-docling --host "$OCR_HOST" --dpi 200
```
The tool runs a preflight check and fails with a clear message if the backend
isn't configured. Per-page failures (timeouts, content filters) are skipped
with a placeholder; the rest of the document still processes.
5. **Review** `out/<stem>/<stem>.md` and the `figures/` crops. Iterate if needed:
raise `--dpi`, switch `--model`, or adjust the caption regex / `bad_words` /
language list (see `references/backends.md`).
## Output
Per-document folder with the stitched markdown (`<stem>.md`), a per-page JSON
`cache/`, cropped `figures/`, and rendered `pages/`. Full schema and frontmatter
fields: `references/output_format.md`.
## Communication guidelines
- State up front that a backend is required and is the user's responsibility.
- Before any cloud run, note that pages are sent off-machine and billed per page;
do not send confidential documents to a cloud API without authorization.
- For large corpora, suggest `--dry-run` first and a small sample before the full
run, so cost and quality are known before committing.
## Attribution
Pipeline and prompts adapted from Bruno de Medeiros' **OntoMorphoGrapher**
proof-of-concept (docling + olmOCR-2 over vLLM).Related Skills
busco-phylogeny
Generate phylogenies from genome assemblies using BUSCO/compleasm-based single-copy orthologs with scheduler-aware workflow generation
lab-ordering
Place lab supply orders from member requests — route by request header to Amazon Business, the Pritzker Lab Google Form, or a direct vendor; stage the cart/form and stop for human review before any purchase. Use when the user pastes an order request or asks to order supplies, place an order, or fill the Pritzker form.
extract-from-pdfs
This skill should be used when extracting structured data from scientific PDFs for systematic reviews, meta-analyses, or database creation. Use when working with collections of research papers that need to be converted into analyzable datasets with validation metrics.
biogeobears
Set up and execute phylogenetic biogeographic analyses using BioGeoBEARS in R. Use when users request biogeographic reconstruction, ancestral range estimation, or want to analyze species distributions on phylogenies. Handles input file validation, data reformatting, RMarkdown workflow generation, and result visualization.
accounting
Process receipts, track expenses in Google Sheets, reconcile records, and generate entertainment supplement tables for Field Museum procurement card accounting
emu-bulk-upload
Help museum insect curators bulk upload specimen data to the Emu database. Maps any input format to Emu's template, matches localities to existing records, finds parent sites, creates bulk upload tables, and walks users through the upload process.
code-documentation
Writing effective code documentation - API docs, README files, inline
analyzing-macro-malware-in-office-documents
Analyzes malicious VBA macros embedded in Microsoft Office documents (Word, Excel, PowerPoint) to identify download cradles, payload execution, persistence mechanisms, and anti-analysis techniques. Uses olevba, oledump, and VBA deobfuscation to extract the attack chain. Activates for requests involving Office macro analysis, VBA malware investigation, maldoc analysis, or document-based threat examination.
golang-documentation
Comprehensive documentation guide for Golang projects, covering godoc comments, README, CONTRIBUTING, CHANGELOG, Go Playground, Example tests, API docs, and llms.txt. Use when writing or reviewing doc comments, documentation, adding code examples, setting up doc sites, or discussing documentation best practices. Triggers for both libraries and applications/CLIs.
documentation
Create Architecture Decision Records (ADRs) and Runbooks for operational documentation.
infrastructure-documentation
Skill for the documentation infrastructure module providing figure management, image handling, markdown integration, and API glossary generation. Use when managing research figures, inserting images into manuscripts, auto-numbering figures, or generating API documentation.
template-documentation-creation
Author or refresh AGENTS.md and README.md for template directories — accurate commands, Mermaid where helpful, link _generated/active_projects.md. USE WHEN folder needs AGENTS, README audit, doc contract fix, or signposting after code change — even without documentation_creation prompt.