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

weird criterion to decide if needed to adjust the padding size #35599

Open
hyusterr opened this issue Jan 9, 2025 · 1 comment
Open

weird criterion to decide if needed to adjust the padding size #35599

hyusterr opened this issue Jan 9, 2025 · 1 comment

Comments

@hyusterr
Copy link

hyusterr commented Jan 9, 2025

if len(tensor1.shape) == 1 or tensor1.shape[1] == tensor2.shape[1]:

When working with Trainer and model output with TokenClassiferOutput, the Trainer collect outputs batch by batch in evaluate_loop with nested_concat.
The criterion to decide whether it is needed to adjust the shape is by tensor.shape[1].
However, if user does not exclude attentions with ignore_key beforehand, the shape[1] of the attentions tensor is always the same. Leading to error occurred with torch.cat.
I think this design is kind of weird, especially because this behavior is not emphasized in the token classification tutorial: https://huggingface.co/docs/transformers/tasks/token_classification

@Rocketknight1
Copy link
Member

cc @SunMarc @muellerzr

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

No branches or pull requests

2 participants