# Marker (datalab-to/marker) — Evaluation Notes

## Overview
State-of-the-art PDF-to-markdown pipeline. Uses Surya (OCR/layout) → Texify (math) → optional LLM boost.

## Key Facts (2026-05-10)
- **Stars:** 34,892 | **Forks:** 2,420 | **Open issues:** 408
- **License:** GPL-3.0 code + OpenRAIL-M models (commercial requires paid license)
- **Last push:** 2026-05-05 (very active)
- **Install:** `pip install marker-pdf[full]`
- **Model download:** ~2.5GB to HuggingFace cache on first run
- **VRAM:** ~5GB per worker peak, 3.5GB average

## Benchmarks (H100, vs. Llamaparse/Mathpix/Docling)
| Metric | Marker | Llamaparse | Mathpix | Docling |
|--------|--------|------------|---------|---------|
| Heuristic score | 95.67 | 84.24 | 86.43 | 86.71 |
| LLM score | 4.24 | 3.98 | 4.16 | 3.70 |
| Time/page | 0.18s | — | — | — |

Table conversion (FinTabNet): Marker 0.816 → 0.907 with `--use_llm` vs Gemini 0.829.

## LLM Services (for `--use_llm` mode)
- **Gemini** (default) — needs `GOOGLE_API_KEY`
- **Google Vertex** — `--llm_service=marker.services.vertex.GoogleVertexService`
- **Ollama** — local, `--llm_service=marker.services.ollama.OllamaService`
- **Claude** — `--llm_service=marker.services.claude.ClaudeService`
- **OpenAI** — `--llm_service=marker.services.openai.OpenAIService`
- **Azure OpenAI** — `--llm_service=marker.services.azure_openai.AzureOpenAIService`

## CLI Usage
```bash
marker_single file.pdf                          # Markdown output
marker_single file.pdf --json                   # JSON with metadata
marker_single file.pdf --output_dir ./out/      # Custom output dir
marker_single file.pdf --force_ocr              # Force OCR on all pages
marker_single file.pdf --use_llm                # LLM-boosted accuracy
marker_single file.pdf --page_range "0,5-10"    # Specific pages
marker /folder/                                 # Batch convert
marker_single file.pdf --use_llm --llm_service marker.services.ollama.OllamaService  # Local LLM
```

## Python API
```python
from marker.converters.pdf import PdfConverter
from marker.models import create_model_dict
from marker.output import text_from_rendered

converter = PdfConverter(artifact_dict=create_model_dict())
rendered = converter("file.pdf")
text, metadata, images = text_from_rendered(rendered)
```

## Known Limitations
- Very complex layouts (nested tables + forms) may not work perfectly
- Forms may not render well — use `--use_llm` + `--force_ocr` to mitigate
- CPU mode: 1-14s/page (acceptable for sporadic use)
- GPU mode: ~0.18s/page (production-ready throughput)

## Decision for Our Use-Case
**Recommended for medical/lab PDFs.** Far superior to pymupdf+pytesseract combo.
- Handles equations, tables, multi-column layouts natively
- 90+ languages (important for German medical docs)
- `--use_llm` with local Ollama model for privacy-sensitive documents
- GPL license OK for internal use; commercial deployment needs license

## Pitfalls
- `marker` (batch) vs `marker_single` (single file) — different CLI entry points
- Workers need 5GB VRAM each — limit on GPU with limited VRAM
- First run downloads models (~2.5GB) — expect delay
- `--use_llm` requires API key or local Ollama setup
- GPL-3.0: cannot redistribute as proprietary product
