Skip to content

Commit ae38bec

Browse files
authored
[Minor] refactor(setup_distance_lookup): reusing attribute self.vocab_size (#21)
1 parent 1b5824b commit ae38bec

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

ntloss/core.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,7 @@ def setup_distance_lookup(
499499
num_ids = torch.nonzero(self.is_number_token, as_tuple=True)[0]
500500
# Create mapping from number token ids to their index in order of appearance in vocab:
501501
# e.g. token "3" -> id 519 -> dist_idx 1, then abs dist to 3 for other NT values will be found in row/column 1
502-
final_vocab_size = self.number_values.shape[0]
503-
vocab_to_dist_idx = torch.full((final_vocab_size,), -1, dtype=torch.long)
502+
vocab_to_dist_idx = torch.full((self.vocab_size,), -1, dtype=torch.long)
504503
# Use arange to ensure order of appearance
505504
vocab_to_dist_idx[num_ids] = torch.arange(num_ids.size(0), dtype=torch.long)
506505

0 commit comments

Comments
 (0)