bert_score
bert_score copied to clipboard
Tensor dimension mismatch when using lang='en-sci'
When I BERTScorer as follows:
bert_scorer = BERTScorer(lang='en-sci')
_, _, f1 = bert_scorer.score([pred_text], [r_text])
I get the following error:
RuntimeError: The expanded size of the tensor (556) must match the existing size (512) at non-singleton dimension 1. Target sizes: [2, 556]. Tensor sizes: [1, 512]
I get the same error when I use model_type="allenai/scibert_scivocab_uncased". However, when I use lang="en" there are no errors, so it seems to be an issue with scibert specifically.
Thanks in advance!
I encountered the same issue and found (not ideal but) a quick fix.
You can edit the following line to provide a correct max_length compatible with SciBERT.
At least setting 512 worked for in my case.
Make sure not to set too low so you don't discard your summaries for evaluation too much.
https://github.com/Tiiiger/bert_score/blob/master/bert_score/utils.py#L227
I encountered the same issue and found (not ideal but) a quick fix. You can edit the following line to provide a correct
max_lengthcompatible with SciBERT. At least setting512worked for in my case. Make sure not to set too low so you don't discard your summaries for evaluation too much.https://github.com/Tiiiger/bert_score/blob/master/bert_score/utils.py#L227
Thank you so much!! This bug has been annoyed me for a month!