Repository navigation
Chandra VLM can enter repeated-token generation loop with vLLM #4130
PrashanthLande
started this conversation in
Ideas
Replies: 1 comment
|
Just following up on this investigation. I was able to reproduce the repeated-token issue and verify that adjusting the sampling parameters (top_p and temperature) on retry can recover the generation. Would it make sense to handle this retry logic in Docling’s Chandra integration? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
While integrating Chandra OCR 2 with Docling through a vLLM/OpenAI-compatible endpoint, I observed that some documents can cause the VLM to enter a repeated-token generation loop.
The generation continues until
max_new_tokensis reached, resulting infinish_reason="length"instead of a completed OCR response.Observed behavior
For a small set of reproducible documents:
max_new_tokenslimit is reached.The issue is particularly problematic when the generated response is expected to complete within a bounded processing time.
Investigation
I implemented a small repetition detector on the generated VLM response to identify repeated output.
I also tested the sampling strategy used by Chandra's client-side retry behavior:
temperature=0.0,top_p=0.1top_p=0.95In my testing, retrying the same document with the adjusted sampling parameters successfully produced a valid response for cases that previously entered the repetition loop.
For example, the retry logic increases temperature progressively while switching
top_pto0.95.Challenge with retrying after completion
The main issue is that with a non-streaming request, repetition can only be detected after the generation has already completed.
For example, if the first generation consumes the full
max_new_tokensbudget before we detect the repetition, retrying means paying the full generation cost again.In one of my test cases, several attempts were required before getting a successful response, resulting in roughly 20 minutes of processing time for a single page.
So simply adding multiple retries after generation may solve correctness but introduce a significant latency problem.
Possible approaches
I'm currently considering a few possible directions:
I'm not sure which approach would fit best with the current Docling VLM architecture.
Question
Has this behavior been seen with the Chandra integration before?
More importantly, where would you prefer this mitigation to live — in the Chandra-specific integration, in the generic VLM pipeline, or at the vLLM/server level?
I can provide the reproducible documents, logs, and a minimal implementation of the repetition detection/retry approach if useful.
All reactions