AndriyMulyar / semantic-text-similarity

an easy-to-use interface to fine-tuned BERT models for computing semantic similarity in clinical and web text. that's it.
MIT License
215 stars 51 forks source link

RuntimeError: The expanded size of the tensor (11) must match the existing size (15) at non-singleton dimension 0. Target sizes: [11]. Tensor sizes: [15] #1

Closed ghost closed 5 years ago

ghost commented 5 years ago
>>> model.predict([("he lives in america","he is an indian but stays in america")])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data/gitcodes/semantic-text-similarity/semantic_text_similarity/models/bert/similarity.py", line 111, in predict
    [{'sentence_1': s1, 'sentence_2':s2} for s1, s2 in data], self.bert_tokenizer)
  File "/data/gitcodes/semantic-text-similarity/semantic_text_similarity/models/bert/bert_preprocessing.py", line 77, in bert_sentence_pair_preprocessing
    dataset_input_ids[idx] = torch.tensor(input_ids, dtype=torch.long)
RuntimeError: The expanded size of the tensor (11) must match the existing size (15) at non-singleton dimension 0.  Target sizes: [11].  Tensor sizes: [15]
AndriyMulyar commented 5 years ago

Please provide your entire scripts alongside system specifications.

UPDATE: This has been fixed. Thank you for reporting the problem

ghost commented 5 years ago

No special scripts... Just did pip and ran as shown in code.. I am running on Ubuntu

On Tue, 23 Jul, 2019, 8:15 PM Andriy Mulyar, notifications@github.com wrote:

Please provide your entire scripts alongside system specifications.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AndriyMulyar/semantic-text-similarity/issues/1?email_source=notifications&email_token=AHRBKIC7DMHHQEGOYAYWNWDQA4KP5A5CNFSM4IGBCEHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2TLLPI#issuecomment-514241981, or mute the thread https://github.com/notifications/unsubscribe-auth/AHRBKIHDGAPP7DRT3WV2P2LQA4KP5ANCNFSM4IGBCEHA .

AndriyMulyar commented 5 years ago

Please re-install:

pip install --upgrade semantic-text-similarity

ghost commented 5 years ago

Thanks.. What was the issue by the way

On Tue, 23 Jul, 2019, 9:58 PM Andriy Mulyar, notifications@github.com wrote:

Please re-install:

pip install --upgrade semantic-text-similarity

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AndriyMulyar/semantic-text-similarity/issues/1?email_source=notifications&email_token=AHRBKIDE62HKXISKY3UTRZ3QA4WSRA5CNFSM4IGBCEHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2TV4DA#issuecomment-514285068, or mute the thread https://github.com/notifications/unsubscribe-auth/AHRBKIHQOB7N24FKF46XKKDQA4WSRANCNFSM4IGBCEHA .

AndriyMulyar commented 5 years ago

A typo in the BERT pre-processing code that only effected the pre-processing on small batch sizes.