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
42121699
Commit
42121699
authored
Mar 06, 2020
by
Patrick von Platen
Browse files
comment out stuff
parent
7a11e925
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
tests/test_modeling_bart.py
tests/test_modeling_bart.py
+16
-16
No files found.
tests/test_modeling_bart.py
View file @
42121699
...
@@ -521,18 +521,18 @@ class BartModelIntegrationTest(unittest.TestCase):
...
@@ -521,18 +521,18 @@ class BartModelIntegrationTest(unittest.TestCase):
tok
.
decode
(
g
,
skip_special_tokens
=
True
,
clean_up_tokenization_spaces
=
False
)
for
g
in
hypotheses_batch
tok
.
decode
(
g
,
skip_special_tokens
=
True
,
clean_up_tokenization_spaces
=
False
)
for
g
in
hypotheses_batch
]
]
hypotheses_batch_bart
=
hf
.
generate_bart
(
#
hypotheses_batch_bart = hf.generate_bart(
input_ids
=
dct
[
"input_ids"
].
to
(
torch_device
),
#
input_ids=dct["input_ids"].to(torch_device),
attention_mask
=
dct
[
"attention_mask"
].
to
(
torch_device
),
#
attention_mask=dct["attention_mask"].to(torch_device),
num_beams
=
4
,
#
num_beams=4,
length_penalty
=
2.0
,
#
length_penalty=2.0,
max_length
=
max_length
,
#
max_length=max_length,
min_len
=
min_length
,
#
min_len=min_length,
no_repeat_ngram_size
=
3
,
#
no_repeat_ngram_size=3,
)
#
)
decoded_bart
=
[
#
decoded_bart = [
tok
.
decode
(
g
,
skip_special_tokens
=
True
,
clean_up_tokenization_spaces
=
False
)
for
g
in
hypotheses_batch_bart
#
tok.decode(g, skip_special_tokens=True, clean_up_tokenization_spaces=False) for g in hypotheses_batch_bart
]
#
]
ipdb
.
set_trace
()
ipdb
.
set_trace
()
...
@@ -540,9 +540,9 @@ class BartModelIntegrationTest(unittest.TestCase):
...
@@ -540,9 +540,9 @@ class BartModelIntegrationTest(unittest.TestCase):
[
EXPECTED_SUMMARY_FRANCE
,
EXPECTED_SUMMARY_SHORTER
,
EXPECTED_SUMMARY_IRAN
,
EXPECTED_SUMMARY_SUBWAY
],
[
EXPECTED_SUMMARY_FRANCE
,
EXPECTED_SUMMARY_SHORTER
,
EXPECTED_SUMMARY_IRAN
,
EXPECTED_SUMMARY_SUBWAY
],
decoded
,
decoded
,
)
)
self
.
assertListEqual
(
#
self.assertListEqual(
[
EXPECTED_SUMMARY_FRANCE
,
EXPECTED_SUMMARY_SHORTER
,
EXPECTED_SUMMARY_IRAN
,
EXPECTED_SUMMARY_SUBWAY
],
#
[EXPECTED_SUMMARY_FRANCE, EXPECTED_SUMMARY_SHORTER, EXPECTED_SUMMARY_IRAN, EXPECTED_SUMMARY_SUBWAY],
decoded_bart
,
#
decoded_bart,
)
#
)
# TODO(SS): run fairseq again with num_beams=2, min_len=20.
# TODO(SS): run fairseq again with num_beams=2, min_len=20.
# TODO(SS): add test case that hits max_length
# TODO(SS): add test case that hits max_length
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