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

ValueError warning in BartAdapterModel is unnecessary for sequence labeling task/generative task #563

Closed
2 tasks
dyxohjl666 opened this issue Jul 3, 2023 · 0 comments · Fixed by #624
Closed
2 tasks
Assignees
Labels
bug Something isn't working

Comments

@dyxohjl666
Copy link

dyxohjl666 commented Jul 3, 2023

Information

Model I am using (Bert, XLNet ...): BartAdapterModel

Language I am using the model on (English, Chinese ...): English

Adapter setup I am using (if any): pffeifer

The problem arises when using:

  • the official example scripts: (give details below)

The tasks I am working on is:

  • an official GLUE/SQUaD task: mlm

To reproduce

Steps to reproduce the behavior:

  1. Follow the official run_mlm.py and use BartAdapterModel as the backbone.
  2. Got " ValueError("All examples must have the same number of tokens.")" during training.

I checked the source code in bart/adatper_model.py and modeling_bart.py (in transformers) and found this in BartAdapterModel's forward() function:

            if len(torch.unique(eos_mask.sum(1))) > 1:
                raise ValueError("All examples must have the same number of <eos> tokens.")
            cls_representation = x[eos_mask, :].view(x.size(0), -1, x.size(-1))[:, -1, :]

which is the same with BartForSequenceClassification. I think it's not necessary for a sequence labeling task? When doing masked language model, all the input text are concatenated and then grouped by every 1024 tokens, and it's common to include different number of tokens accordingly.
This error exists even I add a seq2seq_lm_head.

Expected behavior

The mentioned ValueError should be applied only for classification tasks.

@dyxohjl666 dyxohjl666 added the bug Something isn't working label Jul 3, 2023
@calpt calpt self-assigned this Dec 16, 2023
@calpt calpt closed this as completed in #624 Jan 7, 2024
@calpt calpt closed this as completed in 2e2f302 Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants