Skip to content


[ ]

SpanField Objects#

class SpanField(Field[torch.Tensor]):
 | def __init__(
 |     self,
 |     span_start: int,
 |     span_end: int,
 |     sequence_field: SequenceField
 | ) -> None

A SpanField is a pair of inclusive, zero-indexed (start, end) indices into a SequenceField, used to represent a span of text. Because it's a pair of indices into a SequenceField, we take one of those as input to make the span's dependence explicit and to validate that the span is well defined.


  • span_start : int
    The index of the start of the span in the SequenceField.
  • span_end : int
    The inclusive index of the end of the span in the SequenceField.
  • sequence_field : SequenceField
    A field containing the sequence that this SpanField is a span inside.


 | @overrides
 | def get_padding_lengths(self) -> Dict[str, int]


 | @overrides
 | def as_tensor(self, padding_lengths: Dict[str, int]) -> torch.Tensor


 | @overrides
 | def empty_field(self)