Skip to content

uniformize kwargs for VisionTextDualEncoder#34563

Merged
ArthurZucker merged 2 commits into
huggingface:mainfrom
tibor-reiss:fix-31811-visiontextdualencoder
Apr 30, 2025
Merged

uniformize kwargs for VisionTextDualEncoder#34563
ArthurZucker merged 2 commits into
huggingface:mainfrom
tibor-reiss:fix-31811-visiontextdualencoder

Conversation

@tibor-reiss

Copy link
Copy Markdown
Contributor

Adds uniformized processors for VisionTextDualEncoder following #31911.

@qubvel @molbap

@tibor-reiss

Copy link
Copy Markdown
Contributor Author

@molbap I changed the order of text and images (I saw that in a similar PR as a comment). But this breaks backwards compatibility. I tried to do a isinstance check and flip after, but it errors because how these type aliases are defined. Any other idea how BC can be maintained - if it is a strict requirement?

@tibor-reiss
tibor-reiss force-pushed the fix-31811-visiontextdualencoder branch from a1626ed to 0decb11 Compare November 1, 2024 14:33
@molbap

molbap commented Nov 1, 2024

Copy link
Copy Markdown
Collaborator

Hi @tibor-reiss , you can use _validate_images_text_input_order from processing_utils!

@qubvel qubvel mentioned this pull request Nov 2, 2024
40 tasks
@tibor-reiss

Copy link
Copy Markdown
Contributor Author

Hi @tibor-reiss , you can use _validate_images_text_input_order from processing_utils!

Done, could you please check again @molbap?

@tibor-reiss

Copy link
Copy Markdown
Contributor Author

Friendly reminder @molbap

@molbap molbap left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for uniformizing this! cc @ArthurZucker for core review

@ArthurZucker ArthurZucker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A nit butLGTM otherwise!

Comment on lines +27 to +28
class VisionTextDualEncoderProcessorKwargs(ProcessingKwargs, total=False):
_defaults = {}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if there are no defualt we can just use the processingKwargs directly!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think that is possible because _merge_kwargs: it requires _defaults - https://github.com/huggingface/transformers/blob/main/src/transformers/processing_utils.py#L1056

If you would like to, I could open another PR to have _defaults included in the parent, ProcessingKwargs - that would also make mypy happy :)

@tibor-reiss
tibor-reiss force-pushed the fix-31811-visiontextdualencoder branch from 1ff76b6 to e9982a4 Compare April 27, 2025 06:35
@tibor-reiss

Copy link
Copy Markdown
Contributor Author

Rebased

@ArthurZucker ArthurZucker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks and sorry for the delay!

@ArthurZucker
ArthurZucker merged commit 6c5d374 into huggingface:main Apr 30, 2025
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request May 14, 2025
* Make kwargs uniform for VisionTextDualEncoder

* Add bc for flipped args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants