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
9d9b872b
Unverified
Commit
9d9b872b
authored
Jul 06, 2020
by
Lysandre Debut
Committed by
GitHub
Jul 06, 2020
Browse files
The `add_space_before_punct_symbol` is only for TransfoXL (#5549)
parent
d6b0b9d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
examples/text-generation/run_generation.py
examples/text-generation/run_generation.py
+7
-1
No files found.
examples/text-generation/run_generation.py
View file @
9d9b872b
...
...
@@ -214,8 +214,14 @@ def main():
if
requires_preprocessing
:
prepare_input
=
PREPROCESSING_FUNCTIONS
.
get
(
args
.
model_type
)
preprocessed_prompt_text
=
prepare_input
(
args
,
model
,
tokenizer
,
prompt_text
)
if
model
.
__class__
.
__name__
in
[
"TransfoXLLMHeadModel"
]:
tokenizer_kwargs
=
{
"add_space_before_punct_symbol"
:
True
}
else
:
tokenizer_kwargs
=
{}
encoded_prompt
=
tokenizer
.
encode
(
preprocessed_prompt_text
,
add_special_tokens
=
False
,
return_tensors
=
"pt"
,
add_space_before_punct_symbol
=
True
preprocessed_prompt_text
,
add_special_tokens
=
False
,
return_tensors
=
"pt"
,
**
tokenizer_kwargs
)
else
:
encoded_prompt
=
tokenizer
.
encode
(
prompt_text
,
add_special_tokens
=
False
,
return_tensors
=
"pt"
)
...
...
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