Skip to content

Commit b4b5de0

Browse files
zphangjeswan
andauthored
Assert spans <= max_seq_len (#1302)
Co-authored-by: jeswan <[email protected]>
1 parent 4ab0c08 commit b4b5de0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

jiant/tasks/lib/templates/edge_probing_two_span.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ def featurize(self, tokenizer, feat_spec):
108108
end=self.span2_span[1] + unpadded_inputs.cls_offset,
109109
).to_inclusive()
110110

111+
assert span1_span.end <= len(
112+
tokens
113+
), "Span 1 spans beyond max_seq_len, consider raising max_seq_len"
114+
assert span2_span.end <= len(
115+
tokens
116+
), "Span 2 spans beyond max_seq_len, consider raising max_seq_len"
117+
111118
binary_label_ids = np.zeros((self.label_num,), dtype=int)
112119
for label_id in self.label_ids:
113120
binary_label_ids[label_id] = 1

0 commit comments

Comments
 (0)