socr
Multi-engine document OCR with cascading fallback and quality audit.
socr orchestrates multiple OCR engines — calling each as a CLI subprocess, auditing output quality, and falling back to a different engine when results are poor. Each engine is a standalone CLI tool (gemini-ocr, deepseek-ocr, marker-ocr, etc.) that can also be used independently.
Install
pip install socr
# With specific engine backends
pip install socr[gemini] # Google Gemini (cloud)
pip install socr[local] # DeepSeek + Nougat (local/free)
pip install socr[all] # All engines
Engines are installed separately because they have different dependencies (torch, cloud SDKs, etc.). Install only what you need.
Usage
# Process a PDF
socr paper.pdf
# Choose engine
socr paper.pdf --primary gemini
socr paper.pdf --primary marker
# Save extracted figures
socr paper.pdf --save-figures
# Batch process a directory
socr batch ~/Papers/ -o ./results/
socr batch ~/Papers/ --dry-run # preview what would be processed
socr batch ~/Papers/ --reprocess # force reprocess all
# Check which engines are available
socr engines
How it works
PDF → Primary OCR → Quality Audit → (Fallback OCR if needed) → Markdown
- Primary OCR — Calls the primary engine CLI on the whole PDF
- Quality audit — Heuristic checks (word count, garbage ratio, repetition)
- Fallback — If audit fails, tries a different engine
Each engine is a separate CLI binary. socr calls it as a subprocess, reads the output markdown, and applies the quality pipeline.
Engines
| Engine | Package | Type | Notes |
|---|---|---|---|
| Gemini | gemini-ocr-cli |
Cloud | Google Gemini, ~$0.0002/page |
| Mistral | mistral-ocr-cli |
Cloud | Mistral AI |
| Marker | marker-ocr-cli |
Local | Layout-aware (Surya + Texify) |
| DeepSeek | deepseek-ocr-cli |
Local | Via Ollama |
| Nougat | nougat-ocr-cli |
Local | Academic papers, Python <3.13 |
Check availability:
$ socr engines
[+] gemini cloud, ~$0.0002/page
[+] marker local, layout-aware (Surya + Texify)
[+] mistral cloud, ~$0.001/page
[+] deepseek local via Ollama
[x] nougat local, academic papers
CLI reference
socr process <PDF> [OPTIONS]
-o, --output-dir PATH Output directory
--primary ENGINE Primary OCR engine (gemini, marker, deepseek, etc.)
--fallback ENGINE Fallback engine
--no-audit Skip quality audit
--save-figures Save extracted figure images
--timeout SECONDS Subprocess timeout (default: 300)
--profile NAME Load ~/.config/socr/{name}.yaml
--config PATH Custom YAML config file
-q, --quiet Suppress non-error output
-v, --verbose Verbose output
--dry-run List files without processing
--reprocess Force reprocess already-done files
socr batch <DIR> [OPTIONS]
Same options as process, plus:
--limit N Process first N files
socr engines Show available engines
Output
output/<doc_stem>/
├── <doc_stem>.md # OCR text
├── metadata.json # Processing stats
└── figures/ # With --save-figures
└── figure_1_page3.png
Configuration
Create ~/.config/socr/config.yaml:
primary_engine: gemini
fallback_engine: marker
timeout: 300
save_figures: false
audit_enabled: true
audit_min_words: 50
Or use profiles: ~/.config/socr/fast.yaml → socr paper.pdf --profile fast
Engine CLIs
Each backend is an independent CLI tool:
- gemini-ocr-cli — Google Gemini
- deepseek-ocr-cli — DeepSeek via Ollama
- mistral-ocr-cli — Mistral AI
- marker-ocr-cli — Marker (Surya + Texify)
- nougat-ocr-cli — Meta Nougat
License
MIT
Metadata
Release files for socr 2.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| socr-2.4.0.tar.gz | 676.4 kB | Without provenance | Details for socr-2.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| socr-2.4.0-py3-none-any.whl | Python 3 | none | any | Details for socr-2.4.0-py3-none-any.whl |
Total release size: 797.8 kB
Release files / socr-2.4.0.tar.gz
| Download URL | socr-2.4.0.tar.gz |
|---|---|
| Size | 676.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb49b3deef929e7bffa3e61954d5f4bec2adf21813c293193968e5410f0a17a9
|
|
BLAKE2b-256 checksum How to use checksums |
efd0639d2e2f506d59e5adaed7f01c0e686219901443b823e2b8fdb5d265776d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / socr-2.4.0-py3-none-any.whl
| Download URL | socr-2.4.0-py3-none-any.whl |
|---|---|
| Size | 121.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fab4d0b90069ef6903776f351e09a1777c808c02ea4118d301995ce48ef38622
|
|
BLAKE2b-256 checksum How to use checksums |
815ea238a23d98adff5a313fa7a8341ec380de474379d0a88056e2e086538812
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for socr 2.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.