2

While implementing this code for mt5 summarization of hugging face This error occurred : enter image description here

18     )
     19     # Extract the median scores
---> 20     result = {key: value.mid.fmeasure * 100 for key, value in result.items()}
     21     return {k: round(v, 4) for k, v in result.items()}

AttributeError: 'numpy.float64' object has no attribute 'mid'

Is there something I could do? since the code is kinda fixed. Thank you :)

Hamzah
  • 8,175
  • 3
  • 19
  • 43
  • Apparently that code did not expect to receive a `float64` object as the `value`. It expected an object which has the `mid` attribute. – zvone Sep 23 '22 at 10:37
  • 1
    Running code that you don't understand, and that none of us are familiar with, is hard. You have to follow the documented requirements of that code carefully. Apparently `result` is a `dict`, and the code expects the values to be some sort of object that has a `mid` attribute. But you have, some how, created one that contains numbers. `mid` is not an attribute of any `numpy` object, array or otherwise. It must be something unique to that `huggingface` code. – hpaulj Sep 23 '22 at 16:15

1 Answers1

0

As @hpaulj suggests, this is a "Hugging Face" thing.

As for example explained in Hugging Face's YouTube video "What is the ROUGE metric?" at 3:20 which is linked from the tutorial you cite, the call to compute of a metric loaded via load_metric used to (?) return a more complex data structure (including confidence intervals for the metrics) than what evaluate does now. The mid then extracts/extracted the "median" confidence interval.

Now, just using value instead of value.mid.fmeasure does the trick:

result = {key: value * 100 for key, value in result.items()}
scherand
  • 2,298
  • 20
  • 27