open-mmlab/mmdetection · warning

Inputting a text that is too long will result in poor predic

Error message

Inputting a text that is too long will result in poor prediction performance. Please reduce the --chunked-size.

What it means

Chunked variant of GLIP's prompt tokenization: warns when an individual chunk's token count exceeds language_model.max_tokens, and suggests reducing the chunk size so each chunk fits.

Source

Thrown at mmdet/models/detectors/glip.py:394

            list(range(1,
                       len(original_caption) + 1)), chunked_size)

        positive_map_label_to_token_chunked = []
        caption_string_chunked = []
        positive_map_chunked = []
        entities_chunked = []

        for i in range(len(ids_chunked)):
            if enhanced_text_prompts is not None:
                caption_string, tokens_positive = self.to_enhance_text_prompts(
                    original_caption_chunked[i], enhanced_text_prompts)
            else:
                caption_string, tokens_positive = self.to_plain_text_prompts(
                    original_caption_chunked[i])
            tokenized = self.language_model.tokenizer([caption_string],
                                                      return_tensors='pt')
            if tokenized.input_ids.shape[1] > self.language_model.max_tokens:
                warnings.warn('Inputting a text that is too long will result '
                              'in poor prediction performance. '
                              'Please reduce the --chunked-size.')
            positive_map_label_to_token, positive_map = self.get_positive_map(
                tokenized, tokens_positive)

            caption_string_chunked.append(caption_string)
            positive_map_label_to_token_chunked.append(
                positive_map_label_to_token)
            positive_map_chunked.append(positive_map)
            entities_chunked.append(original_caption_chunked[i])

        return positive_map_label_to_token_chunked, \
            caption_string_chunked, \
            positive_map_chunked, \
            entities_chunked

    def loss(self, batch_inputs: Tensor,
             batch_data_samples: SampleList) -> Union[dict, list]:

View on GitHub (pinned to cfd5d3a985)

Solutions

  1. Decrease the --chunked-size argument so each chunk's caption fits within max_tokens
  2. Shorten category names/phrases

Example fix

# before
texts, chunked_size = prompt, 5
# after
texts, chunked_size = prompt, 2
Defensive patterns

Strategy: validation

Validate before calling

tok = detector.language_model.tokenizer
for chunk in chunks:
    assert tok([chunk], return_tensors='pt').input_ids.shape[1] <= detector.language_model.max_tokens, 'reduce chunked-size'

Prevention

When it happens

Trigger: Using get_tokens_positive_and_prompts_chunked (chunked-size too large) so a chunk's input_ids.shape[1] > max_tokens.

Common situations: Grounding many categories with chunked inference where chunked-size divides categories into still-too-long text groups; default chunk size too big for verbose category names.

Related errors


AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27). Data as JSON: /api/errors/f84af6ef18741064. Report an issue: GitHub.