AIPHES / emnlp19-moverscore

MoverScore: Text Generation Evaluating with Contextualized Embeddings and Earth Mover Distance
MIT License
192 stars 31 forks source link

RuntimeError: Sizes of tensors must match except in dimension 0. Got 17 and 13 #24

Open hoangthangta opened 2 years ago

hoangthangta commented 2 years ago
idf_dict_ref:  defaultdict(<function get_idf_dict.<locals>.<lambda> at 0x7f295995c840>, {1044: 1.540445040947149, 101: 0.0, 102: 0.0, 1045: 1.540445040947149, 1010: 1.9459101490553132, 1049: 1.9459101490553132, 1056: 1.9459101490553132, 1037: 1.9459101490553132, 1050: 1.9459101490553132, 1043: 1.9459101490553132, 1012: 1.9459101490553132})

idf_dict_hyp:  defaultdict(<function get_idf_dict.<locals>.<lambda> at 0x7f2946377730>, {1044: 1.791759469228055, 101: 0.0, 102: 0.0, 1041: 2.1972245773362196, 1048: 1.791759469228055, 1051: 2.1972245773362196, 1045: 2.1972245773362196, 1037: 1.791759469228055, 1049: 2.1972245773362196, 1056: 2.1972245773362196, 1050: 2.1972245773362196, 1043: 2.1972245773362196, 1012: 2.1972245773362196})
............................
    stop_words=[], n_gram=1, remove_subwords=True)
  File "/home/user/.env/lib/python3.6/site-packages/moverscore_v2.py", line 150, in word_mover_score
    raw = torch.cat([ref_embedding, hyp_embedding], 1)
RuntimeError: Sizes of tensors must match except in dimension 0. Got 17 and 13 (The offending index is 0)

I have this error. It seems the size of idf_dict_ref and idf_dict_hyp is not the same?

vejvarm commented 1 year ago

Are your refs and hyps lists the same length when you input it to word_mover_score(refs, hyps, ...)?

andyweizhao commented 1 year ago

Can you check the format of your input texts? The code supports two evaluation setups: single-ref and multi-ref. For single-ref, refs and hyps lists have the same length, as each system output is paired with only one reference.