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
477ec4b6
Unverified
Commit
477ec4b6
authored
Mar 06, 2019
by
Thomas Wolf
Committed by
GitHub
Mar 06, 2019
Browse files
Merge pull request #337 from CatalinVoss/patch-2
Allow tokenization of sequences > 512 for caching
parents
7b9e5a54
4a49c225
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
4 deletions
+4
-4
examples/run_openai_gpt.py
examples/run_openai_gpt.py
+1
-1
pytorch_pretrained_bert/tokenization.py
pytorch_pretrained_bert/tokenization.py
+1
-1
pytorch_pretrained_bert/tokenization_gpt2.py
pytorch_pretrained_bert/tokenization_gpt2.py
+1
-1
pytorch_pretrained_bert/tokenization_openai.py
pytorch_pretrained_bert/tokenization_openai.py
+1
-1
No files found.
examples/run_openai_gpt.py
View file @
477ec4b6
...
...
@@ -163,7 +163,7 @@ def main():
datasets
=
(
train_dataset
,
eval_dataset
)
encoded_datasets
=
tokenize_and_encode
(
datasets
)
# Compute the m
e
x input length for the Transformer
# Compute the m
a
x input length for the Transformer
max_length
=
model
.
config
.
n_positions
//
2
-
2
input_length
=
max
(
len
(
story
[:
max_length
])
+
max
(
len
(
cont1
[:
max_length
]),
len
(
cont2
[:
max_length
]))
+
3
\
for
dataset
in
encoded_datasets
for
story
,
cont1
,
cont2
,
_
in
dataset
)
...
...
pytorch_pretrained_bert/tokenization.py
View file @
477ec4b6
...
...
@@ -120,7 +120,7 @@ class BertTokenizer(object):
for
token
in
tokens
:
ids
.
append
(
self
.
vocab
[
token
])
if
len
(
ids
)
>
self
.
max_len
:
raise
ValueError
(
logger
.
warning
(
"Token indices sequence length is longer than the specified maximum "
" sequence length for this BERT model ({} > {}). Running this"
" sequence through BERT will result in indexing errors"
.
format
(
len
(
ids
),
self
.
max_len
)
...
...
pytorch_pretrained_bert/tokenization_gpt2.py
View file @
477ec4b6
...
...
@@ -193,7 +193,7 @@ class GPT2Tokenizer(object):
token
=
''
.
join
(
self
.
byte_encoder
[
b
]
for
b
in
token
.
encode
(
'utf-8'
))
bpe_tokens
.
extend
(
self
.
encoder
[
bpe_token
]
for
bpe_token
in
self
.
bpe
(
token
).
split
(
' '
))
if
len
(
bpe_tokens
)
>
self
.
max_len
:
raise
ValueError
(
logger
.
warning
(
"Token indices sequence length is longer than the specified maximum "
" sequence length for this OpenAI GPT-2 model ({} > {}). Running this"
" sequence through the model will result in indexing errors"
.
format
(
len
(
bpe_tokens
),
self
.
max_len
)
...
...
pytorch_pretrained_bert/tokenization_openai.py
View file @
477ec4b6
...
...
@@ -232,7 +232,7 @@ class OpenAIGPTTokenizer(object):
else
:
ids
.
append
(
self
.
encoder
.
get
(
token
,
0
))
if
len
(
ids
)
>
self
.
max_len
:
raise
ValueError
(
logger
.
warning
(
"Token indices sequence length is longer than the specified maximum "
" sequence length for this OpenAI GPT model ({} > {}). Running this"
" sequence through the model will result in indexing errors"
.
format
(
len
(
ids
),
self
.
max_len
)
...
...
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