GitHub Repo
Transformers Community Reports Grounding DINO Positional Encoding Bias That May Change Detection Output
On November 7, the Transformers community reported that the v5 series resets position indices for phrase-ending separators to zero in Grounding DINO, causing outputs to diverge from earlier versions and the original implementation. The report includes a CPU reproduction and a proposed fix, but no related patch has been filed; the effect on accuracy across full datasets remains to be verified.

A new numerical compatibility issue has been reported in the Transformers integration of Grounding DINO. On November 7, a community member opened an issue stating that, starting in v5.0, the vectorized implementation of text position indexing sets the period or question mark at the end of a phrase to zero, diverging from the rules used in v4 and the original model. The author provided a reproduction using Transformers 5.18.0 on CPU and said the same code was still present on the main branch they inspected. Issue report
This detail is directly relevant to normal model usage. Grounding DINO uses text descriptions to specify objects to detect. The official documentation recommends separating categories with periods, for example, a cat. a dog., then processing the output using detection and text thresholds. It can also be paired with SAM to produce text-prompted segmentation masks. The handling of separator positions is therefore worth including in upgrade validation. Official documentation
The report says that when the vectorized code searches for the “previous special token,” it includes the current position. As a result, a separator’s position first becomes negative one and is then clamped to zero. For example, the period in a cat. should receive position two, but instead receives zero. These positions are used in both BERT positional embeddings and text sine embeddings, potentially changing downstream text features and detection scores. Reproduction and root cause analysis
The author recommends shifting the cumulative position results one place to the right, so that only separators strictly before the current token are considered, while retaining the vectorized computation. According to the report, this adjustment, together with an earlier embedding type fix and PIL image preprocessing, allowed the specified integration tests to pass again. Masks and position indices for 2,000 random batches also matched the earlier loop implementation. These results are the submitter’s limited validation and do not establish the extent of any change in overall detection accuracy. Test results
As of the time of review, the issue remained open and listed no related PR. Engineering teams can first compare outputs for multi-category prompts before and after an upgrade, while keeping weights, image preprocessing, and thresholds fixed to avoid conflating numerical differences from different sources. They should then watch for maintainer confirmation, regression tests, and inclusion in an official release.