Docs /Templates/ sinapsis-deepseek-ocr

DeepSeekOCRInference

sinapsis-deepseek-ocrOCRdeepseekimageoptical_character_recognitiontext

Python template · sinapsis_deepseek_ocr.templates.deepseek_ocr_inference

Overview

Template for DeepSeek OCR inference.

This template uses the DeepSeek OCR model to extract text from images.

Attributes: MODE_REGISTRY: Registry of available inference mode configurations. AttributesBaseModel: The Pydantic model for template attributes. UIProperties: UI metadata for the template.

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis-deepseek-ocr==1.0.0
uv pip install sinapsis-deepseek-ocr==1.0.0
uv add sinapsis-deepseek-ocr==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

mode

The inference mode configuration to use.

typing.Literal['tiny', 'small', 'gundam', 'base', 'large']
Optional
Default: "base"
prompt

The prompt to send to the model (without <image> or <|grounding|> tags).

str
Optional
Default: "OCR the image."
metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
init_args

Initialization arguments for the model.

DeepSeekOCRInitArgs
Optional
Default: null
cache_dir

Directory to cache downloaded models.

str
Optional
Default: "/home/ariel/.cache/sinapsis"
torch_dtype

Precision for model weights. attn_implementation (Literal["flash_attention_2", "eager"]: Attention implementation.

typing.Union[typing.Literal['float16', 'bfloat16', 'auto'], torch.dtype]
Optional
Default: "auto"
use_safetensors

Whether to use safetensors format.

typing.Literal[True]
Optional
Default: true
trust_remote_code

Whether to trust remote code from HuggingFace.

typing.Literal[True]
Optional
Default: true
attn_implementation
typing.Literal['flash_attention_2', 'eager']
Optional
Default: "flash_attention_2"
pretrained_model_name_or_path

HuggingFace model identifier. Defaults to 'deepseek-ai/DeepSeek-OCR'.

typing.Literal['deepseek-ai/DeepSeek-OCR', 'deepseek-ai/DeepSeek-OCR-2']
Optional
Default: "deepseek-ai/DeepSeek-OCR"
enable_grounding

Whether to enable grounding for bounding box extraction.

bool
Optional
Default: false

Configuration example

Generated from documented defaults. Replace any placeholders and complete required nested settings before running.

yaml
templates:
  - template_name: "DeepSeekOCRInference"
    class_name: "DeepSeekOCRInference"
    attributes:
      mode: "base"
      prompt: "OCR the image."
      init_args:
        cache_dir: "/home/ariel/.cache/sinapsis"
        torch_dtype: "auto"
        use_safetensors: true
        trust_remote_code: true
        attn_implementation: "flash_attention_2"
        pretrained_model_name_or_path: "deepseek-ai/DeepSeek-OCR"
      enable_grounding: false

Inheritance

Immediate parent: sinapsis_core.template_base.template.Template

Environment variables

Environment definitions belong to their canonical Python modules.

No directly related environment variables listed.