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
df52abe3
"examples/git@developer.sourcefind.cn:OpenDAS/nni.git" did not exist on "36b583b705429d39c71b01f04446404d7417da74"
Commit
df52abe3
authored
Aug 28, 2019
by
erenup
Browse files
add sep_toekn between question and choice
parent
43c24325
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
examples/single_model_scripts/utils_multiple_choice.py
examples/single_model_scripts/utils_multiple_choice.py
+11
-5
No files found.
examples/single_model_scripts/utils_multiple_choice.py
View file @
df52abe3
...
@@ -329,7 +329,12 @@ def convert_examples_to_features(examples, label_list, max_seq_length,
...
@@ -329,7 +329,12 @@ def convert_examples_to_features(examples, label_list, max_seq_length,
if
example
.
question
.
find
(
"_"
)
!=
-
1
:
if
example
.
question
.
find
(
"_"
)
!=
-
1
:
tokens_b
=
tokenizer
.
tokenize
(
example
.
question
.
replace
(
"_"
,
ending
))
tokens_b
=
tokenizer
.
tokenize
(
example
.
question
.
replace
(
"_"
,
ending
))
else
:
else
:
tokens_b
=
tokenizer
.
tokenize
(
example
.
question
+
" "
+
ending
)
tokens_b
=
tokenizer
.
tokenize
(
example
.
question
)
tokens_b
+=
[
sep_token
]
if
sep_token_extra
:
tokens_b
+=
[
sep_token
]
tokens_b
+=
tokenizer
.
tokenize
(
ending
)
special_tokens_count
=
4
if
sep_token_extra
else
3
special_tokens_count
=
4
if
sep_token_extra
else
3
_truncate_seq_pair
(
tokens_a
,
tokens_b
,
max_seq_length
-
special_tokens_count
)
_truncate_seq_pair
(
tokens_a
,
tokens_b
,
max_seq_length
-
special_tokens_count
)
...
@@ -425,10 +430,11 @@ def _truncate_seq_pair(tokens_a, tokens_b, max_length):
...
@@ -425,10 +430,11 @@ def _truncate_seq_pair(tokens_a, tokens_b, max_length):
total_length
=
len
(
tokens_a
)
+
len
(
tokens_b
)
total_length
=
len
(
tokens_a
)
+
len
(
tokens_b
)
if
total_length
<=
max_length
:
if
total_length
<=
max_length
:
break
break
if
len
(
tokens_a
)
>
len
(
tokens_b
):
# if len(tokens_a) > len(tokens_b):
tokens_a
.
pop
()
# tokens_a.pop()
else
:
# else:
tokens_b
.
pop
()
# tokens_b.pop()
tokens_a
.
pop
()
processors
=
{
processors
=
{
...
...
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