Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/transformers/generation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ def _get_candidate_generator(
atm_translator = AssistantVocabTranslatorCache.get_translator(
target_tokenizer,
assistant_tokenizer,
self.config.vocab_size,
self.config.get_text_config().vocab_size,
assistant_model=assistant_model,
assistant_prune_lm_head=True, # prune LM head of assistant model
)
Expand Down Expand Up @@ -1234,7 +1234,9 @@ def _get_logits_processor(
# Watermarking should be after all logits processing is finished (see #34630)
if generation_config.watermarking_config is not None:
processors.append(
generation_config.watermarking_config.construct_processor(self.config.vocab_size, device)
generation_config.watermarking_config.construct_processor(
self.config.get_text_config().vocab_size, device
)
)

# `LogitNormalization` should always be the last logit processor, when present
Expand Down Expand Up @@ -1412,7 +1414,7 @@ def compute_transition_scores(

# 3. Optionally normalize the logits (across the vocab dimension)
if normalize_logits:
scores = scores.reshape(-1, self.config.vocab_size, scores.shape[-1])
scores = scores.reshape(-1, self.config.get_text_config().vocab_size, scores.shape[-1])
scores = torch.nn.functional.log_softmax(scores, dim=1)
scores = scores.reshape(-1, scores.shape[-1])

Expand All @@ -1426,7 +1428,7 @@ def compute_transition_scores(
beam_indices[beam_indices_mask] = 0

# 6. multiply beam_indices with vocab size to gather correctly from scores
beam_sequence_indices = beam_indices * self.config.vocab_size
beam_sequence_indices = beam_indices * self.config.get_text_config().vocab_size

# 7. Define which indices contributed to scores
cut_idx = sequences.shape[-1] - max_beam_length
Expand Down