Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processors: don't default padding side #33942

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zucchini-nlp
Copy link
Member

What does this PR do?

Fixes #33847. We should not have default values for padding side after the last PR that enabled passing padding_side to tokenizer directly. Users are free to set padding side as tokenizer attr or pass it to processors directly

cc @yonigozlan if you had any PRs in progress with default padding-side 😉

Copy link
Contributor

@molbap molbap left a comment

Choose a reason for hiding this comment

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

Will be cleaner! added a single comment

src/transformers/models/llava/processing_llava.py Outdated Show resolved Hide resolved
@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.

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

➕ on Pablo's comment, good to go otherwise!

Comment on lines +832 to +837
value = (
getattr(self.tokenizer, modality_key)
if hasattr(self.tokenizer, modality_key)
else tokenizer_init_kwargs[modality_key]
)
default_kwargs[modality][modality_key] = value
Copy link
Member Author

Choose a reason for hiding this comment

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

I just realized the issue comes from this line when we use default tokenizer kwargs that were set during init. It a bit breaking if ppl change the attr like padding_side and that is not reflected in init_kwargs, so I think we can check first tokenizer attr and then fallback to the init kwargs
@molbap wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see, yes that makes sense, it should be a "soft" check though to make sure we are not requiring anything at this stage, just that if it is present, it should be superseding.
Handling priorities in this script is 🤪 good catch though!

Copy link
Member Author

Choose a reason for hiding this comment

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

yea, i think the check is soft as we first see if attribute if present, and if not fallback to the usual init_kwargs[key]

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.

Llava processor changing padding side of tokenizer has no effect.
4 participants