Datasets:

Modalities:
Text
Libraries:
Datasets
Jon Gauthier commited on
Commit
6d4b2a0
·
1 Parent(s): 07dd735

ignore padding tokens in surprisal aggregation

Browse files
Files changed (1) hide show
  1. syntaxgym.py +6 -0
syntaxgym.py CHANGED
@@ -285,6 +285,12 @@ class SyntaxGymMetric(datasets.Metric):
285
  # token = i_tokens[t_cursor]
286
  token_char_start, token_char_end = i_offsets[t_cursor]
287
 
 
 
 
 
 
 
288
  region_start = region_edges[r_cursor]
289
  region_end = region_edges[r_cursor + 1] \
290
  if r_cursor + 1 < len(region_edges) else max_long
 
285
  # token = i_tokens[t_cursor]
286
  token_char_start, token_char_end = i_offsets[t_cursor]
287
 
288
+ if token_char_start == token_char_end == 0:
289
+ # This is a padding token. Skip.
290
+ # TODO what about BOS/EOS? some models incorporate them
291
+ t_cursor += 1
292
+ continue
293
+
294
  region_start = region_edges[r_cursor]
295
  region_end = region_edges[r_cursor + 1] \
296
  if r_cursor + 1 < len(region_edges) else max_long