Skip to content

Commit

Permalink
Fix: remove pad token id in pipeline forward arguments (#30285)
Browse files Browse the repository at this point in the history
  • Loading branch information
zucchini-nlp authored Apr 18, 2024
1 parent df96438 commit 7913214
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/transformers/pipelines/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,11 +888,6 @@ def __init__(
if self.model.can_generate():
self.model.generation_config.update(**task_specific_params.get(task))

self.call_count = 0
self._batch_size = kwargs.pop("batch_size", None)
self._num_workers = kwargs.pop("num_workers", None)
self._preprocess_params, self._forward_params, self._postprocess_params = self._sanitize_parameters(**kwargs)

# Pipelines calling `generate`: if the tokenizer has a pad token but the model doesn't, set it in the
# forward params so that `generate` is aware of the pad token.
if (
Expand All @@ -901,7 +896,12 @@ def __init__(
and self.tokenizer.pad_token_id is not None
and self.model.generation_config.pad_token_id is None
):
self._forward_params["pad_token_id"] = self.tokenizer.pad_token_id
kwargs["pad_token_id"] = self.tokenizer.pad_token_id

self.call_count = 0
self._batch_size = kwargs.pop("batch_size", None)
self._num_workers = kwargs.pop("num_workers", None)
self._preprocess_params, self._forward_params, self._postprocess_params = self._sanitize_parameters(**kwargs)

if self.image_processor is None and self.feature_extractor is not None:
if isinstance(self.feature_extractor, BaseImageProcessor):
Expand Down

0 comments on commit 7913214

Please sign in to comment.