span#

class SpanEvaluator(limit=0.5)[source]#

Bases: Metric

SpanEvaluator computes the precision, recall and F1-score for span detection.

compute(start_probs, end_probs, gold_start_ids, gold_end_ids)[source]#

Computes the precision, recall and F1-score for span detection.

update(num_correct_spans, num_infer_spans, num_label_spans)[source]#

This function takes (num_infer_spans, num_label_spans, num_correct_spans) as input, to accumulate and update the corresponding status of the SpanEvaluator object.

eval_span(predict_start_ids, predict_end_ids, label_start_ids, label_end_ids)[source]#

evaluate position extraction (start, end) return num_correct, num_infer, num_label input: [1, 2, 10] [4, 12] [2, 10] [4, 11] output: (1, 2, 2)

accumulate()[source]#

This function returns the mean precision, recall and f1 score for all accumulated minibatches.

Returns:

Returns tuple (precision, recall, f1 score).

Return type:

tuple

reset()[source]#

Reset function empties the evaluation memory for previous mini-batches.

name()[source]#

Return name of metric instance.