primeqa.mrc.metrics.nq_f1.eval_utils.NQSpan#

class primeqa.mrc.metrics.nq_f1.eval_utils.NQSpan(start_byte: int, end_byte: int, start_token: int, end_token: int, score: Optional[float] = None, long_score: Optional[float] = None, enforce_byte_consistency: bool = True, enforce_token_consistency: bool = True)#

Bases: object

A class for handling token and byte spans.

Taken from https://github.com/google-research-datasets/natural-questions/blob/master/eval_utils.py#L60

The logic is: 1) if both start_byte != -1 and end_byte != -1 then the span is defined

by byte offsets

  1. else, if start_token != -1 and end_token != -1 then the span is define by token offsets

3) else, this is a null span. Null spans means that there is no (long or short) answers. If your systems only care about token spans rather than byte spans, set all byte spans to -1.

Methods

contains

is_null_span

A span is a null span if the start and end are both -1.

null_span

Attributes

start_byte

end_byte

start_token

end_token

score

long_score

is_null_span()#

A span is a null span if the start and end are both -1.