docling-project/docling · error · RuntimeError

Unknown prompt style `{self.vlm_options.transformers_prompt_

Error message

Unknown prompt style `{self.vlm_options.transformers_prompt_style}`. Valid values are {', '.join(s.value for s in TransformersPromptStyle)}.

What it means

RuntimeError from the transformers-based VLM base model when applying the chat template: vlm_options.transformers_prompt_style does not match any branch of the prompt-style dispatch, i.e. it is not one of the TransformersPromptStyle enum values listed in the message.

Source

Thrown at docling/models/base_model.py:138

            return prompt

        elif self.vlm_options.transformers_prompt_style == TransformersPromptStyle.CHAT:
            messages = [
                {
                    "role": "user",
                    "content": [
                        {"type": "image"},
                        {"type": "text", "text": user_prompt},
                    ],
                }
            ]
            prompt = self.processor.apply_chat_template(
                messages, add_generation_prompt=True
            )
            return prompt

        raise RuntimeError(
            f"Unknown prompt style `{self.vlm_options.transformers_prompt_style}`. Valid values are {', '.join(s.value for s in TransformersPromptStyle)}."
        )


EnrichElementT = TypeVar("EnrichElementT", default=NodeItem)


class GenericEnrichmentModel(ABC, Generic[EnrichElementT]):
    elements_batch_size: int = settings.perf.elements_batch_size

    @abstractmethod
    def is_processable(self, doc: DoclingDocument, element: NodeItem) -> bool:
        pass

    @abstractmethod
    def prepare_element(
        self, conv_res: ConversionResult, element: NodeItem
    ) -> Optional[EnrichElementT]:

View on GitHub (pinned to 61d76f1ff3)

Solutions

  1. Use a TransformersPromptStyle enum member instead of a hand-typed string: vlm_options.transformers_prompt_style = TransformersPromptStyle.CHATTY.
  2. Print ', '.join(s.value for s in TransformersPromptStyle) and correct the value to one of those exact strings.
  3. Regenerate or revalidate serialized option files after upgrading Docling.

Example fix

# before
vlm_options.transformers_prompt_style = 'chat'  # typo'd raw string

# after
from docling.datamodel.pipeline_options_vlm_model import TransformersPromptStyle
vlm_options.transformers_prompt_style = TransformersPromptStyle.CHATTY
Defensive patterns

Strategy: validation

Validate before calling

from docling.datamodel.pipeline_options_vlm_model import TransformersPromptStyle
valid = {s.value for s in TransformersPromptStyle}
assert vlm_options.transformers_prompt_style in valid, f'prompt style must be one of {sorted(valid)}'

Type guard

def is_valid_prompt_style(style: str) -> bool:
    return style in {s.value for s in TransformersPromptStyle}

Try / catch

try:
    out = model(...)
except RuntimeError as e:
    if 'Unknown prompt style' in str(e):
        vlm_options.transformers_prompt_style = TransformersPromptStyle.CHATTY
        out = model(...)

Prevention

When it happens

Trigger: Setting transformers_prompt_style to a raw string that does not equal an enum value (e.g. 'chat' vs 'CHATTY') or to a member added in a newer/older transformers-coupled enum than the model code handles.

Common situations: Loading options from YAML/JSON where the style string drifted from the enum's exact spelling; upgrading Docling/transformers where prompt-style names changed; copy-pasting a style from another model's docs.

Related errors


AI-assisted analysis of docling-project/docling@61d76f1ff3 (2026-08-14). Data as JSON: /api/errors/fea8e78e65e492e1. Report an issue: GitHub.