Skip to content

Commit

Permalink
Assert spans <= max_seq_len (#1302)
Browse files Browse the repository at this point in the history
Co-authored-by: jeswan <57466294+jeswan@users.noreply.github.com>
  • Loading branch information
zphang and jeswan committed Apr 8, 2021
1 parent 4ab0c08 commit b4b5de0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions jiant/tasks/lib/templates/edge_probing_two_span.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ def featurize(self, tokenizer, feat_spec):
end=self.span2_span[1] + unpadded_inputs.cls_offset,
).to_inclusive()

assert span1_span.end <= len(
tokens
), "Span 1 spans beyond max_seq_len, consider raising max_seq_len"
assert span2_span.end <= len(
tokens
), "Span 2 spans beyond max_seq_len, consider raising max_seq_len"

binary_label_ids = np.zeros((self.label_num,), dtype=int)
for label_id in self.label_ids:
binary_label_ids[label_id] = 1
Expand Down

0 comments on commit b4b5de0

Please sign in to comment.