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
3a08dc63
Unverified
Commit
3a08dc63
authored
May 03, 2023
by
Joao Gante
Committed by
GitHub
May 03, 2023
Browse files
Generate: better warnings with pipelines (#23128)
parent
2a16d8b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
src/transformers/pipelines/base.py
src/transformers/pipelines/base.py
+3
-1
src/transformers/pipelines/text2text_generation.py
src/transformers/pipelines/text2text_generation.py
+2
-1
No files found.
src/transformers/pipelines/base.py
View file @
3a08dc63
...
...
@@ -803,10 +803,12 @@ class Pipeline(_ScikitCompat):
self
.
torch_dtype
=
torch_dtype
self
.
binary_output
=
binary_output
# Update config with task specific parameters
# Update config
and generation_config
with task specific parameters
task_specific_params
=
self
.
model
.
config
.
task_specific_params
if
task_specific_params
is
not
None
and
task
in
task_specific_params
:
self
.
model
.
config
.
update
(
task_specific_params
.
get
(
task
))
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
)
...
...
src/transformers/pipelines/text2text_generation.py
View file @
3a08dc63
...
...
@@ -273,7 +273,8 @@ class SummarizationPipeline(Text2TextGenerationPipeline):
if
input_length
<
max_length
:
logger
.
warning
(
f
"Your max_length is set to
{
max_length
}
, but your input_length is only
{
input_length
}
. You might "
f
"Your max_length is set to
{
max_length
}
, but your input_length is only
{
input_length
}
. Since this is "
"a summarization task, where outputs shorter than the input are typically wanted, you might "
f
"consider decreasing max_length manually, e.g. summarizer('...', max_length=
{
input_length
//
2
}
)"
)
...
...
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