Skip to content

squad_em_and_f1

allennlp_models.rc.metrics.squad_em_and_f1

[SOURCE]


SquadEmAndF1#

@Metric.register("squad")
class SquadEmAndF1(Metric):
 | def __init__(self) -> None

This Metric takes the best span string computed by a model, along with the answer strings labeled in the data, and computed exact match and F1 score using functions from the official SQuAD2 and SQuAD1.1 evaluation scripts.

__call__#

class SquadEmAndF1(Metric):
 | ...
 | @overrides
 | def __call__(
 |     self,
 |     best_span_strings: Union[str, List[str]],
 |     answer_strings: Union[List[str], List[List[str]]]
 | )

get_metric#

class SquadEmAndF1(Metric):
 | ...
 | @overrides
 | def get_metric(self, reset: bool = False) -> Tuple[float, float]

ReturnsAverage exact match and F1 score (in that order) as computed by the official SQuAD script

over all inputs.

reset#

class SquadEmAndF1(Metric):
 | ...
 | @overrides
 | def reset(self)