Skip to content

Conversation

@Flakes342
Copy link
Contributor

What does this PR do?

Fixes #42203

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Fixed a bug where Blip2Processor assumes num_query_tokens is an int and does max_length - self.num_query_tokens which raises TypeError when num_query_tokens is None.

This change:

  • Treats num_query_tokens as 0 when it is None (with a warning).
  • Adds a minimal unit test to prevent regression.

Who can review?

@Rocketknight1

@Rocketknight1
Copy link
Member

cc @zucchini-nlp! I think it's fine without the warning message, but deferring to her on what behaviour we want from processors 😅

Copy link
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Flakes342 thanks for the PR!

To support older models from the hub which weren't updated, I think we should update the default value of num_query_tokens.

The modeling code assumes that input_ids have special image placeholders and with self.num_query_tokens=None the placeholders will not be added in the input text. Therefore the model will not see an input image

Let's add the default value of 32 which is the only value used in all official checkpoints. Ping me for another review when ready :)

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Flakes342
Copy link
Contributor Author

@zucchini-nlp thr pr is ready for your review

@github-actions
Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: blip_2

@zucchini-nlp
Copy link
Member

run-slow: blip_2

Number of tokens used by the Qformer as queries, should be same as in model's config.
"""

def __init__(self, image_processor, tokenizer, num_query_tokens=None, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I wasn't clear, I meant the default value in the signature here

@github-actions
Copy link
Contributor

This comment contains run-slow, running the specified jobs:

models: ["models/blip_2"]
quantizations: []

@github-actions
Copy link
Contributor

CI Results

Workflow Run ⚙️

Model CI Report

❌ Failed tests

  • blip_2:
    tests/models/blip_2/test_modeling_blip_2.py::Blip2ModelIntegrationTest::test_inference_itm
    tests/models/blip_2/test_modeling_blip_2.py::Blip2ModelIntegrationTest::test_inference_itm_fp16

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.

num_query_tokens of blip2 might be None

4 participants