Skip to content

docs(vllm): fix dots.ocr garbled output by shipping a corrected chat template - #682

Open
KristianZeng wants to merge 1 commit into
intel:mainfrom
KristianZeng:fix/dotsocr-chat-template
Open

docs(vllm): fix dots.ocr garbled output by shipping a corrected chat template#682
KristianZeng wants to merge 1 commit into
intel:mainfrom
KristianZeng:fix/dotsocr-chat-template

Conversation

@KristianZeng

Copy link
Copy Markdown
Contributor

The chat_template.json shipped with dots.ocr does not emit the <|user|> / <|endofuser|> role delimiters (token ids 151670 / 151671) when the message content is an array, and concatenates the array in the order supplied by the caller. The generation marker <|assistant|> therefore follows the image patch tokens with no role terminator in between, and a significant fraction of requests return hallucinated text instead of the expected JSON object.

Measured on a fixed set of 300 document crops at concurrency 8, with prefix caching and the multimodal processor cache disabled:

Intel Arc Pro B60, vLLM 0.26.1.dev 53/300 -> 7/300
NVIDIA RTX 4090, vLLM 0.26.0 61/300 -> 7/300
NVIDIA RTX 4090, vLLM main 61/300 -> 7/300

Paired McNemar exact test on identical inputs: p = 7.7e-10 (Intel) and p = 2.7e-12 (RTX 4090). The same comparison across hardware at matched vLLM version and template gives p = 0.332, so the defect is not platform specific. Behaviour is unchanged on vLLM main, so waiting for an engine update is not a mitigation.

Add chat_template_dots_ocr.jinja, which restores the role wrapper on the array branch and emits image parts before text parts so that both caller orderings render to the same sequence. The system, assistant and trailing sections are byte-identical to the original template. Document the required --chat-template argument and a /tokenize check.

Refs: #599

…template

The chat_template.json shipped with dots.ocr does not emit the
<|user|> / <|endofuser|> role delimiters (token ids 151670 / 151671)
when the message content is an array, and concatenates the array in
the order supplied by the caller. The generation marker <|assistant|>
therefore follows the image patch tokens with no role terminator in
between, and a significant fraction of requests return hallucinated
text instead of the expected JSON object.

Measured on a fixed set of 300 document crops at concurrency 8, with
prefix caching and the multimodal processor cache disabled:

  Intel Arc Pro B60, vLLM 0.26.1.dev  53/300 -> 7/300
  NVIDIA RTX 4090,   vLLM 0.26.0      61/300 -> 7/300
  NVIDIA RTX 4090,   vLLM main        61/300 -> 7/300

Paired McNemar exact test on identical inputs: p = 7.7e-10 (Intel) and
p = 2.7e-12 (RTX 4090). The same comparison across hardware at matched
vLLM version and template gives p = 0.332, so the defect is not
platform specific. Behaviour is unchanged on vLLM main, so waiting for
an engine update is not a mitigation.

Add chat_template_dots_ocr.jinja, which restores the role wrapper on
the array branch and emits image parts before text parts so that both
caller orderings render to the same sequence. The system, assistant and
trailing sections are byte-identical to the original template. Document
the required --chat-template argument and a /tokenize check.

Refs: intel#599
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant