docs(vllm): fix dots.ocr garbled output by shipping a corrected chat template - #682
Open
KristianZeng wants to merge 1 commit into
Open
docs(vllm): fix dots.ocr garbled output by shipping a corrected chat template#682KristianZeng wants to merge 1 commit into
KristianZeng wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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