Token indices sequence length is longer than the specified maximum sequence length for this model (580 > 512). Running this sequence through the model will result in indexing errors
RuntimeError: The size of tensor a (580) must match the size of tensor b (512) at non-singleton dimension 1
in forward(self, input_ids, ...
...
outputs = self.bert(input_ids,
tensor b의 크기가 최대 512이여야 하는데, 580의 크기를 가진 tensor가 들어왔다는 내용이다. 512에 맞게 잘라주면 된다.
...
return_tensors='pt',
max_length=512,
truncate=True # <= 추가
)
잘라주기 위해서 tokenizer 선언할 때 truncate 파라미터를 True로 사용했다.