Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensor dimension mismatch when using lang='en-sci' #174

Open
isabelcachola opened this issue Dec 28, 2023 · 2 comments
Open

Tensor dimension mismatch when using lang='en-sci' #174

isabelcachola opened this issue Dec 28, 2023 · 2 comments

Comments

@isabelcachola
Copy link

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!

@sobamchan
Copy link

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

@JasonCZH4
Copy link

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

Thank you so much!! This bug has been annoyed me for a month!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants