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
3ec851dc
Unverified
Commit
3ec851dc
authored
Jul 28, 2021
by
Sylvain Gugger
Committed by
GitHub
Jul 28, 2021
Browse files
Fix QA examples for roberta tokenizer (#12928)
parent
fd85734e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
0 deletions
+45
-0
examples/pytorch/question-answering/run_qa.py
examples/pytorch/question-answering/run_qa.py
+10
-0
examples/pytorch/question-answering/run_qa_beam_search.py
examples/pytorch/question-answering/run_qa_beam_search.py
+5
-0
examples/pytorch/question-answering/run_qa_beam_search_no_trainer.py
...torch/question-answering/run_qa_beam_search_no_trainer.py
+10
-0
examples/pytorch/question-answering/run_qa_no_trainer.py
examples/pytorch/question-answering/run_qa_no_trainer.py
+10
-0
examples/tensorflow/question-answering/run_qa.py
examples/tensorflow/question-answering/run_qa.py
+10
-0
No files found.
examples/pytorch/question-answering/run_qa.py
View file @
3ec851dc
...
...
@@ -339,6 +339,11 @@ def main():
# Training preprocessing
def
prepare_train_features
(
examples
):
# Some of the questions have lots of whitespace on the left, which is not useful and will make the
# truncation of the context fail (the tokenized question will take a lots of space). So we remove that
# left whitespace
examples
[
question_column_name
]
=
[
q
.
lstrip
()
for
q
in
examples
[
question_column_name
]]
# Tokenize our examples with truncation and maybe padding, but keep the overflows using a stride. This results
# in one example possible giving several features when a context is long, each of those features having a
# context that overlaps a bit the context of the previous feature.
...
...
@@ -433,6 +438,11 @@ def main():
# Validation preprocessing
def
prepare_validation_features
(
examples
):
# Some of the questions have lots of whitespace on the left, which is not useful and will make the
# truncation of the context fail (the tokenized question will take a lots of space). So we remove that
# left whitespace
examples
[
question_column_name
]
=
[
q
.
lstrip
()
for
q
in
examples
[
question_column_name
]]
# Tokenize our examples with truncation and maybe padding, but keep the overflows using a stride. This results
# in one example possible giving several features when a context is long, each of those features having a
# context that overlaps a bit the context of the previous feature.
...
...
examples/pytorch/question-answering/run_qa_beam_search.py
View file @
3ec851dc
...
...
@@ -327,6 +327,11 @@ def main():
# Training preprocessing
def
prepare_train_features
(
examples
):
# Some of the questions have lots of whitespace on the left, which is not useful and will make the
# truncation of the context fail (the tokenized question will take a lots of space). So we remove that
# left whitespace
examples
[
question_column_name
]
=
[
q
.
lstrip
()
for
q
in
examples
[
question_column_name
]]
# Tokenize our examples with truncation and maybe padding, but keep the overflows using a stride. This results
# in one example possible giving several features when a context is long, each of those features having a
# context that overlaps a bit the context of the previous feature.
...
...
examples/pytorch/question-answering/run_qa_beam_search_no_trainer.py
View file @
3ec851dc
...
...
@@ -315,6 +315,11 @@ def main():
# Training preprocessing
def
prepare_train_features
(
examples
):
# Some of the questions have lots of whitespace on the left, which is not useful and will make the
# truncation of the context fail (the tokenized question will take a lots of space). So we remove that
# left whitespace
examples
[
question_column_name
]
=
[
q
.
lstrip
()
for
q
in
examples
[
question_column_name
]]
# Tokenize our examples with truncation and maybe padding, but keep the overflows using a stride. This results
# in one example possible giving several features when a context is long, each of those features having a
# context that overlaps a bit the context of the previous feature.
...
...
@@ -430,6 +435,11 @@ def main():
# Validation preprocessing
def
prepare_validation_features
(
examples
):
# Some of the questions have lots of whitespace on the left, which is not useful and will make the
# truncation of the context fail (the tokenized question will take a lots of space). So we remove that
# left whitespace
examples
[
question_column_name
]
=
[
q
.
lstrip
()
for
q
in
examples
[
question_column_name
]]
# Tokenize our examples with truncation and maybe padding, but keep the overflows using a stride. This results
# in one example possible giving several features when a context is long, each of those features having a
# context that overlaps a bit the context of the previous feature.
...
...
examples/pytorch/question-answering/run_qa_no_trainer.py
View file @
3ec851dc
...
...
@@ -367,6 +367,11 @@ def main():
# Training preprocessing
def
prepare_train_features
(
examples
):
# Some of the questions have lots of whitespace on the left, which is not useful and will make the
# truncation of the context fail (the tokenized question will take a lots of space). So we remove that
# left whitespace
examples
[
question_column_name
]
=
[
q
.
lstrip
()
for
q
in
examples
[
question_column_name
]]
# Tokenize our examples with truncation and maybe padding, but keep the overflows using a stride. This results
# in one example possible giving several features when a context is long, each of those features having a
# context that overlaps a bit the context of the previous feature.
...
...
@@ -459,6 +464,11 @@ def main():
# Validation preprocessing
def
prepare_validation_features
(
examples
):
# Some of the questions have lots of whitespace on the left, which is not useful and will make the
# truncation of the context fail (the tokenized question will take a lots of space). So we remove that
# left whitespace
examples
[
question_column_name
]
=
[
q
.
lstrip
()
for
q
in
examples
[
question_column_name
]]
# Tokenize our examples with truncation and maybe padding, but keep the overflows using a stride. This results
# in one example possible giving several features when a context is long, each of those features having a
# context that overlaps a bit the context of the previous feature.
...
...
examples/tensorflow/question-answering/run_qa.py
View file @
3ec851dc
...
...
@@ -393,6 +393,11 @@ def main():
# Training preprocessing
def
prepare_train_features
(
examples
):
# Some of the questions have lots of whitespace on the left, which is not useful and will make the
# truncation of the context fail (the tokenized question will take a lots of space). So we remove that
# left whitespace
examples
[
question_column_name
]
=
[
q
.
lstrip
()
for
q
in
examples
[
question_column_name
]]
# Tokenize our examples with truncation and maybe padding, but keep the overflows using a stride. This results
# in one example possible giving several features when a context is long, each of those features having a
# context that overlaps a bit the context of the previous feature.
...
...
@@ -487,6 +492,11 @@ def main():
# Validation preprocessing
def
prepare_validation_features
(
examples
):
# Some of the questions have lots of whitespace on the left, which is not useful and will make the
# truncation of the context fail (the tokenized question will take a lots of space). So we remove that
# left whitespace
examples
[
question_column_name
]
=
[
q
.
lstrip
()
for
q
in
examples
[
question_column_name
]]
# Tokenize our examples with truncation and maybe padding, but keep the overflows using a stride. This results
# in one example possible giving several features when a context is long, each of those features having a
# context that overlaps a bit the context of the previous feature.
...
...
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