How deepseek-ai/deepseek-ocr works
DeepSeek-OCR is a visual-text model with Transformers and vLLM inference paths for OCR, document-to-Markdown conversion, grounding, image description, and PDF or batch processing. The principal workflow is to provide an image and task prompt, preprocess image tokens and crops, run model inference, then save or render the generated result. Edges follow the sampled calls and README; the Transformers model internals and some vLLM runtime details are not shown, so those connections are omitted.
Main entry points: deepseek_ocr.py OCR model · run_dpsk_ocr_image.py Image inference · run_dpsk_ocr_pdf.py PDF inference · run_dpsk_ocr_eval_batch.py Batch evaluation
Components 16
Inference Inputs
- Transformers runner
DeepSeek-OCR-master/DeepSeek-OCR-hf/run_dpsk_ocr.py - Inference settings
DeepSeek-OCR-master/DeepSeek-OCR-vllm/config.py - PDF document
Vision Model
- Image tokenization
DeepSeek-OCR-master/DeepSeek-OCR-vllm/process/image_process.py - OCR model
DeepSeek-OCR-master/DeepSeek-OCR-vllm/deepseek_ocr.py - CLIP vision encoder
DeepSeek-OCR-master/DeepSeek-OCR-vllm/deepencoder/clip_sdpa.py - SAM vision encoder
DeepSeek-OCR-master/DeepSeek-OCR-vllm/deepencoder/sam_vary_sdpa.py - Feature projector
DeepSeek-OCR-master/DeepSeek-OCR-vllm/deepencoder/build_linear.py
Inference Serving
- Image inference
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_image.py - PDF inference
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_pdf.py - Batch evaluation
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_eval_batch.py - N-gram suppression
DeepSeek-OCR-master/DeepSeek-OCR-vllm/process/ngram_norepeat.py
OCR Outputs
- OCR text
- Layout rendering
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_pdf.py - Markdown files
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_eval_batch.py
Other components
- Image or PDF user
Connections 24
- Image or PDF user → Transformers runner: supplies image
DeepSeek-OCR-master/DeepSeek-OCR-hf/run_dpsk_ocr.py - Transformers runner → OCR model: runs inference
- Image or PDF user → Image inference: supplies image
README.md - Image or PDF user → PDF document: supplies PDF
README.md - PDF document → PDF inference: processes pages
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_pdf.py - Inference settings → Image inference: configures run
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_image.py - Inference settings → PDF inference: configures run
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_pdf.py - Inference settings → Batch evaluation: configures run
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_eval_batch.py - Image inference → Image tokenization: tokenizes image
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_image.py - PDF inference → Image tokenization: tokenizes pages
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_pdf.py - Batch evaluation → Image tokenization: tokenizes images
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_eval_batch.py - Image inference → OCR model: registers model
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_image.py - PDF inference → OCR model: registers model
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_pdf.py - Batch evaluation → OCR model: registers model
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_eval_batch.py - Image inference → N-gram suppression: uses logits filter
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_image.py - Batch evaluation → N-gram suppression: uses logits filter
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_eval_batch.py - OCR model → Image tokenization: uses processor
DeepSeek-OCR-master/DeepSeek-OCR-vllm/deepseek_ocr.py - OCR model → CLIP vision encoder: imports encoder
DeepSeek-OCR-master/DeepSeek-OCR-vllm/deepseek_ocr.py - OCR model → SAM vision encoder: imports encoder
DeepSeek-OCR-master/DeepSeek-OCR-vllm/deepseek_ocr.py - OCR model → Feature projector: imports projector
DeepSeek-OCR-master/DeepSeek-OCR-vllm/deepseek_ocr.py - Image inference → OCR text: generates text
- PDF inference → OCR text: generates text
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_pdf.py - PDF inference → Layout rendering: renders layouts
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_pdf.py - Batch evaluation → Markdown files: writes Markdown
DeepSeek-OCR-master/DeepSeek-OCR-vllm/run_dpsk_ocr_eval_batch.py