MiniLM RuntimeError: The size of tensor a (599) must match the size of tensor b (512) at non-singleton dimension 1

Context:
To perform text classification, there’s one particle cell texts exceed the limit of 512 . However, I tried to truncate the using the “truncation=True” but it still does not seem to work.

Any help is welcomed! Please Help :frowning:

Code:
pipe = pipeline(model=“Path to Finetuned Minilm Model”)
csv_file = “test.csv”
test = load_dataset(“csv”, data_files=csv_file)

//input
print(test[‘train’][“sentence”][1766])
//feed to model
result=pipe(test[‘train’][“sentence”][1766], top_k=1, truncation=True)
print(result)

Result:
60e3ecf3727f931b87ff6e28d93578d6e68a1106a1bcc9861a60e922e5aecdd7 6aeb678dbc6c686510273642c1be3a484436df7ddfcd0cc5320fc81f86c63fff 6f562bc13a68d6d1b1748ac3e68d816a49b7a8f39eff45e5ee877257bed4ba84 79a1a96cee5e8e68f9f470c33a264bfc08e025e278c721a3593bd23851056c89 8a9026e3443ea4e40687161628ec243e20d03962c2028f1f4d899d346376c1ee 8c3757d3af9e1e73ed829a861031ef011f9e66efe787a425b38880339bb4d1d2 9237fba115e33d1d398ef5996d2bf0e5a07f5b420615d9f0224d601effe5314d 9bb091b2ba045774521260b8886153b12cdfce2ede7f175927484ec4e954665c a92fcbf5d000d79e0dc176eb0149f56c048184c62870dec17d23caf87cb4b224 ad3007a70636d72419046ddadb7a5d84dca9fc029c65398a7414deed2839b09e b0dd26a6cf17d346f1dae35a43cbc6d47bf484d20b5bc4b5ec374f289b428f91 b902bd944848f6cf48a28c1ce9c3d196a5d7588a320db10ae0cb75f1e63c2ab6 bcbd05416f810460b3d296621ad88275b22c6f02c00e3a566af35ab714b11ca1

RuntimeError: The size of tensor a (599) must match the size of tensor b (512) at non-singleton dimension 1

1 Like