batch_size, seq_length = input_shape ValueError: too many values to unpack (expected 2) Transformer Sentence Similarity Classification
Author: Chimaco37
Pull request: no

I encountering a problem when doing Sentence Similarity Classification Task Using Transformer.

It happens when I was about to train my model, I load and process my dataset in this way, and this is what the training dataset element shape looks like:

![image](https://github.com/huggingface/transformers/assets/77201421/58dfce32-a8d8-4473-a169-435f41f48818)

but when I train the model, it says:

ValueError: Caught ValueError in replica 0 on device 0.
Original Traceback (most recent call last):
  File "/home/fanshaoqi/anaconda3/envs/tf2/lib/python3.10/site-packages/torch/nn/parallel/parallel_apply.py", line 85, in _worker
    output = module(*input, **kwargs)
  File "/home/fanshaoqi/anaconda3/envs/tf2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/fanshaoqi/anaconda3/envs/tf2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/fanshaoqi/anaconda3/envs/tf2/lib/python3.10/site-packages/transformers/models/bert/modeling_bert.py", line 1564, in forward
    outputs = self.bert(
  File "/home/fanshaoqi/anaconda3/envs/tf2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/fanshaoqi/anaconda3/envs/tf2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/fanshaoqi/anaconda3/envs/tf2/lib/python3.10/site-packages/transformers/models/bert/modeling_bert.py", line 967, in forward
    batch_size, seq_length = input_shape
ValueError: too many values to unpack (expected 2)

So I figure try this to decrease the dimension
![image](https://github.com/huggingface/transformers/assets/77201421/65dcd314-6bbc-4f0a-bcf1-12e31fbf6a2a)
the training element looks like this now:
![image](https://github.com/huggingface/transformers/assets/77201421/7c3b2dba-a279-4d83-8eb3-11a08a5c6006)

and the model was able to train, but its extremely slow!!!
![2f1ee98a5c2ceb0bc6d71e9aabd8173](https://github.com/huggingface/transformers/assets/77201421/25a7ab53-016e-4496-aa25-6bf819403163)

And because this is a sentence similarity classification task, so i suppose the batch_size should be 2? but it always 1. what it should be like?

Dont really understand why, Been struggling for a long time, Someone pls help. Thanks!



Comments:
I think the first training element shape is correct, because thats what official document presents, but it just couldnt run the model.
![image](https://github.com/huggingface/transformers/assets/77201421/e2de8374-10f1-43c0-949a-45cda8fc77cb)
![image](https://github.com/huggingface/transformers/assets/77201421/a056c205-1cbb-4537-b0e2-8692898b43ca)
![image](https://github.com/huggingface/transformers/assets/77201421/f7e94957-712f-46c0-9394-2f2575768465)
![image](https://github.com/huggingface/transformers/assets/77201421/1dff0b77-a858-4d6c-80c3-3eb04cd2cc0b)
This is how i config the model