Skip to content

Commit

Permalink
unfinished intermediate commit to start implementing pseudo log-likel…
Browse files Browse the repository at this point in the history
…ihood fol. cauf&ivanova 2023 (better-mlm-scoring)?
  • Loading branch information
carina-kauf authored and aalok-sathe committed Nov 15, 2023
1 parent 1473cbc commit 5ef4ce4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion surprisal/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,22 @@ def surprise(
mask_mask = torch.eye(n, n)[1:, :].repeat(b, 1).bool()
ids_with_bos_token[mask_mask] = self.tokenizer.mask_token_id

import IPython
# below is from ckauf and neuranna?
# if "within_word_l2r" == PLL_metric:
# """
# Future tokens belonging to the same word as the target token are masked during token inference as well.
# """
# mask_indices = [
# [mask_pos]
# + [
# j
# for j in range(mask_pos + 1, effective_length + 2)
# if word_ids[j] == word_ids[mask_pos]
# ]
# if word_ids[mask_pos] is not None
# else [mask_pos]
# for mask_pos in range(effective_length + 2)
# ]

raise NotImplementedError

Expand Down

0 comments on commit 5ef4ce4

Please sign in to comment.