Skip to content

Commit

Permalink
Slight simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
Rocketknight1 committed Feb 6, 2025
1 parent 15ff9ef commit a322e8d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/transformers/generation/stopping_criteria.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,7 @@ def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwa
flipped_ids = torch.flip(input_ids, (1,))

# Clip out-of-vocab values to the dummy value at the end of the embedding vector
vocab_size = self.embedding_vec.size(0)
flipped_ids = torch.clamp(flipped_ids, max=vocab_size - 1)
flipped_ids = torch.clamp(flipped_ids, max=self.embedding_vec.size(0) - 1)

# Size of the vector of positions a single token can match
max_valid_positions = self.max_valid_positions
Expand Down

0 comments on commit a322e8d

Please sign in to comment.