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: Expected input batch_size (2048) to match target batch_size (16) when I load model from HuggingFace #15

Open
sdey17 opened this issue Feb 14, 2025 · 1 comment

Comments

@sdey17
Copy link

sdey17 commented Feb 14, 2025

Hi,

Thank you for providing such detailed instructions on how to use this model. It has been extremely useful to me. I am relatively new to this field of transformers. I cloned the model from GitHub and was able to run it successfully on my own dataset. However, if I try to load the model from HuggingFace using the following, the code fails and I get an error.

config = AutoConfig.from_pretrained("HUBioDataLab/SELFormer", num_labels=num_labels)
model = AutoModelForMaskedLM.from_pretrained("HUBioDataLab/SELFormer", config=config)
tokenizer = AutoTokenizer.from_pretrained("HUBioDataLab/SELFormer", do_lower_case=False)

The error says ValueError: Expected input batch_size (2048) to match target batch_size (16) and 2048 is 16*128 which is the max_length. I have seen occurrences of such errors and they have been associated with how the loss function is computed. Could you please help me figure out what I am doing wrong here?

Thanks,
Souvik

@atabeyunlu
Copy link
Collaborator

Hey Souvik,

Thanks for your interest in our model. Sorry to get back to you late. Can you give me a bit more details about your setup so I can reproduce the error. Information like:

  1. What does the input dataset look like (shape, num_labels, tokenization steps, max_length, batch size used during training/inference)?
  2. Could you provide a minimal, reproducible code snippet that triggers the error?
  3. Are you using a custom loss function, or are you relying on the default one in AutoModelForMaskedLM?

It would be beneficial for me the understand your problem further.

Best,
Atabey

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