Advanced Customization#
Most users should rely on the built-in model profiles described in Providers And Configuration. Use this page when you need to override prompt rendering, work directly with template helpers, or parse model-specific OCR output.
Custom OCRModelProfile#
If you need to override prompt rendering for a custom Hugging Face model, pass a custom OCRModelProfile.
from churro_ocr.providers import (
HuggingFaceOptions,
OCRBackendSpec,
OCRModelProfile,
build_ocr_backend,
)
from churro_ocr.templates import HFChatTemplate
backend = build_ocr_backend(
OCRBackendSpec(
provider="hf",
model="your-org/your-vlm",
profile=OCRModelProfile(
profile_name="custom",
template=HFChatTemplate(
system_message="Transcribe the page exactly.",
user_prompt=None,
),
),
options=HuggingFaceOptions(model_kwargs={"device_map": "auto"}),
)
)
Template Exports And Helpers#
Useful public template exports live in churro_ocr.templates.
Use the templates API for exact signatures.
Export |
Use case |
|---|---|
|
Build a Hugging Face chat-style multimodal prompt. |
|
Render a template or template callable into the conversation payload passed to OCR backends. |
|
Generic OCR prompt template used by the default model profile. |
|
Built-in template for |
|
Built-in template for |
|
Built-in template for |
|
Built-in markdown-conversion template for |
|
Built-in structured-markdown template for |
|
Built-in markdown-conversion template for |
|
Built-in template for |
|
Built-in template for |
|
Built-in markdown-conversion template for |
|
Built-in OCR template for |
|
MinerU2.5 layout-detection prompt template used by the built-in two-step backends. |
|
MinerU2.5 table-recognition prompt template used for block extraction. |
|
MinerU2.5 formula-recognition prompt template used for block extraction. |
|
MinerU2.5 image-analysis prompt template used for image and chart blocks. |
|
Built-in template for |
|
Built-in template for the supported |
|
Built-in template for |
|
Type alias for the rendered multimodal conversation payload. |
|
Base protocol for custom profile integration. |
|
Callable form for dynamic prompt rendering from a |
|
Union accepted by helper APIs that can take either a protocol instance or callable template. |
Prompt Exports And Response Helpers#
Useful public prompt exports and response helpers live in churro_ocr.prompts.
Use the prompts API for exact signatures.
Export |
Use case |
|---|---|
|
Default system instruction for generic OCR prompting. |
|
Default user prompt for plain OCR output. |
|
Default user prompt when markdown-style OCR output is preferred. |
|
Upstream Chandra OCR 2 layout-block HTML prompt. |
|
Shared tag name used by the default OCR postprocessor. |
|
Default prompt used by LLM-based page and text-block boundary detection helpers. |
|
Upstream olmOCR YAML-front-matter prompt used by the built-in olmOCR templates. |
|
Convert Chandra HTML-layout output to plain text and preserve raw HTML metadata. |
|
Convert olmOCR YAML or markdown output into plain text plus parsed metadata. |
|
Normalize markdown or HTML OCR output into plain text without model-specific metadata parsing. |
|
Remove the default OCR wrapper tag from model output. |
Exact Reference#
Use the Provider APIs for
OCRBackendSpec,OCRModelProfile, and provider option dataclasses.Use the templates API for template protocols, conversations, and built-in templates.
Use the prompts API for prompt constants and response-parsing helpers.