Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions metrics/meteor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ It also has several optional parameters:

`gamma`: The relative weight assigned to fragmentation penalty. The default is `0.5`.

`use_aggregator`: If `True` (the default), return the mean score. If `False`, return one score per prediction, in input order.

Refer to the [METEOR paper](https://aclanthology.org/W05-0909.pdf) for more information about parameter values and ranges.

```python
Expand All @@ -70,6 +72,13 @@ The metric outputs a dictionary containing the METEOR score. Its values range fr
{'meteor': 0.9999142661179699}
```

To get the individual scores:

```python
>>> meteor.compute(predictions=["red", "blue sky"], references=["red", "blue sky"], use_aggregator=False)
{'meteor': [0.5, 0.9375]}
```


### Values from popular papers
The [METEOR paper](https://aclanthology.org/W05-0909.pdf) does not report METEOR score values for different models, but it does report that METEOR gets an R correlation value of 0.347 with human evaluation on the Arabic data and 0.331 on the Chinese data.
Expand Down
10 changes: 7 additions & 3 deletions metrics/meteor/meteor.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@
alpha: Parameter for controlling relative weights of precision and recall. default: 0.9
beta: Parameter for controlling shape of penalty as a function of fragmentation. default: 3
gamma: Relative weight assigned to fragmentation penalty. default: 0.5
use_aggregator: Return the mean score if True (default), or one score per prediction if False.
Returns:
'meteor': meteor score.
'meteor': the mean score or a list of scores in prediction order.
Examples:

>>> meteor = evaluate.load('meteor')
Expand All @@ -85,6 +86,9 @@
>>> results = meteor.compute(predictions=predictions, references=references)
>>> print(round(results["meteor"], 4))
0.6944

>>> meteor.compute(predictions=["red", "blue sky"], references=["red", "blue sky"], use_aggregator=False)
{'meteor': [0.5, 0.9375]}
"""


Expand Down Expand Up @@ -127,7 +131,7 @@ def _download_and_prepare(self, dl_manager):
if NLTK_VERSION >= version.Version("3.6.6"):
nltk.download("omw-1.4")

def _compute(self, predictions, references, alpha=0.9, beta=3, gamma=0.5):
def _compute(self, predictions, references, alpha=0.9, beta=3, gamma=0.5, use_aggregator=True):
multiple_refs = isinstance(references[0], list)
if NLTK_VERSION >= version.Version("3.6.5"):
# the version of METEOR in NLTK version 3.6.5 and earlier expect tokenized inputs
Expand Down Expand Up @@ -167,4 +171,4 @@ def _compute(self, predictions, references, alpha=0.9, beta=3, gamma=0.5):
for ref, pred in zip(references, predictions)
]

return {"meteor": np.mean(scores)}
return {"meteor": np.mean(scores) if use_aggregator else scores}