Open Crista23 opened 2 years ago
Had the same problem due to PyPI version of moverscore being outdated,
Please try installing moverscore from the git repo as refered in this solution.
I am having the same error and installing moverscore from the git repo as referred in this https://github.com/AIPHES/emnlp19-moverscore/issues/22#issuecomment-1049560990 did not work. Can someone please help?
from moverscore_v2 import get_idf_dict, word_mover_score from collections import defaultdict
references = ["The quick brown fox jumps over the lazy dog.", "A stitch in time saves nine."] translations = ["The speedy brown fox leaps over the lazy dog.", "A stitch at the right time saves nine."]
idf_dict_hyp = get_idf_dict(translations) # Using default if not specified idf_dict_ref = get_idf_dict(references) # Using default if not specified
try: scores = word_mover_score(references, translations, idf_dict_ref, idf_dict_hyp, stop_words=[], n_gram=1, remove_subwords=True) print("Scores:", scores) except Exception as e: print("Error during scoring:", str(e))
How to fix the error below? Thank you!
$ python3 example.py Traceback (most recent call last): File "example.py", line 79, in
test_sentence_score()
File "example.py", line 72, in test_sentence_score
mover = sentence_score(sys, refs)
File "example.py", line 23, in sentence_score
scores = word_mover_score(references, hypothesis, idf_dict_ref, idf_dict_hyp, stop_words=[], n_gram=1, remove_subwords=False)
File "/usr/lib/python3.7/site-packages/moverscore_v2.py", line 128, in word_mover_score
device=device)
File "/usr/lib/python3.7/site-packages/moverscore_v2.py", line 100, in get_bert_embedding
batch_embedding = torch.stack(batch_embedding)
TypeError: stack(): argument 'tensors' (position 1) must be tuple of Tensors, not str