Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
79132145
Unverified
Commit
79132145
authored
Apr 18, 2024
by
Raushan Turganbay
Committed by
GitHub
Apr 18, 2024
Browse files
Fix: remove `pad token id` in pipeline forward arguments (#30285)
parent
df964384
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
src/transformers/pipelines/base.py
src/transformers/pipelines/base.py
+6
-6
No files found.
src/transformers/pipelines/base.py
View file @
79132145
...
@@ -888,11 +888,6 @@ class Pipeline(_ScikitCompat, PushToHubMixin):
...
@@ -888,11 +888,6 @@ class Pipeline(_ScikitCompat, PushToHubMixin):
if
self
.
model
.
can_generate
():
if
self
.
model
.
can_generate
():
self
.
model
.
generation_config
.
update
(
**
task_specific_params
.
get
(
task
))
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
# 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.
# forward params so that `generate` is aware of the pad token.
if
(
if
(
...
@@ -901,7 +896,12 @@ class Pipeline(_ScikitCompat, PushToHubMixin):
...
@@ -901,7 +896,12 @@ class Pipeline(_ScikitCompat, PushToHubMixin):
and
self
.
tokenizer
.
pad_token_id
is
not
None
and
self
.
tokenizer
.
pad_token_id
is
not
None
and
self
.
model
.
generation_config
.
pad_token_id
is
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
self
.
image_processor
is
None
and
self
.
feature_extractor
is
not
None
:
if
isinstance
(
self
.
feature_extractor
,
BaseImageProcessor
):
if
isinstance
(
self
.
feature_extractor
,
BaseImageProcessor
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment